Author: mareshkau
Date: 2010-03-15 09:11:02 -0400 (Mon, 15 Mar 2010)
New Revision: 20823
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5985
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp 2010-03-15
13:11:02 UTC (rev 20823)
@@ -0,0 +1,16 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+ <f:view id="jbide-5985">
+ <h:graphicImage
value="#{facesContext.externalContext.requestContextPath}/resources/img/img.gif"></h:graphicImage>
+ <img
src="#{facesContext.externalContext.requestContextPath}/resources/img/img.gif"/>
+ </f:view>
+ </body>
+</html>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml 2010-03-15
13:11:02 UTC (rev 20823)
@@ -0,0 +1,14 @@
+<tests>
+<test id="jbide-5985">
+<TABLE STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px; width:
100%;">
+<TR>
+<TD>
+<DIV>
+<IMG SRC="/.*jsf2test/WebContent/resources/img/img.gif/"
STYLE="-moz-user-modify: read-write;"/>
+<IMG SRC="/.*jsf2test/WebContent/resources/img/img.gif/"/>
+</DIV>
+</TD>
+</TR>
+</TABLE>
+</test>
+</tests>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-03-15
04:46:19 UTC (rev 20822)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-03-15
13:11:02 UTC (rev 20823)
@@ -91,6 +91,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.SelectAllAndCut_JBIDE4853;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.SelectWholeElement_JBIDE4713;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.TaglibXMLUnformatedDTD_JBIDE5642;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestContextPathResolution;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestFViewLocaleAttribute_JBIDE5218;
import
org.jboss.tools.jsf.vpe.jsf.test.jbide.TestForUsingComponentsLibrariesWithDefaultNamespace;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestOpenOnForXhtmlFiles_JBIDE5577;
@@ -121,6 +122,7 @@
TestSuite suite = new TestSuite("Tests for Vpe Jsf components");
//$NON-NLS-1$
// $JUnit-BEGIN$
+ suite.addTestSuite(TestContextPathResolution.class);
suite.addTestSuite(JBIDE5920Test.class);
suite.addTestSuite(RenderFacetAndInsertChildrenTest.class);
suite.addTestSuite(EditFontFamilyTest_JBIDE5872.class);
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestContextPathResolution.java 2010-03-15
13:11:02 UTC (rev 20823)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.ComponentContentTest;
+
+/**
+ *
https://jira.jboss.org/jira/browse/JBIDE-5985
+ *
+ * @author mareshkau
+ *
+ */
+public class TestContextPathResolution extends ComponentContentTest{
+
+ public TestContextPathResolution(String name) {
+ super(name);
+ }
+
+ public void testContextPathResolution() throws Throwable{
+ performContentTest("JBIDE/5985/testFacesContextResolution.jsp");
//$NON-NLS-1$
+ }
+
+ @Override
+ protected String getTestProjectName() {
+ return JsfAllTests.IMPORT_JSF_20_PROJECT_NAME;
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java 2010-03-15
04:46:19 UTC (rev 20822)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionHref.java 2010-03-15
13:11:02 UTC (rev 20823)
@@ -36,7 +36,7 @@
public VpeValue exec(VpePageContext pageContext, Node sourceNode) throws
VpeExpressionException {
String tagValue = getParameter(0).exec(pageContext, sourceNode).stringValue();
- tagValue = resolveEL(pageContext,tagValue);
+ //tagValue = resolveEL(pageContext,tagValue);
IPath tagPath = new Path(tagValue);
if (tagPath.isEmpty()) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2010-03-15
04:46:19 UTC (rev 20822)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2010-03-15
13:11:02 UTC (rev 20823)
@@ -52,7 +52,7 @@
public VpeValue exec(VpePageContext pageContext, Node sourceNode) throws
VpeExpressionException {
String tagValue = getParameter(0).exec(pageContext, sourceNode)
.stringValue();
- tagValue = resolveEL(pageContext,tagValue);
+// tagValue = resolveEL(pageContext,tagValue);
IFile iFile = VpeCreatorUtil.getFile(tagValue, pageContext);
if (iFile != null) {
@@ -251,24 +251,24 @@
* temporary solution to solve #{facesContext.externalContext.requestContextPath}
* JBIDE-1410
*/
- protected String resolveEL(VpePageContext pageContext, String value) {
- String resolvedValue =
value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
""); //$NON-NLS-1$ //$NON-NLS-2$
-
- //fix for JBIDE-2550, author Maksim Areshkau
- if(Jsf2ResourceUtil.isJSF2ResourceString(resolvedValue)){
- resolvedValue = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext,
resolvedValue);
- }
-
- //Fix for JBIDE-3030
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
- || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() instanceof
IFile)){
- return resolvedValue;
- }
- final IFile file = (IFile)
pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
-
- resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
- return resolvedValue;
- }
+// protected String resolveEL(VpePageContext pageContext, String value) {
+// String resolvedValue =
value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
""); //$NON-NLS-1$ //$NON-NLS-2$
+//
+// //fix for JBIDE-2550, author Maksim Areshkau
+// if(Jsf2ResourceUtil.isJSF2ResourceString(resolvedValue)){
+// resolvedValue = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext,
resolvedValue);
+// }
+//
+// //Fix for JBIDE-3030
+// if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
+// || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() instanceof
IFile)){
+// return resolvedValue;
+// }
+// final IFile file = (IFile)
pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
+//
+// resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
+// return resolvedValue;
+// }
public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
String pluginPath = VpePlugin.getPluginResourcePath();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2010-03-15
04:46:19 UTC (rev 20822)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2010-03-15
13:11:02 UTC (rev 20823)
@@ -186,7 +186,9 @@
if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode,
file)))
|| isInResourcesBundle(pageContext, sourceNode)){
rst = true;
- }else if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
+ }else if(Jsf2ResourceUtil.isContainJSFExternalContextPath(sourceNode)){
+ rst = true;
+ }if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
//added by Maksim Areshkau, see JBIDE-4812
rst = true;
}
@@ -386,6 +388,10 @@
//replace custom attributes
rst = replaceCustomAttributes(pageContext,rst);
+ if(Jsf2ResourceUtil.isExternalContextPathString(value)){
+ rst = Jsf2ResourceUtil.processExternalContextPath(value);
+ }
+
if(Jsf2ResourceUtil.isJSF2ResourceString(rst)){
rst = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, rst);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java 2010-03-15
04:46:19 UTC (rev 20822)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java 2010-03-15
13:11:02 UTC (rev 20823)
@@ -29,12 +29,60 @@
.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*'(.*)'\\s*\\]\\s*\\}");
//$NON-NLS-1$
private static final Pattern resourcePatternWithDoableCoat = Pattern
.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*\"(.*)\"\\s*\\]\\s*\\}");
//$NON-NLS-1$
+ private static final Pattern jsfExternalContextPath = Pattern
+ .compile("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}");
//$NON-NLS-1$
+ /**
+ * Check if node contains attributes like this
src="#{facesContext.externalContext.requestContextPath}/images/sample.gif"
+ * @param sourceNode
+ * @return true if node contains
#{facesContext.externalContext.requestContextPath}/images/sample.gif
+ * @author mareshkau, fix for
https://jira.jboss.org/jira/browse/JBIDE-5985
+ */
+ public static boolean isContainJSFExternalContextPath(Node sourceNode) {
+ boolean result = false;
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ String textValue = sourceNode.getNodeValue();
+ if (textValue != null) {
+ if (Jsf2ResourceUtil.isExternalContextPathString(textValue)) {
+ result = true;
+ }
+ }
+ } else {
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
+ if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ if (Jsf2ResourceUtil
+ .isExternalContextPathString(((Attr) nodeMap
+ .item(i)).getValue())) {
+ result = true;
+ }
+ }
+ }
+ }
+ return result;
+ }
/**
+ * Checks string for jsf declaration
+ * @param attributeValue
+ * @return true is string contains #{facesContext.externalContext.requestContextPath}
+ * @author mareshkau, fix for
https://jira.jboss.org/jira/browse/JBIDE-5985
+ */
+ public static boolean isExternalContextPathString(String attributeValue) {
+ Matcher externalContextPathMatcher = jsfExternalContextPath
+ .matcher(attributeValue);
+ boolean result = false;
+ if (externalContextPathMatcher.find()) {
+ result = true;
+ }
+ return result;
+ }
+
+ /**
* Checks is node contained jsf attributes declaration
+ *
* @param sourceNode
- * @return true if node has #{resource[...]} declarations
- * false otherwise
+ * @return true if node has #{resource[...]} declarations false otherwise
+ * @author mareshkau
*/
public static boolean isContainJSF2ResourceAttributes(Node sourceNode) {
boolean result = false;
@@ -59,25 +107,31 @@
}
return result;
}
+
/**
* Replaces custom jsf attribute with attribute from VPE
+ *
* @param pageContext
* @param value
* @return
*/
- public static final String processCustomJSFAttributes(VpePageContext pageContext,
String value){
- String result =null;
- //fix for JBIDE-2550, author Maksim Areshkau
- Matcher singleCoatMatcher = resourcePatternWithSinglCoat.matcher(value);
- Matcher doubleCoatMatcher = resourcePatternWithDoableCoat.matcher(value);
- if(doubleCoatMatcher.find()) {
- result = FileUtil.getJSF2ResourcePath(pageContext, doubleCoatMatcher.group(1));
- }else if(singleCoatMatcher.find()){
- result = FileUtil.getJSF2ResourcePath(pageContext,
singleCoatMatcher.group(1));
- }
+ public static final String processCustomJSFAttributes(
+ VpePageContext pageContext, String value) {
+ String result = null;
+ // fix for JBIDE-2550, author Maksim Areshkau
+ Matcher singleCoatMatcher = resourcePatternWithSinglCoat.matcher(value);
+ Matcher doubleCoatMatcher = resourcePatternWithDoableCoat
+ .matcher(value);
+ if (doubleCoatMatcher.find()) {
+ result = FileUtil.getJSF2ResourcePath(pageContext,
+ doubleCoatMatcher.group(1));
+ } else if (singleCoatMatcher.find()) {
+ result = FileUtil.getJSF2ResourcePath(pageContext,
+ singleCoatMatcher.group(1));
+ }
- return result;
- }
+ return result;
+ }
/**
* Checks if string is jsf 2 resource
@@ -96,4 +150,12 @@
}
return result;
}
+ /**
+ * Replaced
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}" with
""
+ * @param value
+ * @return replaced
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}" with
""
+ */
+ public static String processExternalContextPath(String value) {
+ return
value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}