JBoss Rich Faces SVN: r16483 - branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-02-22 08:17:31 -0500 (Mon, 22 Feb 2010)
New Revision: 16483
Modified:
branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
Fix broken tests on Hudson
Modified: branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
--- branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2010-02-22 07:40:39 UTC (rev 16482)
+++ branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2010-02-22 13:17:31 UTC (rev 16483)
@@ -348,27 +348,26 @@
}
void _testModelDataAppliedToClient(Calendar c) {
- String currentDate = selenium.getText(dateSelectionXpath);
- selenium.click("//table[@id='"+calendarId+"']/tbody/tr/td[text() = '13']");
-
- if (!selenium.getText(dateSelectionXpath).equals(currentDate)) {
- Assert.fail("Enabled attribute of data model was not applied for client data. 13th day should disabled and should force date change after click.");
- }
-
- int currentMonth = c.get(Calendar.MONTH);
-
- String cellDay7StyleClass = selenium.getAttribute("//table[@id='"+calendarId+"']/tbody/tr/td[text() = '7']/@class");
- String cellDay7ModelClass = "styleClass"+currentMonth+"7";
- if (cellDay7StyleClass == null || cellDay7StyleClass.indexOf(cellDay7ModelClass) == -1) {
- Assert.fail("Style class was not applied from data model to cell days. Style class for 7th day should contain [" + cellDay7ModelClass + "]. But has only + [" + cellDay7StyleClass +"]");
- }
-
- String cellDay5StyleClass = selenium.getAttribute("//table[@id='"+calendarId+"']/tbody/tr/td[text() = '5']/@class");
- String cellDay5ModelClass = "styleClass"+currentMonth+"5";
- if (cellDay5StyleClass == null || cellDay5StyleClass.indexOf(cellDay5ModelClass) == -1) {
- Assert.fail("Style class was not applied from data model to cell days. Style class for 5th day should contain [" + cellDay5ModelClass + "]. But has only + [" + cellDay5StyleClass +"]");
- }
- }
+ String currentDate = selenium.getText(dateSelectionXpath);
+ selenium.click("//table[@id='"+calendarId+"']/tbody/tr/td[text() = '13']");
+
+ if (!selenium.getText(dateSelectionXpath).equals(currentDate)) {
+ Assert.fail("Enabled attribute of data model was not applied for client data. 13th day should disabled and should force date change after click.");
+ }
+
+ int currentMonth = c.get(Calendar.MONTH);
+
+ String cellDay8StyleClass = selenium.getAttribute("//table[@id='"+calendarId+"']/tbody/tr/td[text() = '8']/@class");
+ String cellDay8ModelClass = "styleClass"+currentMonth+"8";
+ if (cellDay8StyleClass == null || cellDay8StyleClass.indexOf(cellDay8ModelClass) == -1) {
+ Assert.fail("Style class was not applied from data model to cell days. Style class for 8th day should contain [" + cellDay8ModelClass + "]. But has only + [" + cellDay8StyleClass +"]");
+ }
+ String cellDay5StyleClass = selenium.getAttribute("//table[@id='"+calendarId+"']/tbody/tr/td[text() = '5']/@class");
+ String cellDay5ModelClass = "styleClass"+currentMonth+"5";
+ if (cellDay5StyleClass == null || cellDay5StyleClass.indexOf(cellDay5ModelClass) == -1) {
+ Assert.fail("Style class was not applied from data model to cell days. Style class for 5th day should contain [" + cellDay5ModelClass + "]. But has only + [" + cellDay5StyleClass +"]");
+ }
+ }
void testInternatialization(String prefix) {
String label = selenium.getText(todayControlXpath);
14 years, 10 months
JBoss Rich Faces SVN: r16482 - branches/community/3.3.X/samples/richfaces-demo/functional-test.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-02-22 02:40:39 -0500 (Mon, 22 Feb 2010)
New Revision: 16482
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
Log:
- rf-demo ftest - pom.xml - moved firefoxProfileTemplate to right place - selenium-maven-plugin
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-02-21 23:24:35 UTC (rev 16481)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-02-22 07:40:39 UTC (rev 16482)
@@ -163,7 +163,6 @@
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>-Dbrowser='${browser}' -Dcontext.root='${context.root}' -Dcontext.path='${context.path}' -Dselenium.host='${selenium.host}' -Dselenium.port='${selenium.port}' -Dselenium.debug='${selenium.debug}' -Dselenium.maximize='${selenium.maximize}' -Dmaven.resources.dir='${resources.dir}' -Dmaven.project.build.directory='${project.build.directory}' -Djsf.majorVersion='${jsf.majorVersion}'</argLine>
- <firefoxProfileTemplate>${firefoxProfileTemplate}</firefoxProfileTemplate>
<properties>
<property>
<name>listener</name>
@@ -243,6 +242,7 @@
<background>true</background>
<port>${selenium.port}</port>
<userExtensions>${resources.dir}/custom-extensions.js</userExtensions>
+ <firefoxProfileTemplate>${firefoxProfileTemplate}</firefoxProfileTemplate>
<logOutput>true</logOutput>
<logFile>${project.build.directory}/selenium/selenium-server.log</logFile>
<browserSideLog>${selenium.debug}</browserSideLog>
14 years, 10 months
JBoss Rich Faces SVN: r16481 - in root/ui/trunk/components/core/src/main: templates/org/ajax4jsf/renderkit/html and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-02-21 18:24:35 -0500 (Sun, 21 Feb 2010)
New Revision: 16481
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
Log:
TODOs & fixes for CDK
https://jira.jboss.org/jira/browse/RF-8310
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-02-21 23:23:03 UTC (rev 16480)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-02-21 23:24:35 UTC (rev 16481)
@@ -63,7 +63,7 @@
for (UIComponent child : component.getChildren()) {
String childId = child.getClientId(context);
if (child.isRendered()) {
- renderChild(context, child);
+ child.encodeAll(context);
} else {
// Render "dummy" span.
ResponseWriter out = context.getResponseWriter();
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2010-02-21 23:24:35 UTC (rev 16481)
@@ -14,9 +14,9 @@
<cc:implementation>
<input id="#{clientId}" name="#{clientId}"
- cdk:passThroughWithExclusions="type" onclick="#{this.getOnClick(facesContext,cc)}"
- value="#{cc.attributes['value']}">
- <cdk:call expression="encodeTypeAndImage(facesContext,cc);" />
+ cdk:passThroughWithExclusions="type" onclick="#{this.getOnClick(facesContext, component)}"
+ value="#{component.attributes['value']}">
+ <cdk:call expression="encodeTypeAndImage(facesContext, component);" />
</input>
</cc:implementation>
</cdk:root>
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml 2010-02-21 23:24:35 UTC (rev 16481)
@@ -14,7 +14,7 @@
<cc:implementation>
<span id="#{clientId}" style="display: none;">
<script type="text/javascript">
- #{this.getFunction(facesContext, cc)};
+ #{this.getFunction(facesContext, component)};
</script>
</span>
</cc:implementation>
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2010-02-21 23:24:35 UTC (rev 16481)
@@ -13,13 +13,14 @@
<cc:implementation>
<a id="#{clientId}" name="#{clientId}"
- cdk:passThroughWithExclusions="value" onclick="#{this.getOnClick(facesContext, cc)}"
+ cdk:passThroughWithExclusions="value" onclick="#{this.getOnClick(facesContext, component)}"
href="#">
- #{cc.attributes['value']}
+ #{component.attributes['value']}
<cdk:body>
- <cdk:call expression="renderChildren(facesContext, cc);" />
+ <cdk:call expression="renderChildren(facesContext, component);" />
</cdk:body>
</a>
+ <div></div>
</cc:implementation>
</cdk:root>
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-02-21 23:24:35 UTC (rev 16481)
@@ -27,9 +27,9 @@
LOG.LEVEL = LOG.#{component.attributes["level"]}; </script> </div>
</cdk:otherwise> </cdk:choose
-->
- <div id="richfaces.log" class="rich-log #{cc.attributes['styleClass']}">
+ <div id="richfaces.log" class="rich-log #{component.attributes['styleClass']}">
<script type="text/javascript">
- RichFaces.log.setLevel("#{cc.attributes['level']}");
+ RichFaces.log.setLevel("#{component.attributes['level']}");
</script>
</div>
</cc:implementation>
14 years, 10 months
JBoss Rich Faces SVN: r16480 - in root/cdk/trunk/plugins: attributes/src/test/java/org/richfaces/cdk/attributes and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-02-21 18:23:03 -0500 (Sun, 21 Feb 2010)
New Revision: 16480
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/HelperMethod.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanResultOperationTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-schemas-aggregator.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-boolean-method.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/types/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/coercions.template.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/test/java/org/richfaces/cdk/CoercionsTest.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatement.java
Modified:
root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java
root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/Type.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBinaryOperationTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractMethodTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredOrDynamicExpressionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticIntegerOperationTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticOperationTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanOperationTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/grid.template.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/input.template.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/link.template.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/xml-configured-component/src/main/templates/testPanel.xml
Log:
TODOs & fixes for CDK
https://jira.jboss.org/jira/browse/RF-8310
Modified: root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -144,7 +144,7 @@
*/
@XmlElement(name = "component-attribute-name")
public String getComponentAttributeName() {
- return componentAttributeName;
+ return componentAttributeName != null ? componentAttributeName : name;
}
/**
Modified: root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java
===================================================================
--- root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,7 +21,11 @@
*/
package org.richfaces.cdk.attributes;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.io.StringReader;
import java.io.StringWriter;
@@ -129,6 +133,7 @@
Attribute restoredIdAttribute = restoredSpanAttributes.get("id");
assertNotNull(restoredIdAttribute);
assertEquals("id", restoredIdAttribute.getName());
+ assertEquals("id", restoredIdAttribute.getComponentAttributeName());
assertEquals("id", restoredIdAttribute.getKey());
assertNull(restoredIdAttribute.getDefaultValue());
assertFalse(restoredIdAttribute.isRequired());
@@ -144,16 +149,19 @@
Attribute restoredAltAttribute = restoredImgAttributes.get("alt");
assertNotNull(restoredAltAttribute);
assertEquals("alt", restoredAltAttribute.getName());
+ assertEquals("alt", restoredAltAttribute.getComponentAttributeName());
assertTrue(restoredAltAttribute.isRequired());
Attribute restoredSrcAttribute = restoredImgAttributes.get("src");
assertNotNull(restoredSrcAttribute);
assertEquals("src", restoredSrcAttribute.getName());
+ assertEquals("src", restoredSrcAttribute.getComponentAttributeName());
assertEquals(Kind.URI, restoredSrcAttribute.getKind());
Attribute restoredDirAttribute = restoredImgAttributes.get("dir");
assertNotNull(restoredDirAttribute);
assertEquals("dir", restoredDirAttribute.getName());
+ assertEquals("dir", restoredDirAttribute.getComponentAttributeName());
assertEquals("ltr", restoredDirAttribute.getDefaultValue());
Attribute restoredClassAttribute = restoredImgAttributes.get("class");
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -49,6 +49,7 @@
public static final String COMMA = ",";
public static final String IS_EQUAL_FUNCTION = "isEqual";
public static final String CONVERT_TO_STRING_FUNCTION = "convertToString";
+ public static final String CONVERT_TO_BOOLEAN_FUNCTION = "convertToBoolean";
public static final String DOT = ".";
public static final String DOUBLE_VALUE_OF_FUNCTION = "Double.valueOf";
public static final String EXCLAMATION_MARK = "!";
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -88,6 +88,7 @@
import org.richfaces.cdk.parser.el.node.BinaryArithmeticIntegerOperationTreeNode;
import org.richfaces.cdk.parser.el.node.BinaryArithmeticOperationTreeNode;
import org.richfaces.cdk.parser.el.node.BinaryBooleanOperationTreeNode;
+import org.richfaces.cdk.parser.el.node.BinaryBooleanResultOperationTreeNode;
import org.richfaces.cdk.parser.el.node.ConstantValueTreeNode;
import org.richfaces.cdk.parser.el.node.EqualityTestTreeNode;
import org.richfaces.cdk.parser.el.node.ITreeNode;
@@ -209,13 +210,13 @@
} else if (child instanceof AstEqual) {
treeNode = new EqualityTestTreeNode(child);
} else if (child instanceof AstGreaterThan) {
- treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.GREATER_THEN_OPERATOR);
+ treeNode = new BinaryBooleanResultOperationTreeNode(child, ELNodeConstants.GREATER_THEN_OPERATOR);
} else if (child instanceof AstGreaterThanEqual) {
- treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.GREATER_THEN_OR_EQUALITY_OPERATOR);
+ treeNode = new BinaryBooleanResultOperationTreeNode(child, ELNodeConstants.GREATER_THEN_OR_EQUALITY_OPERATOR);
} else if (child instanceof AstLessThan) {
- treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.LESS_THEN_OPERATOR);
+ treeNode = new BinaryBooleanResultOperationTreeNode(child, ELNodeConstants.LESS_THEN_OPERATOR);
} else if (child instanceof AstLessThanEqual) {
- treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.LESS_THEN_OR_EQUALITY_OPERATOR);
+ treeNode = new BinaryBooleanResultOperationTreeNode(child, ELNodeConstants.LESS_THEN_OR_EQUALITY_OPERATOR);
} else if (child instanceof AstNotEqual) {
treeNode = new EqualityTestTreeNode(child, true);
} else if (child instanceof AstOr) {
@@ -459,4 +460,19 @@
public static void clearCaches() {
classDataCache.clear();
}
+
+ public static String coerceToType(String valueString, ELVisitor visitor, Type expectedType) {
+ if (!expectedType.isAssignableFrom(visitor.getExpressionType())) {
+ for (HelperMethod conversionMethod: HelperMethod.getConversionMethods()) {
+ Type returnType = TypesFactory.getType(conversionMethod.getReturnType());
+ if (expectedType.isAssignableFrom(returnType)) {
+ visitor.getUsedHelperMethods().add(conversionMethod);
+ visitor.setExpressionType(returnType);
+ return conversionMethod.getName() + "(" + valueString + ")";
+ }
+ }
+ }
+
+ return valueString;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,16 +21,19 @@
package org.richfaces.cdk.parser.el;
+import static org.richfaces.cdk.parser.el.HelperMethod.TO_STRING_CONVERSION;
import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
+import java.text.MessageFormat;
+import java.util.EnumSet;
import java.util.Map;
+import java.util.Set;
import org.jboss.el.parser.AstCompositeExpression;
import org.jboss.el.parser.ELParser;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.node.ITreeNode;
import org.richfaces.cdk.parser.el.types.TypesFactory;
-
/**
* Entry point for parsing EL expressions. @see parse() method.
*
@@ -38,43 +41,46 @@
*/
public final class ELVisitor {
- boolean useConversionToString;
- boolean useEmptinessCheck;
- boolean useEqualsCheck;
-
private String parsedExpression = null;
- private Type variableType = null;
- public boolean isUseConversionToString() {
- return useConversionToString;
- }
+ private Type expressionType = null;
- public void setUseConversionToString(boolean needConversion) {
- this.useConversionToString = needConversion;
- }
+ private Map<String, Type> variables = null;
+
+ private Set<HelperMethod> usedHelperMethods = EnumSet.noneOf(HelperMethod.class);
- public boolean isUseEmptinessCheck() {
- return useEmptinessCheck;
+ private Set<HelperMethod> usedConversionMethods = EnumSet.noneOf(HelperMethod.class);
+
+ public Type getExpressionType() {
+ return expressionType;
}
- public void setUseEmptinessCheck(boolean useCheckForEmpty) {
- this.useEmptinessCheck = useCheckForEmpty;
+ public void setExpressionType(Type variableType) {
+ this.expressionType = variableType;
}
- public boolean isUseEqualsCheck() {
- return useEqualsCheck;
+ /**
+ * @return the variables
+ */
+ public Map<String, Type> getVariables() {
+ return variables;
}
- public void setUseEqualsCheck(boolean useEqualsCheck) {
- this.useEqualsCheck = useEqualsCheck;
- }
+ public Type getVariable(String name) throws ParsingException {
+ Type variableType = variables.get(name);
+ if (variableType == null) {
+ throw new ParsingException(MessageFormat.format(
+ "No type found in context for identifier ''{0}'', handling as generic Object", name));
+ }
- public Type getVariableType() {
return variableType;
}
-
- public void setVariableType(Type variableType) {
- this.variableType = variableType;
+
+ /**
+ * @return the uses
+ */
+ public Set<HelperMethod> getUsedHelperMethods() {
+ return usedHelperMethods;
}
/**
@@ -92,25 +98,28 @@
* @return generated Java code.
* @throws ParsingException - if error occurred during parsing.
*/
- public void parse(String expression, Map<String, Type> contextMap) throws ParsingException {
+ public void parse(String expression, Map<String, Type> contextMap, Type expectedType) throws ParsingException {
reset();
Node ret = ELParser.parse(expression);
+ variables = contextMap;
if (ret instanceof AstCompositeExpression && ret.jjtGetNumChildren() >= 2) {
//AstCompositeExpression with 2+ children is a mixed expression
- this.setUseConversionToString(true);
+ getUsedHelperMethods().add(TO_STRING_CONVERSION);
}
if (ret != null && ret.jjtGetNumChildren() > 0) {
- parsedExpression = this.visit(ret, contextMap);
+ parsedExpression = this.visit(ret);
} else {
parsedExpression = getEscapedString("");
- variableType = TypesFactory.getType(String.class);
+ expressionType = TypesFactory.getType(String.class);
}
+
+ parsedExpression = ELParserUtils.coerceToType(parsedExpression, this, expectedType);
}
- private String visit(Node node, Map<String, Type> context) throws ParsingException {
+ private String visit(Node node) throws ParsingException {
int numChildren = node.jjtGetNumChildren();
StringBuilder sb = new StringBuilder();
@@ -119,7 +128,7 @@
ITreeNode treeNode = ELParserUtils.determineNodeType(child);
- treeNode.visit(sb, context, this);
+ treeNode.visit(sb, this);
if (i != numChildren - 1) {
sb.append(" + ");
@@ -131,9 +140,9 @@
private void reset() {
parsedExpression = null;
- useConversionToString = false;
- useEmptinessCheck = false;
- useEqualsCheck = false;
- variableType = null;
+ usedHelperMethods.clear();
+ variables = null;
+ expressionType = null;
}
+
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/HelperMethod.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/HelperMethod.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/HelperMethod.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.parser.el;
+
+import static org.richfaces.cdk.parser.el.ELNodeConstants.CONVERT_TO_BOOLEAN_FUNCTION;
+import static org.richfaces.cdk.parser.el.ELNodeConstants.CONVERT_TO_STRING_FUNCTION;
+import static org.richfaces.cdk.parser.el.ELNodeConstants.IS_EMPTY_FUNCTION;
+import static org.richfaces.cdk.parser.el.ELNodeConstants.IS_EQUAL_FUNCTION;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public enum HelperMethod {
+
+ TO_STRING_CONVERSION(CONVERT_TO_STRING_FUNCTION, String.class, Object.class),
+ TO_BOOLEAN_CONVERSION(CONVERT_TO_BOOLEAN_FUNCTION, Boolean.TYPE, Object.class),
+ EMPTINESS_CHECK(IS_EMPTY_FUNCTION, Boolean.TYPE, Object.class),
+ EQUALS_CHECK(IS_EQUAL_FUNCTION, Boolean.TYPE, Object.class, Object.class);
+
+ private static final Set<HelperMethod> CONVERSION_METHODS = EnumSet.of(TO_STRING_CONVERSION, TO_BOOLEAN_CONVERSION);
+
+ private String name;
+
+ private Class<?> returnType;
+
+ private Class<?>[] argumentTypes;
+
+ private HelperMethod(String name, Class<?> returnType, Class<?>... argumentTypes) {
+ this.name = name;
+ this.returnType = returnType;
+ this.argumentTypes = argumentTypes;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<?> getReturnType() {
+ return returnType;
+ }
+
+ public Class<?>[] getArgumentTypes() {
+ return argumentTypes;
+ }
+
+ public static Set<HelperMethod> getConversionMethods() {
+ return CONVERSION_METHODS;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/Type.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/Type.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/Type.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -27,6 +27,7 @@
* @author Nick Belaevski
*
*/
+//TODO unit-test thoroughly all implementations of this interface
public interface Type {
public String getCode();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBinaryOperationTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBinaryOperationTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBinaryOperationTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,8 +21,6 @@
*/
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
-
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
@@ -30,9 +28,13 @@
import org.richfaces.cdk.parser.el.Type;
/**
- * <p>Abstract class for all binary (having two operands) operation expression nodes</p>
- * <p>For operands <code>A</code> and <code>B</code> and operator <code>x</code> output is <code>(A x B)</code></p>
- *
+ * <p>
+ * Abstract class for all binary (having two operands) operation expression nodes
+ * </p>
+ * <p>
+ * For operands <code>A</code> and <code>B</code> and operator <code>x</code> output is <code>(A x B)</code>
+ * </p>
+ *
* @author Nick Belaevski
*/
public abstract class AbstractBinaryOperationTreeNode extends AbstractTreeNode {
@@ -47,16 +49,21 @@
protected abstract Type getOperationType(Type firstArgumentType, Type secondArgumentType);
- /* (non-Javadoc)
- * @see org.richfaces.cdk.parser.el.node.AbstractTreeNode#visit(java.lang.StringBuilder, java.util.Map, org.richfaces.cdk.parser.el.ELVisitor)
- */
+ protected abstract String getCoercedChildOutput(int childIndex, ELVisitor visitor)
+ throws ParsingException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.parser.el.node.AbstractTreeNode#visit(java.lang.StringBuilder, java.util.Map,
+ * org.richfaces.cdk.parser.el.ELVisitor)
+ */
@Override
- public void visit(StringBuilder sb, Map<String, Type> context,
- ELVisitor visitor) throws ParsingException {
- String firstChildOutput = getChildOutput(0, context, visitor);
- Type firstChildType = visitor.getVariableType();
- String secondChildOutput = getChildOutput(1, context, visitor);
- Type secondChildType = visitor.getVariableType();
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
+ String firstChildOutput = getCoercedChildOutput(0, visitor);
+ Type firstChildType = visitor.getExpressionType();
+ String secondChildOutput = getCoercedChildOutput(1, visitor);
+ Type secondChildType = visitor.getExpressionType();
sb.append(ELNodeConstants.LEFT_BRACKET);
@@ -66,6 +73,6 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setVariableType(getOperationType(firstChildType, secondChildType));
+ visitor.setExpressionType(getOperationType(firstChildType, secondChildType));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractMethodTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractMethodTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractMethodTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
@@ -48,10 +47,10 @@
super(node);
}
- protected void visitMethod(StringBuilder sb, Map<String, Type> context, ELVisitor visitor, String methodName)
+ protected void visitMethod(StringBuilder sb, ELVisitor visitor, String methodName)
throws ParsingException {
- Class<?> methodHolderClass = visitor.getVariableType().getRawType();
+ Class<?> methodHolderClass = visitor.getExpressionType().getRawType();
List<Type> argumentTypes = new ArrayList<Type>();
sb.append(ELNodeConstants.DOT);
@@ -64,11 +63,11 @@
if (k != 0) {
sb.append(ELNodeConstants.COMMA);
}
- String childOutput = getChildOutput(k, context, visitor);
+ String childOutput = getChildOutput(k, visitor);
sb.append(childOutput);
// TODO: handle generic matches -?
- argumentTypes.add(visitor.getVariableType());
+ argumentTypes.add(visitor.getExpressionType());
}
sb.append(ELNodeConstants.RIGHT_BRACKET);
@@ -83,6 +82,6 @@
returnType = TypesFactory.getType(Object.class);
}
- visitor.setVariableType(returnType);
+ visitor.setExpressionType(returnType);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,14 +21,12 @@
package org.richfaces.cdk.parser.el.node;
-import java.text.MessageFormat;
-import java.util.Map;
-
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELParserUtils;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
import org.richfaces.cdk.parser.el.Type;
+import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
* This abstract class implement some methods of ITreeNode interface to using in subclasses.
@@ -53,26 +51,20 @@
* @return
* @throws ParsingException
*/
- protected String getChildOutput(int childIndex, Map<String, Type> context, ELVisitor visitor)
+ protected String getChildOutput(int childIndex, ELVisitor visitor)
throws ParsingException {
StringBuilder sb = new StringBuilder();
- getChild(childIndex).visit(sb, context, visitor);
+ getChild(childIndex).visit(sb, visitor);
return sb.toString();
}
- protected Type getIdentifierFromContext(Map<String, Type> context, String identifierName) throws ParsingException {
- Type identifierType = context.get(identifierName);
-
- if (identifierType == null) {
- throw new ParsingException(MessageFormat.format(
- "No type found in context for identifier ''{0}'', handling as generic Object", identifierName));
- }
-
- return identifierType;
+ protected String coerceToBoolean(String value, ELVisitor visitor) {
+ Type booleanType = TypesFactory.getType(Boolean.TYPE);
+ return ELParserUtils.coerceToType(value, visitor, booleanType);
}
-
+
/**
* Return node of current wrapper.
*
@@ -120,14 +112,14 @@
/**
* Return child of wrapped node by specified index. Abstract operation to override in subclasses.
- *
* @param index
* - index of child.
+ *
* @throws ParsingException
* - if error occurred(child not found).
* @return wrapper for child
*
*/
- public abstract void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException;
+ public abstract void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,7 +21,6 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
@@ -41,9 +40,9 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
- Type variableType = visitor.getVariableType();
- String suffixValue = getChildOutput(0, context, visitor);
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
+ Type variableType = visitor.getExpressionType();
+ String suffixValue = getChildOutput(0, visitor);
if (variableType.isArray()) {
sb.append(ELNodeConstants.LEFT_SQUARE_BRACKET);
@@ -61,6 +60,6 @@
if (containerType == null) {
containerType = TypesFactory.getType(Object.class);
}
- visitor.setVariableType(containerType);
+ visitor.setExpressionType(containerType);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,7 +23,6 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
@@ -43,13 +42,13 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
//condition ? correctConditionBranch : incorrectConditionBranch
- String condition = getChildOutput(0, context, visitor);
- String correctConditionBranch = getChildOutput(1, context, visitor);
- Type correctConditionBranchType = visitor.getVariableType();
- String incorrectConditionBranch = getChildOutput(2, context, visitor);
- Type incorrectConditionBranchType = visitor.getVariableType();
+ String condition = coerceToBoolean(getChildOutput(0, visitor), visitor);
+ String correctConditionBranch = getChildOutput(1, visitor);
+ Type correctConditionBranchType = visitor.getExpressionType();
+ String incorrectConditionBranch = getChildOutput(2, visitor);
+ Type incorrectConditionBranchType = visitor.getExpressionType();
sb.append(ELNodeConstants.LEFT_BRACKET);
@@ -62,9 +61,9 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
if (!correctConditionBranchType.isNullType()) {
- visitor.setVariableType(correctConditionBranchType);
+ visitor.setExpressionType(correctConditionBranchType);
} else {
- visitor.setVariableType(incorrectConditionBranchType);
+ visitor.setExpressionType(incorrectConditionBranchType);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredOrDynamicExpressionTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredOrDynamicExpressionTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredOrDynamicExpressionTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,13 +21,13 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
+import static org.richfaces.cdk.parser.el.HelperMethod.TO_STRING_CONVERSION;
+
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
@@ -42,22 +42,22 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
int childrenCount = getChildrenCount();
for (int i = 0; i < childrenCount; i++) {
- if (visitor.isUseConversionToString()) {
+ if (visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION)) {
sb.append(ELNodeConstants.CONVERT_TO_STRING_FUNCTION);
sb.append(ELNodeConstants.LEFT_BRACKET);
}
ITreeNode treeNode = getChild(i);
- treeNode.visit(sb, context, visitor);
+ treeNode.visit(sb, visitor);
- if (visitor.isUseConversionToString()) {
+ if (visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION)) {
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setVariableType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.getType(String.class));
} /* otherwise variableType will be set in child's visit invocation */
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,13 +23,12 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
+import static org.richfaces.cdk.parser.el.HelperMethod.EMPTINESS_CHECK;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
@@ -44,17 +43,17 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
- visitor.setUseEmptinessCheck(true);
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
+ visitor.getUsedHelperMethods().add(EMPTINESS_CHECK);
sb.append(ELNodeConstants.IS_EMPTY_FUNCTION);
sb.append(ELNodeConstants.LEFT_BRACKET);
- String childOutput = getChildOutput(0, context, visitor);
+ String childOutput = getChildOutput(0, visitor);
sb.append(childOutput);
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setVariableType(TypesFactory.getType(Boolean.TYPE));
+ visitor.setExpressionType(TypesFactory.getType(Boolean.TYPE));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,13 +23,11 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
@@ -44,12 +42,12 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(ELNodeConstants.DOUBLE_VALUE_OF_FUNCTION);
sb.append(ELNodeConstants.LEFT_BRACKET);
sb.append(getNode().getImage());
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setVariableType(TypesFactory.getType(Double.TYPE));
+ visitor.setExpressionType(TypesFactory.getType(Double.TYPE));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,7 +21,6 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.AstFunction;
import org.jboss.el.parser.Node;
@@ -44,7 +43,7 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
AstFunction functionNode = (AstFunction) getNode();
String functionPrefix = functionNode.getPrefix();
String functionName = functionNode.getLocalName();
@@ -59,9 +58,9 @@
sb.append(identifierName);
- Type identifierType = getIdentifierFromContext(context, identifierName);
- visitor.setVariableType(identifierType);
+ Type identifierType = visitor.getVariable(identifierName);
+ visitor.setExpressionType(identifierType);
- visitMethod(sb, context, visitor, functionName);
+ visitMethod(sb, visitor, functionName);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,7 +21,6 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
@@ -40,13 +39,13 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String identifierName = getNode().getImage();
- Type identifierType = getIdentifierFromContext(context, identifierName);
+ Type identifierType = visitor.getVariable(identifierName);
//TODO: implement variable mapper like "utils" -> "this.getUtils()"
- visitor.setVariableType(identifierType);
+ visitor.setExpressionType(identifierType);
sb.append(identifierName);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,12 +23,10 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
@@ -43,8 +41,8 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(getNode().getImage());
- visitor.setVariableType(TypesFactory.getType(Integer.TYPE));
+ visitor.setExpressionType(TypesFactory.getType(Integer.TYPE));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,13 +23,11 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
-import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
@@ -44,11 +42,11 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
if (getNode().getImage() != null) {
sb.append(getEscapedString(getNode().getImage()));
- visitor.setVariableType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.getType(String.class));
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,12 +21,10 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
/**
* This class extend AbstractTreeNode and wrap AstMethodSuffix node.
@@ -40,9 +38,9 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String methodName = getNode().getImage();
- visitMethod(sb, context, visitor, methodName);
+ visitMethod(sb, visitor, methodName);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,13 +23,11 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
/**
* This class extend AbstractTreeNode and wrap AstNegative node.
@@ -43,10 +41,10 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(ELNodeConstants.NEGATIVE);
- String childOutput = getChildOutput(0, context, visitor);
+ String childOutput = getChildOutput(0, visitor);
sb.append(childOutput);
//variable type has been already set by getChildOuput()
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,13 +23,11 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
/**
* This class extend AbstractTreeNode and wrap AstNot node.
@@ -43,10 +41,10 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(ELNodeConstants.LEFT_BRACKET);
sb.append(ELNodeConstants.EXCLAMATION_MARK);
- String childOutput = getChildOutput(0, context, visitor);
+ String childOutput = coerceToBoolean(getChildOutput(0, visitor), visitor);
sb.append(childOutput);
sb.append(ELNodeConstants.RIGHT_BRACKET);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,7 +23,6 @@
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
@@ -70,10 +69,10 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String propertyName = getNode().getImage();
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
Class<?> clazz = variableType.getRawType();
String readMethodName;
@@ -88,7 +87,7 @@
readMethodReturnType = TypesFactory.getType(Object.class);
}
- visitor.setVariableType(readMethodReturnType);
+ visitor.setExpressionType(readMethodReturnType);
sb.append(ELNodeConstants.DOT);
sb.append(readMethodName);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,14 +23,12 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.AstString;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
-import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
/**
@@ -45,9 +43,9 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(getEscapedString(((AstString) getNode()).getString()));
- visitor.setVariableType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.getType(String.class));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,12 +21,10 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
/**
* This class extend AbstractTreeNode and wrap AstValue node.
@@ -39,10 +37,10 @@
}
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
int childrenCount = getChildrenCount();
for (int i = 0; i < childrenCount; i++) {
- String childOutput = getChildOutput(i, context, visitor);
+ String childOutput = getChildOutput(i, visitor);
sb.append(childOutput);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticIntegerOperationTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticIntegerOperationTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticIntegerOperationTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -23,6 +23,8 @@
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
@@ -49,4 +51,15 @@
return TypesFactory.getType(Integer.TYPE);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.parser.el.node.AbstractBinaryOperationTreeNode#getCoercedChildOutput(int, java.util.Map, org.richfaces.cdk.parser.el.ELVisitor)
+ */
+ @Override
+ protected String getCoercedChildOutput(int childIndex, ELVisitor visitor)
+ throws ParsingException {
+
+ //TODO implement coercion to number
+ return getChildOutput(childIndex, visitor);
+ }
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticOperationTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticOperationTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryArithmeticOperationTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -22,6 +22,8 @@
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
@@ -57,4 +59,15 @@
return TypesFactory.getType(Integer.TYPE);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.parser.el.node.AbstractBinaryOperationTreeNode#getCoercedChildOutput(int, java.util.Map, org.richfaces.cdk.parser.el.ELVisitor)
+ */
+ @Override
+ protected String getCoercedChildOutput(int childIndex, ELVisitor visitor)
+ throws ParsingException {
+
+ //TODO implement coercion to number
+ return getChildOutput(childIndex, visitor);
+ }
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanOperationTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanOperationTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanOperationTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -22,6 +22,8 @@
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
@@ -48,4 +50,10 @@
return TypesFactory.getType(Boolean.TYPE);
}
+ @Override
+ protected String getCoercedChildOutput(int childIndex, ELVisitor visitor)
+ throws ParsingException {
+
+ return coerceToBoolean(getChildOutput(childIndex, visitor), visitor);
+ }
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanResultOperationTreeNode.java (from rev 16477, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanOperationTreeNode.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanResultOperationTreeNode.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/BinaryBooleanResultOperationTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+import org.richfaces.cdk.parser.el.Type;
+import org.richfaces.cdk.parser.el.types.TypesFactory;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class BinaryBooleanResultOperationTreeNode extends AbstractBinaryOperationTreeNode {
+
+ /**
+ * @param node
+ * @param operatorString
+ */
+ public BinaryBooleanResultOperationTreeNode(Node node, String operatorString) {
+ super(node, operatorString);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.parser.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type, java.lang.reflect.Type)
+ */
+ @Override
+ protected Type getOperationType(Type firstArgumentType,
+ Type secondArgumentType) {
+ return TypesFactory.getType(Boolean.TYPE);
+ }
+
+ @Override
+ protected String getCoercedChildOutput(int childIndex, ELVisitor visitor)
+ throws ParsingException {
+
+ return getChildOutput(childIndex, visitor);
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ConstantValueTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,7 +21,6 @@
*/
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.richfaces.cdk.parser.el.ELNodeConstants;
import org.richfaces.cdk.parser.el.ELVisitor;
@@ -63,9 +62,9 @@
* org.richfaces.cdk.parser.el.ELVisitor)
*/
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(value);
- visitor.setVariableType(type);
+ visitor.setExpressionType(type);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,7 +21,7 @@
*/
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
+import static org.richfaces.cdk.parser.el.HelperMethod.EQUALS_CHECK;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELNodeConstants;
@@ -75,11 +75,11 @@
* @see org.richfaces.cdk.parser.el.node.AbstractTreeNode#visit(java.lang.StringBuilder, java.util.Map, org.richfaces.cdk.parser.el.ELVisitor)
*/
@Override
- public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
- String firstChildOutput = getChildOutput(0, context, visitor);
- Type firstChildType = visitor.getVariableType();
- String secondChildOutput = getChildOutput(1, context, visitor);
- Type secondChildType = visitor.getVariableType();
+ public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
+ String firstChildOutput = getChildOutput(0, visitor);
+ Type firstChildType = visitor.getExpressionType();
+ String secondChildOutput = getChildOutput(1, visitor);
+ Type secondChildType = visitor.getExpressionType();
if (useIsEqualsMethod(firstChildType, secondChildType)) {
@@ -97,7 +97,7 @@
sb.append(secondChildOutput);
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setUseEqualsCheck(true);
+ visitor.getUsedHelperMethods().add(EQUALS_CHECK);
} else {
sb.append(ELNodeConstants.LEFT_BRACKET);
@@ -114,7 +114,7 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
}
- visitor.setVariableType(TypesFactory.getType(Boolean.TYPE));
+ visitor.setExpressionType(TypesFactory.getType(Boolean.TYPE));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -21,12 +21,10 @@
package org.richfaces.cdk.parser.el.node;
-import java.util.Map;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
/**
* Interface for all wrappers of org.jboss.el.parser.Node class.
@@ -44,14 +42,13 @@
/**
* Visit current node. Generate Java code, that represent current node.
- *
- * @param stringBuilder instance to collect information.
- * @param context - context to resolve beans
* @param visitor - ELVisitor
+ * @param stringBuilder instance to collect information.
+ *
* @return instance of org.jboss.el.parser.Node
* @throws ParsingException - if error occurred during parsing process.
*/
- void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException;
+ void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException;
/**
* Return child of wrapped node by specified index
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-import org.richfaces.builder.model.MethodBodyStatement;
-
-/**
- * @author Nick Belaevski
- */
-public class AbstractTemplateMethodBodyStatement implements MethodBodyStatement {
-
- private String templateName;
-
- protected AbstractTemplateMethodBodyStatement(String templateName) {
- super();
- this.templateName = templateName;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return renderer.renderSnippet(templateName, this);
- }
-
-}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java (from rev 16471, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatement.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.builder.model.MethodBodyStatement;
+
+/**
+ * @author Nick Belaevski
+ */
+public class BaseTemplateMethodBodyStatement implements MethodBodyStatement {
+
+ private String templateName;
+
+ protected BaseTemplateMethodBodyStatement(String templateName) {
+ super();
+ this.templateName = templateName;
+ }
+
+ @Override
+ public String getCode(FreeMarkerRenderer renderer) {
+ return renderer.renderSnippet(templateName, this);
+ }
+
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler;
+
+/**
+ * @author Nick Belaevski
+ */
+public class ConversionToBooleanMethodBodyStatement extends HelperMethodBodyStatement {
+
+ public ConversionToBooleanMethodBodyStatement() {
+ super("conversion-to-boolean-method", new String[] {"object"});
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -24,9 +24,9 @@
/**
* @author Nick Belaevski
*/
-public class ConversionToStringMethodBodyStatement extends AbstractTemplateMethodBodyStatement {
+public class ConversionToStringMethodBodyStatement extends HelperMethodBodyStatement {
public ConversionToStringMethodBodyStatement() {
- super("conversion-to-string-method");
+ super("conversion-to-string-method", new String[] {"object"});
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -26,7 +26,7 @@
/**
* @author Nick Belaevski
*/
-public class DefineObjectStatement extends AbstractTemplateMethodBodyStatement {
+public class DefineObjectStatement extends BaseTemplateMethodBodyStatement {
private Type type;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -24,9 +24,9 @@
/**
* @author Nick Belaevski
*/
-public class EmptinessCheckingMethodBodyStatement extends AbstractTemplateMethodBodyStatement {
+public class EmptinessCheckingMethodBodyStatement extends HelperMethodBodyStatement {
public EmptinessCheckingMethodBodyStatement() {
- super("emptiness-check-method");
+ super("emptiness-check-method", new String[] {"object"});
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -24,7 +24,7 @@
/**
* @author Nick Belaevski
*/
-public class EncodeMethodPrefaceStatement extends AbstractTemplateMethodBodyStatement {
+public class EncodeMethodPrefaceStatement extends BaseTemplateMethodBodyStatement {
/**
* @param templateName
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -25,9 +25,9 @@
* @author Nick Belaevski
*
*/
-public class EqualsCheckingMethodBodyStatement extends AbstractTemplateMethodBodyStatement {
+public class EqualsCheckingMethodBodyStatement extends HelperMethodBodyStatement {
public EqualsCheckingMethodBodyStatement() {
- super("equals-check-method");
+ super("equals-check-method", new String[] {"o1", "o2"});
}
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class HelperMethodBodyStatement extends BaseTemplateMethodBodyStatement {
+
+ private String[] argumentNames;
+
+ protected HelperMethodBodyStatement(String templateName, String[] argumentNames) {
+ super(templateName);
+
+ this.argumentNames = argumentNames;
+ }
+
+ public String[] getArgumentNames() {
+ return argumentNames;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -30,6 +30,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -50,7 +51,6 @@
import org.richfaces.builder.model.JavaMethod;
import org.richfaces.builder.model.JavaModifier;
import org.richfaces.builder.model.MethodBody;
-import org.richfaces.builder.model.MethodBodyStatement;
import org.richfaces.builder.model.MethodBodyStatementsContainer;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
@@ -62,6 +62,7 @@
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.parser.el.ELParserUtils;
import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.HelperMethod;
import org.richfaces.cdk.parser.el.ParsingException;
import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.parser.el.types.TypesFactory;
@@ -106,7 +107,7 @@
/**
*
*/
- static final String COMPONENT_VARIABLE = "cc";
+ static final String COMPONENT_VARIABLE = "component";
/**
*
*/
@@ -129,87 +130,21 @@
*/
private static final String PASS_THROUGH_ATTRIBUTES_FIELD_NAME = "PASS_THROUGH_ATTRIBUTES";
- private static final Set<String> DEFAULT_NAMESPACES = ImmutableSet.of(Template.XHTML_EL_NAMESPACE,Template.XHTML_NAMESPACE);
+ private static final Set<String> DEFAULT_NAMESPACES = ImmutableSet.of(Template.XHTML_EL_NAMESPACE,
+ Template.XHTML_NAMESPACE);
- private enum ServiceMethods {
- EMPTY_CHECK("isEmpty", boolean.class, new Argument("object", Object.class)) {
+ private static final EnumMap<HelperMethod, HelperMethodBodyStatement> HELPER_METHOD_BODIES =
+ new EnumMap<HelperMethod, HelperMethodBodyStatement>(HelperMethod.class);
- @Override
- public MethodBodyStatement createMethodBodyStatement() {
- return new EmptinessCheckingMethodBodyStatement();
- }
-
- @Override
- public boolean isServiceMethodRequired(ELVisitor visitor) {
- return visitor.isUseEmptinessCheck();
- }
-
- },
-
- TO_STRING_CONVERSION("convertToString", String.class, new Argument("object",
- Object.class)) {
-
- @Override
- public MethodBodyStatement createMethodBodyStatement() {
- return new ConversionToStringMethodBodyStatement();
- }
-
- @Override
- public boolean isServiceMethodRequired(ELVisitor visitor) {
- return visitor.isUseConversionToString();
- }
-
- },
-
- EQUALS_CHECK("isEqual", boolean.class, new Argument("o1", Object.class),
- new Argument("o2", Object.class)) {
-
- @Override
- public MethodBodyStatement createMethodBodyStatement() {
- return new EqualsCheckingMethodBodyStatement();
- }
-
- @Override
- public boolean isServiceMethodRequired(ELVisitor visitor) {
- return visitor.isUseEqualsCheck();
- }
-
- };
-
- private String name;
-
- private Class<?> returnType;
-
- private Argument[] arguments;
-
- private ServiceMethods(String name, Class<?> returnType, Argument... arguments) {
- this.name = name;
- this.returnType = returnType;
- this.arguments = arguments;
- }
-
- abstract MethodBodyStatement createMethodBodyStatement();
-
- abstract boolean isServiceMethodRequired(ELVisitor visitor);
-
- void createMethod(JavaClass generatedClass) {
- JavaMethod serviceMethod = new JavaMethod(name, returnType, arguments);
-
- serviceMethod.addModifier(JavaModifier.PRIVATE);
- serviceMethod.addModifier(JavaModifier.STATIC);
- serviceMethod.addModifier(JavaModifier.FINAL);
-
- MethodBody serviceMethodBody = new MethodBody(serviceMethod);
- serviceMethod.setMethodBody(serviceMethodBody);
- serviceMethodBody.addStatement(createMethodBodyStatement());
-
- generatedClass.addMethod(serviceMethod);
- }
+ static {
+ HELPER_METHOD_BODIES.put(HelperMethod.EMPTINESS_CHECK, new EmptinessCheckingMethodBodyStatement());
+ HELPER_METHOD_BODIES.put(HelperMethod.EQUALS_CHECK, new EqualsCheckingMethodBodyStatement());
+ HELPER_METHOD_BODIES.put(HelperMethod.TO_BOOLEAN_CONVERSION, new ConversionToBooleanMethodBodyStatement());
+ HELPER_METHOD_BODIES.put(HelperMethod.TO_STRING_CONVERSION, new ConversionToStringMethodBodyStatement());
}
-
+
private final Logger log;
-
private MethodBodyStatementsContainer currentStatement;
private Schema attributesSchema = null;
@@ -221,7 +156,7 @@
private Map<String, Type> localsTypesMap;
private ClassLoader classLoader;
- private Set<ServiceMethods> addedServiceMethods = EnumSet.noneOf(ServiceMethods.class);
+ private Set<HelperMethod> addedHelperMethods = EnumSet.noneOf(HelperMethod.class);
private Type lastCompiledExpressionType;
private int passThroughCounter;
@@ -255,24 +190,45 @@
this.createMethodContext();
}
- private void addServiceMethod(ServiceMethods serviceMethod) {
- if (addedServiceMethods.add(serviceMethod)) {
- serviceMethod.createMethod(generatedClass);
+ private void addHelperMethod(HelperMethod helperMethod) {
+ if (addedHelperMethods.add(helperMethod)) {
+ HelperMethodBodyStatement methodBodyStatement = HELPER_METHOD_BODIES.get(helperMethod);
+
+ String[] argumentNames = methodBodyStatement.getArgumentNames();
+ Class<?>[] argumentTypes = helperMethod.getArgumentTypes();
+
+ assert argumentNames.length == argumentTypes.length;
+
+ Argument[] arguments = new Argument[argumentTypes.length];
+ for (int i = 0; i < arguments.length; i++) {
+ arguments[i] = new Argument(argumentNames[i], argumentTypes[i]);
+ }
+
+ JavaMethod helperJavaMethod = new JavaMethod(helperMethod.getName(),
+ helperMethod.getReturnType(), arguments);
+
+ helperJavaMethod.addModifier(JavaModifier.PRIVATE);
+ helperJavaMethod.addModifier(JavaModifier.STATIC);
+ helperJavaMethod.addModifier(JavaModifier.FINAL);
+
+ MethodBody helperJavaMethodBody = new MethodBody(helperJavaMethod);
+ helperJavaMethod.setMethodBody(helperJavaMethodBody);
+ helperJavaMethodBody.addStatement(methodBodyStatement);
+
+ generatedClass.addMethod(helperJavaMethod);
}
}
private String compileEl(String expression, Class<?> type) {
try {
ELVisitor elVisitor = new ELVisitor();
- elVisitor.parse(expression, localsTypesMap);
+ elVisitor.parse(expression, localsTypesMap, TypesFactory.getType(type));
- lastCompiledExpressionType = elVisitor.getVariableType();
+ lastCompiledExpressionType = elVisitor.getExpressionType();
String parsedExpression = elVisitor.getParsedExpression();
- for (ServiceMethods serviceMethod : ServiceMethods.values()) {
- if (serviceMethod.isServiceMethodRequired(elVisitor)) {
- addServiceMethod(serviceMethod);
- }
+ for (HelperMethod helperMethod : elVisitor.getUsedHelperMethods()) {
+ addHelperMethod(helperMethod);
}
return parsedExpression + "/* " + expression.trim() + " */";
@@ -329,15 +285,13 @@
sb.append(")");
- String attributeName;
- if (!Strings.isEmpty(componentAttributeName)) {
+ String attributeName = htmlAttributeName;
+ if (!attributeName.equals(componentAttributeName)) {
attributeName = componentAttributeName;
sb.append(".setComponentAttributeName(");
sb.append(getEscapedString(componentAttributeName));
sb.append(")");
- } else {
- attributeName = htmlAttributeName;
}
Property property = attributes.get(attributeName);
@@ -353,8 +307,7 @@
public String apply(EventName from) {
return from.getName();
}
- }
- );
+ });
sb.append(getEscapedStringsArray(eventNamesStrings));
@@ -365,7 +318,7 @@
return sb.toString();
}
- private JavaField createPassThroughField(Map<String, Attribute> htmlAttributesMap) {
+ private String createPassThroughField(Map<String, Attribute> htmlAttributesMap) {
String fieldName = PASS_THROUGH_ATTRIBUTES_FIELD_NAME;
if (passThroughCounter >= 0) {
fieldName += ("_" + passThroughCounter);
@@ -403,8 +356,9 @@
fieldValue.append("))");
passThroughField.setValue(fieldValue.toString());
+ generatedClass.addField(passThroughField);
- return passThroughField;
+ return fieldName;
}
private void createMethodContext() {
@@ -527,7 +481,7 @@
Map<QName, Object> sortedElementAttributes = new TreeMap<QName, Object>(QNAME_COMPARATOR);
sortedElementAttributes.putAll(elementAttributes);
-
+
for (Map.Entry<QName, Object> attribute : sortedElementAttributes.entrySet()) {
QName attributeName = attribute.getKey();
Object attributeValue = attribute.getValue();
@@ -547,7 +501,7 @@
if (writtenAttributes.add(attributeLocalName)) {
generatedClass.addImport(RENDER_KIT_UTILS_CLASS_NAME);
currentStatement.addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(
- attributeValue.toString(), String.class)));
+ attributeValue.toString(), Object.class)));
}
}
}
@@ -570,10 +524,9 @@
}
if (!actualAttributesMap.isEmpty()) {
- JavaField passThroughField = createPassThroughField(actualAttributesMap);
- generatedClass.addField(passThroughField);
+ String passThroughFieldName = createPassThroughField(actualAttributesMap);
generatedClass.addImport(RENDER_KIT_UTILS_CLASS_NAME);
- currentStatement.addStatement(new WriteAttributesSetStatement(passThroughField.getName()));
+ currentStatement.addStatement(new WriteAttributesSetStatement(passThroughFieldName));
}
}
}
@@ -631,7 +584,7 @@
*/
@Override
public void startElement(CdkIfElement cdkIfElement) {
- String compiledTestExpression = compileEl(cdkIfElement.getTest(), Boolean.class);
+ String compiledTestExpression = compileEl(cdkIfElement.getTest(), Boolean.TYPE);
pushStatement(new IfElseStatement());
pushStatement(new IfStatement(compiledTestExpression));
@@ -679,7 +632,7 @@
*/
@Override
public void startElement(CdkWhenElement cdkWhenElement) {
- String compiledTestExpression = compileEl(cdkWhenElement.getTest(), Boolean.class);
+ String compiledTestExpression = compileEl(cdkWhenElement.getTest(), Boolean.TYPE);
pushStatement(new IfStatement(compiledTestExpression));
}
@@ -745,7 +698,14 @@
}
if (!Strings.isEmpty(value)) {
- value = compileEl(value, Object.class);
+ Class<?> valueType;
+ if (type != null) {
+ valueType = type.getRawType();
+ } else {
+ valueType = Object.class;
+ }
+
+ value = compileEl(value, valueType);
if (type == null) {
type = lastCompiledExpressionType;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -25,7 +25,7 @@
* @author Nick Belaevski
* @since 4.0
*/
-public class StartElementStatement extends AbstractTemplateMethodBodyStatement {
+public class StartElementStatement extends BaseTemplateMethodBodyStatement {
private String elementName;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -24,7 +24,7 @@
/**
* @author Nick Belaevski
*/
-public class WriteAttributeStatement extends AbstractTemplateMethodBodyStatement {
+public class WriteAttributeStatement extends BaseTemplateMethodBodyStatement {
private String attributeName;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -25,7 +25,7 @@
/**
* @author Nick Belaevski
*/
-public class WriteAttributesSetStatement extends AbstractTemplateMethodBodyStatement {
+public class WriteAttributesSetStatement extends BaseTemplateMethodBodyStatement {
private String passThroughFieldName;
@@ -40,4 +40,5 @@
public String getPassThroughFieldName() {
return passThroughFieldName;
}
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -24,7 +24,7 @@
/**
* @author Nick Belaevski
*/
-public class WriteTextStatement extends AbstractTemplateMethodBodyStatement {
+public class WriteTextStatement extends BaseTemplateMethodBodyStatement {
private String textExpression;
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-schemas-aggregator.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-schemas-aggregator.xsd (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-schemas-aggregator.xsd 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+
+ <!--
+ JBoss, Home of Professional Open Source Copyright ${year}, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of individual
+ contributors. This is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version. This software is
+ distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not, write
+ to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:abc"
+ xmlns:xml="http://www.w3.org/XML/1998/namespace">
+
+ <xs:import schemaLocation="cdk-template.xsd" namespace="http://richfaces.org/cdk/core" />
+ <xs:import schemaLocation="cdk-composite.xsd" namespace="http://richfaces.org/cdk/jsf/composite" />
+ <xs:import schemaLocation="cdk-jstl-core.xsd" namespace="http://richfaces.org/cdk/jstl/core" />
+
+</xs:schema>
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-02-21 23:23:03 UTC (rev 16480)
@@ -127,6 +127,8 @@
rendering.
</span>
</p>
+ <p>If "disabled" attribute of the component is true (i.e. boolean true or "true"), then
+ attributes that have associated behavior events are not encoded.</p>
</xs:documentation>
</xs:annotation>
<xs:simpleType>
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-boolean-method.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-boolean-method.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-boolean-method.ftl 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,9 @@
+if (object == null) {
+ return false;
+}
+
+if (object instanceof Boolean) {
+ return Boolean.TRUE.equals(object);
+}
+
+return Boolean.valueOf(object.toString());
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -25,6 +25,10 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.richfaces.cdk.parser.el.HelperMethod.EMPTINESS_CHECK;
+import static org.richfaces.cdk.parser.el.HelperMethod.EQUALS_CHECK;
+import static org.richfaces.cdk.parser.el.HelperMethod.TO_BOOLEAN_CONVERSION;
+import static org.richfaces.cdk.parser.el.HelperMethod.TO_STRING_CONVERSION;
import java.util.HashMap;
import java.util.List;
@@ -56,100 +60,105 @@
public void testNull() throws Exception {
parseExpression("#{null}");
assertEquals("null", visitor.getParsedExpression());
- assertTrue(visitor.getVariableType().isNullType());
+ assertTrue(visitor.getExpressionType().isNullType());
}
@Test
public void testTrue() throws Exception {
parseExpression("#{true}");
assertEquals("true", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testFalse() throws Exception {
parseExpression("#{false}");
assertEquals("false", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testFloat() throws Exception {
parseExpression("#{5.0}");
assertEquals("Double.valueOf(5.0)", visitor.getParsedExpression());
- assertEquals(Double.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{5.012e+34}");
assertEquals("Double.valueOf(5.012e+34)", visitor.getParsedExpression());
- assertEquals(Double.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testNegative() throws Exception {
parseExpression("#{-5}");
assertEquals("-5", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testNegativeFloat() throws Exception {
parseExpression("#{-5.0}");
assertEquals("-Double.valueOf(5.0)", visitor.getParsedExpression());
- assertEquals(Double.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testNotEqual() throws Exception {
parseExpression("#{1 ne 3}");
assertEquals("(1 != 3)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertFalse(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{2 != 3}");
assertEquals("(2 != 3)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertFalse(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action != 2}");
assertEquals("!isEqual(action,2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{2 ne action}");
assertEquals("!isEqual(2,action)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action != clientId}");
assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action ne clientId}");
assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action ne null}");
assertEquals("(action != null)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertFalse(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{2 != null}");
assertEquals("!isEqual(2,null)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
}
@Test
public void testNot() throws Exception {
parseExpression("#{not test}");
assertEquals("(!test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{!otherTest}");
assertEquals("(!otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{!action}");
+ assertEquals("(!convertToBoolean(action))", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
}
@Test
@@ -157,210 +166,235 @@
// TODO: tests involving double values
parseExpression("#{1+2}");
assertEquals("(1 + 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testMinus() throws Exception {
parseExpression("#{1-2}");
assertEquals("(1 - 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testDiv() throws Exception {
parseExpression("#{1/2}");
assertEquals("(1 / 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testMult() throws Exception {
parseExpression("#{1*2}");
assertEquals("(1 * 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testMod() throws Exception {
parseExpression("#{1%2}");
assertEquals("(1 % 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testAnd() throws Exception {
parseExpression("#{test and otherTest}");
assertEquals("(test && otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{otherTest && test}");
assertEquals("(otherTest && test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{action and otherTest}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(convertToBoolean(action) && otherTest)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{test && action}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(test && convertToBoolean(action))", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testOr() throws Exception {
parseExpression("#{test or otherTest}");
assertEquals("(test || otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{otherTest || test}");
assertEquals("(otherTest || test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{action or otherTest}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(convertToBoolean(action) || otherTest)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{test || action}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(test || convertToBoolean(action))", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testEquals() throws Exception {
parseExpression("#{1 eq 2}");
assertEquals("(1 == 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertFalse(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{3 == 2}");
assertEquals("(3 == 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertFalse(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action == 2}");
assertEquals("isEqual(action,2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{2 eq action}");
assertEquals("isEqual(2,action)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action == clientId}");
assertEquals("isEqual(action,clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action eq clientId}");
assertEquals("isEqual(action,clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{action eq null}");
assertEquals("(action == null)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertFalse(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
parseExpression("#{2 == null}");
assertEquals("isEqual(2,null)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
- assertTrue(visitor.isUseEqualsCheck());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
}
@Test
public void testGreatThen() throws Exception {
parseExpression("#{1 gt 2}");
assertEquals("(1 > 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{3 > 2}");
assertEquals("(3 > 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testLessThen() throws Exception {
parseExpression("#{1 lt 2}");
assertEquals("(1 < 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{3 < 2}");
assertEquals("(3 < 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testLessThenEquals() throws Exception {
parseExpression("#{1 le 2}");
assertEquals("(1 <= 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{3 <= 2}");
assertEquals("(3 <= 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testGreatThenEquals() throws Exception {
parseExpression("#{1 ge 2}");
assertEquals("(1 >= 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{3 >= 2}");
assertEquals("(3 >= 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testChoice() throws Exception {
parseExpression("#{test ? 2 : 3}");
assertEquals("(test ? 2 : 3)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
parseExpression("#{test ? null : 'string'}");
assertEquals("(test ? null : \"string\")", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{action ? null : 'string'}");
+ assertEquals("(convertToBoolean(action) ? null : \"string\")", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
}
@Test
public void testInteger() throws Exception {
parseExpression("#{152}");
assertEquals("152", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testString() throws Exception {
parseExpression("#{\"nabc\"}");
assertEquals("\"nabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
parseExpression("#{'nabc'}");
assertEquals("\"nabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
parseExpression("#{'\tabc'}");
assertEquals("\"\\tabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
parseExpression("#{'/nabc'}");
assertEquals("\"/nabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
parseExpression("#{'na\"bc'}");
assertEquals("\"na\\\"bc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
parseExpression("#{'na\\\\bc'}");
assertEquals("\"na\\\\bc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
public void testIdentifier() throws Exception {
parseExpression("#{clientId}");
assertEquals("clientId", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
public void testLiteral() throws Exception {
parseExpression("clientId");
assertEquals("\"clientId\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
public void testMethodReturnMap() throws Exception {
parseExpression("#{action.facets}");
assertEquals("action.getFacets()", visitor.getParsedExpression());
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
assertEquals(Map.class, variableType.getRawType());
assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
@@ -372,15 +406,15 @@
public void testMethodReturnMapElement() throws Exception {
parseExpression("#{action.getFacet('header')}");
assertEquals("action.getFacet(\"header\")", visitor.getParsedExpression());
- assertEquals(UIComponent.class, visitor.getVariableType().getRawType());
+ assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
parseExpression("#{action.facets['header']}");
assertEquals("action.getFacets().get(\"header\")", visitor.getParsedExpression());
- assertEquals(UIComponent.class, visitor.getVariableType().getRawType());
+ assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
parseExpression("#{action.rawMap['something']}");
assertEquals("action.getRawMap().get(\"something\")", visitor.getParsedExpression());
- assertEquals(Object.class, visitor.getVariableType().getRawType());
+ assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
// @Test
@@ -392,7 +426,7 @@
public void testMethodReturnMapElement2() throws Exception {
parseExpression("#{action.facets.toString()}");
assertEquals("action.getFacets().toString()", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
@@ -401,28 +435,28 @@
// resolveExpression("#{action.getFacet('header').rendered}"));
parseExpression("#{action.facets['header'].rendered}");
assertEquals("action.getFacets().get(\"header\").isRendered()", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testMethod() throws Exception {
parseExpression("#{action.readOnly}");
assertEquals("action.isReadOnly()", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testNestedMethod() throws Exception {
parseExpression("#{action.testBean2.string}");
assertEquals("action.getTestBean2().getString()", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
public void testMethodReturnList() throws Exception {
parseExpression("#{action.components}");
assertEquals("action.getComponents()", visitor.getParsedExpression());
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
assertEquals(List.class, variableType.getRawType());
assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
}
@@ -431,28 +465,28 @@
public void testMethodReturnListElement() throws Exception {
parseExpression("#{action.components[0]}");
assertEquals("action.getComponents().get(0)", visitor.getParsedExpression());
- assertEquals(UIComponent.class, visitor.getVariableType().getRawType());
+ assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
}
@Test
public void testMethodReturnListElement2() throws Exception {
parseExpression("#{action.components[0].rendered}");
assertEquals("action.getComponents().get(0).isRendered()", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testMethodReturnArray() throws Exception {
parseExpression("#{action.array}");
assertEquals("action.getArray()", visitor.getParsedExpression());
- assertEquals(UIComponent[].class, visitor.getVariableType().getRawType());
+ assertEquals(UIComponent[].class, visitor.getExpressionType().getRawType());
}
@Test
public void testMethodReturnArrayElement() throws Exception {
parseExpression("#{action.array[0]}");
assertEquals("action.getArray()[0]", visitor.getParsedExpression());
- assertEquals(UIComponent.class, visitor.getVariableType().getRawType());
+ assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
}
@Test
@@ -461,55 +495,55 @@
assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)", visitor
.getParsedExpression());
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
parseExpression("#{action.count(123)}");
assertEquals("action.count(123)", visitor.getParsedExpression());
- assertEquals(Integer.class, visitor.getVariableType().getRawType());
+ assertEquals(Integer.class, visitor.getExpressionType().getRawType());
parseExpression("#{action.count(clientId)}");
assertEquals("action.count(clientId)", visitor.getParsedExpression());
- assertEquals(Object.class, visitor.getVariableType().getRawType());
+ assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
@Test
public void testEmpty() throws Exception {
parseExpression("#{empty action.array}");
assertEquals("isEmpty(action.getArray())", visitor.getParsedExpression());
- assertTrue(visitor.isUseEmptinessCheck());
- assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EMPTINESS_CHECK));
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testFunction() throws Exception {
parseExpression("#{super:getType()}");
assertEquals("super.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
}
@Test
public void testLiteralWithDeferred() throws Exception {
parseExpression("#{1}#{2}");
assertEquals("convertToString(1) + convertToString(2)", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
parseExpression("abs #{getType()}");
assertEquals("\"abs \" + convertToString(this.getType())", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
public void testLiteralWithDeferred2() throws Exception {
parseExpression("#{getType()} abs ");
assertEquals("convertToString(this.getType()) + \" abs \"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
public void testThisFunction() throws Exception {
parseExpression("#{getType()}");
assertEquals("this.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
parseExpression("#{this.getType()}");
assertEquals("this.getType()", visitor.getParsedExpression());
@@ -519,14 +553,14 @@
public void testVariableFunction() throws Exception {
parseExpression("#{objectVar.getType()}");
assertEquals("objectVar.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getVariableType();
+ Type variableType = visitor.getExpressionType();
}
@Test
public void testNonExistingMethod() throws Exception {
parseExpression("#{action.doSomething(clientId, 123)}");
assertEquals("action.doSomething(clientId,123)", visitor.getParsedExpression());
- assertEquals(Object.class, visitor.getVariableType().getRawType());
+ assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
@Test
@@ -544,17 +578,51 @@
public void testWrongExpression2() throws Exception {
parseExpression("#{action.property}");
assertEquals("action.getProperty()", visitor.getParsedExpression());
- assertEquals(Object.class, visitor.getVariableType().getRawType());
+ assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
@Test
public void testEmptyString() throws Exception {
parseExpression("");
assertEquals("\"\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getVariableType().getRawType());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
+ @Test
+ public void testBooleanReturnType() throws Exception {
+ parseExpression("#{clientId}", Boolean.TYPE);
+
+ assertEquals("convertToBoolean(clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+
+ parseExpression("#{test}", Boolean.TYPE);
+
+ assertEquals("test", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ }
+
+ @Test
+ public void testStringReturnType() throws Exception {
+ parseExpression("#{clientId}", String.class);
+
+ assertEquals("clientId", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION));
+
+ parseExpression("#{test}", String.class);
+
+ assertEquals("convertToString(test)", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION));
+ }
+
private void parseExpression(String expression) throws ParsingException {
+ parseExpression(expression, Object.class);
+ }
+
+ private void parseExpression(String expression, Class<?> returnType) throws ParsingException {
Map<String, Type> contextMap = new HashMap<String, Type>();
contextMap.put("action", TypesFactory.getType(org.richfaces.cdk.parser.el.test.Bean.class));
@@ -565,6 +633,6 @@
contextMap.put("super", TypesFactory.getType(Object.class));
contextMap.put("objectVar", TypesFactory.getType(Object.class));
- visitor.parse(expression, contextMap);
+ visitor.parse(expression, contextMap, TypesFactory.getType(returnType));
}
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml 2010-02-21 23:23:03 UTC (rev 16480)
@@ -32,15 +32,15 @@
</cc:interface>
<cc:implementation>
start
- <c:if test="#{cc.attributes['ifTest'] != null}">if content</c:if>
+ <c:if test="#{component.attributes['ifTest'] != null}">if content</c:if>
<c:choose>
- <c:when test="#{cc.attributes['anotherTest'] != null}">when content</c:when>
- <c:when test="#{cc.attributes['coolTest'] != null}">
- <c:if test="#{cc.attributes['nestedIfTest'] != null}">nested if content</c:if>
+ <c:when test="#{component.attributes['anotherTest'] != null}">when content</c:when>
+ <c:when test="#{component.attributes['coolTest'] != null}">
+ <c:if test="#{component.attributes['nestedIfTest'] != null}">nested if content</c:if>
</c:when>
<c:otherwise>otherwise content</c:otherwise>
</c:choose>
- <c:forEach items="#{cc.children}" var="iterationVar">
+ <c:forEach items="#{component.children}" var="iterationVar">
forEach content
</c:forEach>
finish
Added: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/coercions.template.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/coercions.template.xml (rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/coercions.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://richfaces.org/cdk/xhtml-el" xmlns:cdk="http://richfaces.org/cdk/core"
+ xmlns:c="http://richfaces.org/cdk/jstl/core" xmlns:cc="http://richfaces.org/cdk/jsf/composite"
+ xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.cdk.renderkit.html.CoercedRenderer</cdk:class>
+ <cdk:component-family>org.richfaces.cdk.CoercedComponent</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.cdk.CoercedRenderer</cdk:renderer-type>
+ </cc:interface>
+
+ <cc:implementation>
+ <c:if test="#{component.attributes['flag']}">
+ Flag
+ </c:if>
+
+ <cdk:object type="boolean" name="anotherFlag" value="#{component.attributes['anotherFlag']}" />
+ <c:if test="#{anotherFlag}">
+ AnotherFlag
+ </c:if>
+
+ <cdk:object name="someObject" type="Object" value="#{component.attributes['someObject']}" />
+ <cdk:object name="string" type="String" value="#{someObject}" />
+ #{string.length()}
+
+ </cc:implementation>
+</cdk:root>
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/grid.template.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/grid.template.xml 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/grid.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
@@ -15,7 +15,7 @@
<table id="#{clientId}">
<tbody>
<cdk:body>
- <c:forEach items="#{cc.children}" var="child">
+ <c:forEach items="#{component.children}" var="child">
<tr>
<td>
<cdk:call>
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/input.template.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/input.template.xml 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/input.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
@@ -14,13 +14,13 @@
<span id="#{clientId}">
<cdk:body />
- <cdk:object name="componentIsDisabled" value="#{cc.attributes['disabled'] == true}" />
+ <cdk:object name="componentIsDisabled" value="#{component.attributes['disabled'] == true}" />
<c:choose>
<c:when test="#{not componentIsDisabled}">
<input type="text" />
- <cdk:object name="image" value="#{cc.attributes['image']}" />
- <cdk:object name="disabledImage" value="#{cc.attributes['disabledImage']}" />
+ <cdk:object name="image" value="#{component.attributes['image']}" />
+ <cdk:object name="disabledImage" value="#{component.attributes['disabledImage']}" />
<c:choose>
<c:when test="#{disabledImage != null}">
<img src="#{disabledImage}" alt="" />
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/link.template.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/link.template.xml 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/main/templates/link.template.xml 2010-02-21 23:23:03 UTC (rev 16480)
@@ -11,12 +11,12 @@
</cc:interface>
<cc:implementation>
- <a id="#{clientId}" href="#{cc.attributes['href']}" cdk:passThroughWithExclusions="target rel rev">
- <cdk:object name="imageSource" value="#{cc.attributes['imageSource']}" />
+ <a id="#{clientId}" href="#{component.attributes['href']}" cdk:passThroughWithExclusions="target rel rev">
+ <cdk:object name="imageSource" value="#{component.attributes['imageSource']}" />
<c:if test="#{not empty imageSource}">
- <img src="#{imageSource}" alt="" class="rich-link #{cc.attributes['linkImageStyleClass']} #{cc.attributes['imageStyleClass']}" />
+ <img src="#{imageSource}" alt="" class="rich-link #{component.attributes['linkImageStyleClass']} #{component.attributes['imageStyleClass']}" />
</c:if>
- value: #{cc.attributes['value']}; differentValue: #{cc.attributes['differentValue']}; anotherValue: #{cc.attributes['anotherValue']};
+ value: #{component.attributes['value']}; differentValue: #{component.attributes['differentValue']}; anotherValue: #{component.attributes['anotherValue']};
</a>
</cc:implementation>
</cdk:root>
Added: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/test/java/org/richfaces/cdk/CoercionsTest.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/test/java/org/richfaces/cdk/CoercionsTest.java (rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/renderer-template-test/src/test/java/org/richfaces/cdk/CoercionsTest.java 2010-02-21 23:23:03 UTC (rev 16480)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk;
+
+import static org.easymock.EasyMock.eq;
+
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.cdk.renderkit.html.CoercedRenderer;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class CoercionsTest extends BaseRendererTest {
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Test
+ public void testEncodeEnd() throws Exception {
+ responseWriter.writeText(eq("0"), EasyMock.<String>isNull());
+
+ replayAll();
+
+ CoercedRenderer renderer = new CoercedRenderer();
+ renderer.encodeEnd(facesContext, component);
+ }
+
+ @Test
+ public void testEncodeEndObjectCoercedToString() throws Exception {
+ componentAttributes.put("someObject", "test value");
+
+ responseWriter.writeText(eq(String.valueOf("test value".length())), EasyMock.<String>isNull());
+
+ replayAll();
+
+ CoercedRenderer renderer = new CoercedRenderer();
+ renderer.encodeEnd(facesContext, component);
+ }
+
+ @Test
+ public void testEncodeEndWithBooleanFlags() throws Exception {
+ componentAttributes.put("flag", Boolean.FALSE);
+ componentAttributes.put("anotherFlag", Boolean.TRUE);
+
+ responseWriter.writeText(eq("AnotherFlag"), EasyMock.<String>isNull());
+ responseWriter.writeText(eq("0"), EasyMock.<String>isNull());
+
+ replayAll();
+
+ CoercedRenderer renderer = new CoercedRenderer();
+ renderer.encodeEnd(facesContext, component);
+ }
+
+ @Test
+ public void testEncodeEndWithStringFlags() throws Exception {
+ componentAttributes.put("flag", "true");
+ componentAttributes.put("anotherFlag", "false");
+
+ responseWriter.writeText(eq("Flag"), EasyMock.<String>isNull());
+ responseWriter.writeText(eq("0"), EasyMock.<String>isNull());
+
+ replayAll();
+
+ CoercedRenderer renderer = new CoercedRenderer();
+ renderer.encodeEnd(facesContext, component);
+ }
+}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/xml-configured-component/src/main/templates/testPanel.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/xml-configured-component/src/main/templates/testPanel.xml 2010-02-21 23:19:48 UTC (rev 16479)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/xml-configured-component/src/main/templates/testPanel.xml 2010-02-21 23:23:03 UTC (rev 16480)
@@ -32,12 +32,12 @@
</cc:interface>
<cc:implementation>
<div>
- <c:if test="#{cc.facets['header'] != null}">
+ <c:if test="#{component.facets['header'] != null}">
<div class="tpHeader">
- <cdk:call expression='cc.getFacet("header").encodeAll(facesContext)'/>
+ <cdk:call expression='component.getFacet("header").encodeAll(facesContext)'/>
</div>
</c:if>
- <c:forEach items="#{cc.children}" var="iterationVar">
+ <c:forEach items="#{component.children}" var="iterationVar">
<cdk:call expression='((javax.faces.component.UIComponent)iterationVar).encodeAll(facesContext)'/>
</c:forEach>
</div>
14 years, 10 months
JBoss Rich Faces SVN: r16479 - in root/framework/trunk: commons/src/test/java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-02-21 18:19:48 -0500 (Sun, 21 Feb 2010)
New Revision: 16479
Modified:
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
Log:
TODOs & fixes for CDK
Removed renderChild() from RendererBase
https://jira.jboss.org/jira/browse/RF-8310
Modified: root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-02-21 23:15:30 UTC (rev 16478)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-02-21 23:19:48 UTC (rev 16479)
@@ -35,6 +35,7 @@
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.component.behavior.ClientBehaviorHint;
import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -47,6 +48,16 @@
/**
*
*/
+ static final String BEHAVIOR_SOURCE_ID = "javax.faces.source";
+
+ /**
+ *
+ */
+ static final String BEHAVIOR_EVENT_NAME = "javax.faces.behavior.event";
+
+ /**
+ *
+ */
private static final String XHTML_ATTRIBUTE_PREFIX = "xml:";
/**
@@ -65,6 +76,8 @@
private static final String[] XHTML_ATTRIBUTE_NAMES = { "lang" };
+ private static final String DISABLED_ATTRIBUTE_NAME = "disabled";
+
private RenderKitUtils() {
// utility constructor
}
@@ -80,10 +93,23 @@
return result;
}
+ static boolean isDisabled(UIComponent component) {
+ Object disabledAttributeValue = component.getAttributes().get(DISABLED_ATTRIBUTE_NAME);
+ if (disabledAttributeValue == null) {
+ return false;
+ }
+
+ if (disabledAttributeValue instanceof Boolean) {
+ return Boolean.TRUE.equals(disabledAttributeValue);
+ }
+
+ return Boolean.valueOf(disabledAttributeValue.toString());
+ }
+
static String escape(String s) {
StringBuilder sb = new StringBuilder(s.length());
int start = 0;
- int end = s.length();
+ int end;
while ((end = s.indexOf('\'', start)) >= 0) {
sb.append(s, start, end);
@@ -274,6 +300,7 @@
public static void renderPassThroughAttributesOptimized(FacesContext context, UIComponent component,
Map<String, ComponentAttribute> knownAttributesMap) throws IOException {
+ boolean disabled = isDisabled(component);
Set<String> handledAttributes = new HashSet<String>(knownAttributesMap.size());
Object attributesThatAreSetObject = component.getAttributes().get(ATTRIBUTES_THAT_ARE_SET);
if (attributesThatAreSetObject instanceof Collection<?>) {
@@ -289,7 +316,10 @@
if (knownAttribute != null) {
handledAttributes.add(knownAttribute.getHtmlAttributeName());
- // TODO check for disabled component
+ if (disabled && knownAttribute.getEventNames() != null) {
+ continue;
+ }
+
renderAttributeAndBehaviors(context, component, knownAttribute);
}
}
@@ -312,8 +342,48 @@
public static void renderPassThroughAttributes(FacesContext context, UIComponent component,
Map<String, ComponentAttribute> knownAttributesMap) throws IOException {
+ boolean disabled = isDisabled(component);
+
for (ComponentAttribute knownAttribute : knownAttributesMap.values()) {
+ if (disabled && knownAttribute.getEventNames() != null) {
+ continue;
+ }
+
renderAttributeAndBehaviors(context, component, knownAttribute);
}
}
+
+ public static void decodeBehaviors(FacesContext context, UIComponent component) {
+ if (!(component instanceof ClientBehaviorHolder)) {
+ return;
+ }
+
+ ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
+ Map<String, List<ClientBehavior>> behaviors = holder.getClientBehaviors();
+
+ if (behaviors == null || behaviors.isEmpty()) {
+ return;
+ }
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, String> parametersMap = externalContext.getRequestParameterMap();
+ String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME);
+
+ if (behaviorEvent == null) {
+ return;
+ }
+
+ List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
+ String behaviorSource = parametersMap.get(BEHAVIOR_SOURCE_ID);
+ String clientId = component.getClientId(context);
+
+ if (behaviorSource != null && behaviorSource.equals(clientId)) {
+ if (behaviorsForEvent != null) {
+ for (ClientBehavior behavior : behaviorsForEvent) {
+ behavior.decode(context, component);
+ }
+ }
+ }
+ }
+
}
Modified: root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
===================================================================
--- root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-02-21 23:15:30 UTC (rev 16478)
+++ root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-02-21 23:19:48 UTC (rev 16479)
@@ -23,23 +23,29 @@
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.same;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.component.behavior.ClientBehaviorHint;
import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -56,21 +62,42 @@
*/
public class RenderKitUtilsTest {
+ /**
+ *
+ */
+ private static final String CLIENT_ID = "submittedId";
+
private MockFacesEnvironment facesEnvironment;
private ResponseWriter responseWriter;
private FacesContext facesContext;
+ private ExternalContext externalContext;
+
+ private Map<String, Object> componentAttributes;
+
+ private Map<String, List<ClientBehavior>> behaviorsMap;
+
+ private Map<String, ComponentAttribute> knownAttributes;
+
+ private List<Object> createdMocks;
+
@Before
public void setUp() throws Exception {
- facesEnvironment = FacesMock.createMockEnvironment();
- facesEnvironment.resetToNice();
+ facesEnvironment = FacesMock.createMockEnvironment().withExternalContext();
+
facesContext = facesEnvironment.getFacesContext();
-
+ externalContext = facesEnvironment.getExternalContext();
+
responseWriter = FacesMock.createMock(ResponseWriter.class);
- expect(facesContext.getResponseWriter()).andReturn(responseWriter).anyTimes();
- expect(responseWriter.getContentType()).andReturn("application/xhtml+xml").anyTimes();
+ expect(facesContext.getResponseWriter()).andStubReturn(responseWriter);
+ expect(responseWriter.getContentType()).andStubReturn("application/xhtml+xml");
+
+ componentAttributes = new HashMap<String, Object>();
+ behaviorsMap = new HashMap<String, List<ClientBehavior>>();
+ knownAttributes = new TreeMap<String, ComponentAttribute>();
+ createdMocks = new ArrayList<Object>();
}
@After
@@ -78,8 +105,53 @@
this.facesEnvironment = null;
this.responseWriter = null;
this.facesContext = null;
+ this.externalContext = null;
+ this.componentAttributes = null;
+ this.behaviorsMap = null;
+ this.knownAttributes = null;
+ this.createdMocks = null;
}
+ private void replay(Object... objects) {
+ FacesMock.replay(facesEnvironment, responseWriter);
+ for (Object object : createdMocks) {
+ FacesMock.replay(object);
+ }
+ for (Object object : objects) {
+ FacesMock.replay(object);
+ }
+ }
+
+ private void verify(Object... objects) {
+ FacesMock.verify(facesEnvironment, responseWriter);
+ for (Object object : createdMocks) {
+ FacesMock.verify(object);
+ }
+ for (Object object : objects) {
+ FacesMock.verify(object);
+ }
+ }
+
+ private UIComponent createMockComponent() {
+ UIComponent component = FacesMock.createMock(UIComponent.class);
+ expect(component.getAttributes()).andStubReturn(componentAttributes);
+ expect(component.getClientId(same(facesContext))).andStubReturn(CLIENT_ID);
+ createdMocks.add(component);
+ return component;
+ }
+
+ private ClientBehaviorHolder createMockClientBehaviorHolder() {
+ UIComponent component = FacesMock.createMock(MockClientBehaviorHolder.class);
+ expect(component.getClientId(same(facesContext))).andStubReturn(CLIENT_ID);
+ expect(component.getAttributes()).andStubReturn(componentAttributes);
+ ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) component;
+ expect(behaviorHolder.getClientBehaviors()).andStubReturn(behaviorsMap);
+ expect(behaviorHolder.getEventNames()).andStubReturn(
+ Arrays.asList("click", "action", "mousemove", "keypress", "blur", "contextmenu"));
+ createdMocks.add(behaviorHolder);
+ return behaviorHolder;
+ }
+
@Test
public void testEscape() throws Exception {
assertEquals("", RenderKitUtils.escape(""));
@@ -156,7 +228,6 @@
@Test
public void testRenderPassThroughAttributes() throws Exception {
- Map<String, ComponentAttribute> knownAttributes = new HashMap<String, ComponentAttribute>();
knownAttributes.put("disabled", new ComponentAttribute("disabled"));
knownAttributes.put("checked", new ComponentAttribute("checked"));
knownAttributes.put("style", new ComponentAttribute("style"));
@@ -164,7 +235,6 @@
knownAttributes.put("lang", new ComponentAttribute("lang"));
knownAttributes.put("class", new ComponentAttribute("class").setComponentAttributeName("styleClass"));
- Map<String, Object> componentAttributes = new HashMap<String, Object>();
componentAttributes.put("disabled", Boolean.TRUE);
componentAttributes.put("checked", Boolean.FALSE);
componentAttributes.put("style", "color:red");
@@ -173,8 +243,7 @@
componentAttributes.put("lang", "ru");
componentAttributes.put("styleClass", "rich-component");
- UIComponent component = FacesMock.createMock(UIComponent.class);
- expect(component.getAttributes()).andReturn(componentAttributes).anyTimes();
+ UIComponent component = createMockComponent();
responseWriter.writeAttribute(eq("disabled"), eq(Boolean.TRUE), EasyMock.<String>isNull());
// checked attribute shouldn't be rendered - it's 'false'
@@ -184,25 +253,25 @@
responseWriter.writeAttribute(eq("xml:lang"), eq("ru"), EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("class"), eq("rich-component"), EasyMock.<String>isNull());
- FacesMock.replay(facesEnvironment, component, responseWriter);
+ replay();
RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- FacesMock.verify(facesEnvironment, component, responseWriter);
+ verify();
}
private ClientBehavior createClientBehavior(String handlerData, Set<ClientBehaviorHint> hints) {
ClientBehavior behavior = FacesMock.createMock(ClientBehavior.class);
- expect(behavior.getScript(EasyMock.<ClientBehaviorContext> notNull())).andReturn(
- MessageFormat.format("prompt({0})", handlerData)).anyTimes();
+ expect(behavior.getScript(EasyMock.<ClientBehaviorContext> notNull())).andStubReturn(
+ MessageFormat.format("prompt({0})", handlerData));
- expect(behavior.getHints()).andReturn(hints).anyTimes();
+ expect(behavior.getHints()).andStubReturn(hints);
+ createdMocks.add(behavior);
return behavior;
}
@Test
public void testBehaviors() throws Exception {
- Map<String, ComponentAttribute> knownAttributes = new HashMap<String, ComponentAttribute>();
knownAttributes.put("onclick", new ComponentAttribute("onclick")
.setEventNames(new String[] { "click", "action" }));
knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
@@ -212,7 +281,6 @@
knownAttributes.put("oncontextmenu", new ComponentAttribute("oncontextmenu")
.setEventNames(new String[] { "contextmenu" }));
- Map<String, Object> componentAttributes = new HashMap<String, Object>();
componentAttributes.put("onkeypress", "alert(keypress)");
componentAttributes.put("onmousemove", "alert(mousemove)");
componentAttributes.put("onclick", "alert(click)");
@@ -220,8 +288,6 @@
Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
Set<ClientBehaviorHint> submittingHintsSet = EnumSet.of(ClientBehaviorHint.SUBMITTING);
- Map<String, List<ClientBehavior>> behaviorsMap = new HashMap<String, List<ClientBehavior>>();
-
ClientBehavior keypressBehavior = createClientBehavior("keypress", emptyHintsSet);
ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
ClientBehavior actionBehavior2 = createClientBehavior("action2", submittingHintsSet);
@@ -232,12 +298,8 @@
behaviorsMap.put("action", Arrays.asList(actionBehavior1, actionBehavior2, actionBehavior3));
behaviorsMap.put("contextmenu", Arrays.asList(contextmenuBehavior));
- UIComponent component = FacesMock.createMock(MockClientBehaviorHolder.class);
- expect(component.getAttributes()).andReturn(componentAttributes).anyTimes();
- ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) component;
- expect(behaviorHolder.getClientBehaviors()).andReturn(behaviorsMap).anyTimes();
- expect(behaviorHolder.getEventNames()).andReturn(
- Arrays.asList("click", "action", "mousemove", "keypress", "blur", "contextmenu")).anyTimes();
+ ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
+ UIComponent component = (UIComponent) behaviorHolder;
responseWriter.writeAttribute(eq("onkeypress"), eq("jsf.util.chain('alert(keypress)','prompt(keypress)')"),
EasyMock.<String>isNull());
@@ -246,12 +308,189 @@
responseWriter.writeAttribute(eq("onmousemove"), eq("alert(mousemove)"), EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("oncontextmenu"), eq("prompt(contextmenu)"), EasyMock.<String>isNull());
- FacesMock.replay(component, facesEnvironment, responseWriter, keypressBehavior, actionBehavior1,
- actionBehavior2, actionBehavior3, contextmenuBehavior);
+ replay();
RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- FacesMock.verify(component, facesEnvironment, responseWriter, keypressBehavior, actionBehavior1,
- actionBehavior2, actionBehavior3, contextmenuBehavior);
+ verify();
}
+
+ private UIComponent setupBehaviorsTestForDisabledComponent() throws IOException {
+ knownAttributes.put("style", new ComponentAttribute("style"));
+ knownAttributes.put("onclick", new ComponentAttribute("onclick")
+ .setEventNames(new String[] { "click", "action" }));
+ knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
+ .setEventNames(new String[] { "mousemove" }));
+
+ componentAttributes.put("onmousemove", "alert(mousemove)");
+ componentAttributes.put("onclick", "alert(click)");
+ componentAttributes.put("style", "color:green");
+
+ Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
+
+ ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
+ behaviorsMap.put("action", Arrays.asList(actionBehavior1));
+
+ ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
+ UIComponent component = (UIComponent) behaviorHolder;
+ return component;
+ }
+
+ @Test
+ public void testBehaviorsForDisabledComponent() throws Exception {
+ componentAttributes.put("disabled", Boolean.TRUE);
+ UIComponent component = setupBehaviorsTestForDisabledComponent();
+
+ responseWriter.writeAttribute(eq("style"), eq("color:green"), EasyMock.<String>isNull());
+
+ replay();
+
+ RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
+
+ verify();
+ }
+
+ @Test
+ public void testBehaviorsForNonDisabledComponent() throws Exception {
+ componentAttributes.put("disabled", Boolean.FALSE);
+ UIComponent component = setupBehaviorsTestForDisabledComponent();
+
+ responseWriter.writeAttribute(eq("onclick"), eq("jsf.util.chain('alert(click)','prompt(action1)')"),
+ EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("onmousemove"),
+ eq("alert(mousemove)"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("style"), eq("color:green"), EasyMock.<String>isNull());
+
+ replay();
+
+ RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
+
+ verify();
+ }
+
+ public void checkDisabled(Object attributeValue, boolean expectedValue) throws Exception {
+ componentAttributes.put("disabled", attributeValue);
+
+ UIComponent component = createMockComponent();
+ replay();
+ assertTrue(expectedValue == RenderKitUtils.isDisabled(component));
+ verify();
+ }
+
+ @Test
+ public void testIsDisabled() throws Exception {
+ checkDisabled(Boolean.TRUE, true);
+ }
+
+ @Test
+ public void testIsDisabledString() throws Exception {
+ checkDisabled("true", true);
+ }
+
+ @Test
+ public void testIsNonDisabled() throws Exception {
+ checkDisabled(Boolean.FALSE, false);
+ }
+
+ @Test
+ public void testIsNonDisabledString() throws Exception {
+ checkDisabled("false", false);
+ }
+
+ @Test
+ public void testIsNonDisabledNull() throws Exception {
+ checkDisabled(null, false);
+ }
+
+ private UIComponent setupTestDecodeBehaviors(String behaviorSourceId, String behaviorEventName) throws Exception {
+ ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
+ UIComponent component = (UIComponent) behaviorHolder;
+
+ Map<String, String> requestParameterMap = new HashMap<String, String>();
+ requestParameterMap.put(RenderKitUtils.BEHAVIOR_SOURCE_ID, behaviorSourceId);
+ requestParameterMap.put(RenderKitUtils.BEHAVIOR_EVENT_NAME, behaviorEventName);
+ expect(externalContext.getRequestParameterMap()).andStubReturn(requestParameterMap);
+
+ ClientBehavior actionBehavior = createClientBehavior("action1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
+ ClientBehavior actionBehavior1 = createClientBehavior("action2", EnumSet.of(ClientBehaviorHint.SUBMITTING));
+ behaviorsMap.put("action", Arrays.asList(actionBehavior, actionBehavior1));
+
+ ClientBehavior blurBehavior = createClientBehavior("blur1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
+ behaviorsMap.put("blur", Arrays.asList(blurBehavior));
+
+ return component;
+ }
+
+ @Test
+ public void testDecodeActionBehaviors() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "action");
+
+ List<ClientBehavior> behaviors = behaviorsMap.get("action");
+ for (ClientBehavior clientBehavior : behaviors) {
+ clientBehavior.decode(same(facesContext), same(component));
+ expectLastCall();
+ }
+
+ replay();
+
+ RenderKitUtils.decodeBehaviors(facesContext, component);
+
+ verify();
+ }
+
+ @Test
+ public void testDecodeBlurBehaviors() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "blur");
+
+ List<ClientBehavior> behaviors = behaviorsMap.get("blur");
+ for (ClientBehavior clientBehavior : behaviors) {
+ clientBehavior.decode(same(facesContext), same(component));
+ expectLastCall();
+ }
+
+ replay();
+
+ RenderKitUtils.decodeBehaviors(facesContext, component);
+
+ verify();
+ }
+
+ @Test
+ public void testDecodeNonMatchingClientId() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors("wrongId", "action");
+
+ //nothing should be called - clientId is not matched
+
+ replay();
+
+ RenderKitUtils.decodeBehaviors(facesContext, component);
+
+ verify();
+ }
+
+ @Test
+ public void testDecodeNoSubmittedBehavior() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, null);
+
+ //nothing should be called - no behavior event information was submitted
+
+ replay();
+
+ RenderKitUtils.decodeBehaviors(facesContext, component);
+
+ verify();
+ }
+
+ @Test
+ public void testDecodeContextMenuBehaviors() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "contextmenu");
+
+ //nothing should be called - no context menu behaviors were created
+
+ replay();
+
+ RenderKitUtils.decodeBehaviors(facesContext, component);
+
+ verify();
+ }
}
\ No newline at end of file
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2010-02-21 23:15:30 UTC (rev 16478)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2010-02-21 23:19:48 UTC (rev 16479)
@@ -167,7 +167,7 @@
}
} else {
renderedAreas.add(component.getClientId(context));
- renderChild(context, component);
+ component.encodeAll(context);
}
}
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2010-02-21 23:15:30 UTC (rev 16478)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2010-02-21 23:19:48 UTC (rev 16479)
@@ -21,24 +21,21 @@
package org.ajax4jsf.renderkit;
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
import org.ajax4jsf.Messages;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.RenderKitUtils;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
import org.slf4j.Logger;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
/**
* Base Renderer for all chameleon Skin's and components.
* At most, make all common procedures and realise concrete work in "template" methods.
@@ -82,42 +79,11 @@
// TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding.
if (component.isRendered()) {
- decodeBehaviors(context, component);
+ RenderKitUtils.decodeBehaviors(context, component);
doDecode(context, component);
}
}
- protected void decodeBehaviors(FacesContext context, UIComponent component) {
- if (!(component instanceof ClientBehaviorHolder)) {
- return;
- }
-
- ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
- Map<String, List<ClientBehavior>> behaviors = holder.getClientBehaviors();
-
- if (behaviors.isEmpty()) {
- return;
- }
-
- ExternalContext external = context.getExternalContext();
- Map<String, String> params = external.getRequestParameterMap();
- String behaviorEvent = params.get("javax.faces.behavior.event");
-
- if (behaviorEvent == null) {
- return;
- }
-
- List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
- String behaviorSource = params.get("javax.faces.source");
- String clientId = component.getClientId();
-
- if ((null != behaviorSource) && behaviorSource.equals(clientId)) {
- for (ClientBehavior behavior : behaviorsForEvent) {
- behavior.decode(context, component);
- }
- }
- }
-
protected void preDecode(FacesContext context, UIComponent component) {
}
@@ -306,34 +272,13 @@
* @throws IOException
*/
public void renderChildren(FacesContext facesContext, UIComponent component) throws IOException {
- for (UIComponent child : component.getChildren()) {
- renderChild(facesContext, child);
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ child.encodeAll(facesContext);
+ }
}
}
- /**
- * Render one component and it childrens
- *
- * @param facesContext
- * @param child
- * @throws IOException
- */
- public void renderChild(FacesContext facesContext, UIComponent child) throws IOException {
- if (!child.isRendered()) {
- return;
- }
-
- child.encodeBegin(facesContext);
-
- if (child.getRendersChildren()) {
- child.encodeChildren(facesContext);
- } else {
- renderChildren(facesContext, child);
- }
-
- child.encodeEnd(facesContext);
- }
-
// TODO method stub - replace with JSF 2.0 annotations
public InternetResource getResource(String name) {
return null;
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2010-02-21 23:15:30 UTC (rev 16478)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2010-02-21 23:19:48 UTC (rev 16479)
@@ -67,7 +67,7 @@
if (children) {
this.renderChildren(context, component);
} else {
- this.renderChild(context, component);
+ component.encodeAll(context);
}
saxResponseWriter.endElement("root");
14 years, 10 months
JBoss Rich Faces SVN: r16478 - in root/ui-sandbox/trunk/components/tables/ui/src/main: templates/org/richfaces/renderkit/html and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-02-21 18:15:30 -0500 (Sun, 21 Feb 2010)
New Revision: 16478
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml
Log:
Replaced renderChild() method with encodeAll()
Replaced "cc" with "component"
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-02-19 17:35:31 UTC (rev 16477)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-02-21 23:15:30 UTC (rev 16478)
@@ -371,7 +371,7 @@
UIComponent facet = column.getFacet(facetName);
if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
+ facet.encodeAll(context);
}
strategy.encodeEnd(context, writer, column, facetName);
@@ -401,7 +401,7 @@
writer.writeAttribute("scope", "colgroup", null);
}
- renderChild(context, footer);
+ footer.encodeAll(context);
if(!isColumnGroup){
writer.endElement(element);
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-02-19 17:35:31 UTC (rev 16477)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-02-21 23:15:30 UTC (rev 16478)
@@ -124,7 +124,7 @@
UIComponent child = components.next();
if (child instanceof Row) {
encodeTableBodyEnd(writer, context, (UIDataTable) row);
- renderChild(context, (UISubTable) child);
+ child.encodeAll(context);
if (components.hasNext()) {
encodeTableBodyStart(writer, context, (UIDataTable) row);
}
@@ -195,7 +195,7 @@
writer.writeAttribute(HTML.STYLE_ATTRIBUTE, captionStyle, "captionStyle");
}
- renderChild(context, caption);
+ caption.encodeAll(context);
writer.endElement(HTML.CAPTION_ELEMENT);
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-02-19 17:35:31 UTC (rev 16477)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-02-21 23:15:30 UTC (rev 16478)
@@ -131,13 +131,13 @@
UIComponent caption = component.getFacet("caption");
if (caption != null && caption.isRendered()) {
writer.startElement(HTML.DIV_ELEM, component);
- renderChild(context, caption);
+ caption.encodeAll(context);
writer.endElement(HTML.DIV_ELEM);
}
UIComponent header = component.getFacet("header");
if (header != null && header.isRendered()) {
writer.startElement(HTML.DIV_ELEM, component);
- renderChild(context, header);
+ header.encodeAll(context);
writer.endElement(HTML.DIV_ELEM);
}
}
@@ -163,7 +163,7 @@
UIComponent facet = component.getFacet("footer");
if (facet != null && facet.isRendered()) {
writer.startElement(HTML.DIV_ELEM, component);
- renderChild(context, facet);
+ facet.encodeAll(context);
writer.endElement(HTML.DIV_ELEM);
}
writer.startElement(HTML.DIV_ELEM, component);
@@ -303,7 +303,7 @@
if (table.getRowCount() == 0) {
UIComponent facet = table.getFacet("noData");
if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
+ facet.encodeAll(context);
} else {
Object noDataLabel = table.getAttributes().get("noDataLabel");
if (noDataLabel != null) {
@@ -369,7 +369,7 @@
null);
UIComponent facet = column.getFacet(facetName);
if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
+ facet.encodeAll(context);
}
writer.endElement(HTML.DIV_ELEM);
writer.endElement(HTML.TD_ELEM);
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml 2010-02-19 17:35:31 UTC (rev 16477)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/templates/org/richfaces/renderkit/html/toggle-control.template.xml 2010-02-21 23:15:30 UTC (rev 16478)
@@ -13,11 +13,11 @@
</cc:interface>
<cc:implementation>
- <cdk:call expression="getUtils().encodeBeginFormIfNessesary(facesContext, cc);"/>
- <span id="#{clientId}" class="#{cc.attributes['styleClass']}">
- <cdk:call expression="encodeControl(facesContext, cc);" />
+ <cdk:call expression="getUtils().encodeBeginFormIfNessesary(facesContext, component);"/>
+ <span id="#{clientId}" class="#{component.attributes['styleClass']}">
+ <cdk:call expression="encodeControl(facesContext, component);" />
</span>
- <cdk:call expression="getUtils().encodeEndFormIfNessesary(facesContext, cc);"/>
+ <cdk:call expression="getUtils().encodeEndFormIfNessesary(facesContext, component);"/>
</cc:implementation>
</cdk:root>
\ No newline at end of file
14 years, 10 months
JBoss Rich Faces SVN: r16477 - root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-02-19 12:35:31 -0500 (Fri, 19 Feb 2010)
New Revision: 16477
Modified:
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Company.java
Log:
remove reference for the visual model
Modified: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Company.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Company.java 2010-02-19 17:18:11 UTC (rev 16476)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Company.java 2010-02-19 17:35:31 UTC (rev 16477)
@@ -1,6 +1,5 @@
package org.richfaces.demo.model;
-import org.richfaces.model.visual.SubTableVisualModel;
public class Company {
@@ -11,16 +10,7 @@
private String phone;
- SubTableVisualModel model;
- public SubTableVisualModel getModel() {
- return model;
- }
-
- public void setModel(SubTableVisualModel model) {
- this.model = model;
- }
-
public Company(String name) {
this.name = name;
}
14 years, 10 months
JBoss Rich Faces SVN: r16476 - in root/ui-sandbox/trunk/components/tables: ui/src/main/java/org/richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-02-19 12:18:11 -0500 (Fri, 19 Feb 2010)
New Revision: 16476
Removed:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Ordering.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/visual/
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/model/
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
Log:
use SortOrder instead Ordering, remove visual models classes
Deleted: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Ordering.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Ordering.java 2010-02-19 16:57:18 UTC (rev 16475)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Ordering.java 2010-02-19 17:18:11 UTC (rev 16476)
@@ -1,31 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-/**
- *
- * @author Maksim Kaszynski
- *
- */
-public enum Ordering {
- ASCENDING,
- DESCENDING,
- UNSORTED
-}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-02-19 16:57:18 UTC (rev 16475)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-02-19 17:18:11 UTC (rev 16476)
@@ -21,7 +21,6 @@
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UISubTable;
import org.richfaces.event.SortingEvent;
-import org.richfaces.model.Ordering;
import org.richfaces.model.SortMode;
@ResourceDependencies( { @ResourceDependency(library = "javax.faces", name = "jsf-uncompressed.js"),
14 years, 10 months
JBoss Rich Faces SVN: r16475 - in root/examples-sandbox/trunk/components/tables/src/main: java/org/richfaces/demo/utils and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-02-19 11:57:18 -0500 (Fri, 19 Feb 2010)
New Revision: 16475
Modified:
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java
root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml
Log:
Modified: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java 2010-02-19 16:50:37 UTC (rev 16474)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java 2010-02-19 16:57:18 UTC (rev 16475)
@@ -7,9 +7,7 @@
import org.richfaces.demo.model.Employee;
import org.richfaces.demo.utils.EmployeeUtils;
-import org.richfaces.event.ToggleEvent;
-import org.richfaces.model.visual.DataTableVisualModel;
-import org.richfaces.model.visual.SubTableVisualModel;
+import org.richfaces.event.SortingEvent;
@ManagedBean(name="dataBean")
@SessionScoped
@@ -17,17 +15,9 @@
private List<Employee> employeeList;
private boolean state = true;
+
- private DataTableVisualModel dataTableVisualModel;
-
- public DataTableVisualModel getDataTableVisualModel() {
- return dataTableVisualModel;
- }
- public void setDataTableVisualModel(DataTableVisualModel dataTableVisualModel) {
- this.dataTableVisualModel = dataTableVisualModel;
- }
-
public void setEmployeeList(List<Employee> employeeList) {
this.employeeList = employeeList;
}
@@ -46,5 +36,9 @@
public void setState(boolean state) {
this.state = state;
}
+
+ public void sortingListener(SortingEvent event) {
+ System.out.println(event.getSortOrder());
+ }
}
Modified: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java 2010-02-19 16:50:37 UTC (rev 16474)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java 2010-02-19 16:57:18 UTC (rev 16475)
@@ -18,7 +18,7 @@
addEmployeeToCollection(employeeList, "2Hideo Kodzima", "Vice Prezident", "khideo(a)konami.jp", "AMicrosoft", "419-615-2730", "Tokyo, Japan");
addEmployeeToCollection(employeeList, "3Stan Carpenter", "Lead Designer", "scarpenter(a)ndogs.com", "AMicrosoft", "714-647-3380", "Tokyo, Japan");
addEmployeeToCollection(employeeList, "Clement Gaudet", "Chief Technology Officer", "cgaudet(a)rstar.com", "Rock Star", "403-444-1100", "Canada");
- addEmployeeToCollection(employeeList, "Kazunori Yamauchi", "CEO", "ykazunori(a)sony.jp", "Sony", "410-561-4400", "Tokyo, Japan");
+ /*addEmployeeToCollection(employeeList, "Kazunori Yamauchi", "CEO", "ykazunori(a)sony.jp", "Sony", "410-561-4400", "Tokyo, Japan");
addEmployeeToCollection(employeeList, "Willis Aberg", "VP and CIO", "waberg(a)evjscet.com", "Evj Scet", "+046-155248000", "Tacoma, WA United States");
addEmployeeToCollection(employeeList, "Nick Acree", "Computer Technician", "nacree(a)grifcity.com", "City Of Griffin", "781-229-9599", "Houston, TX United States");
addEmployeeToCollection(employeeList, "RIchard L. Adams", "Technology", "rladams(a)penergy.com", "Panhandle Energy", "713-789-1400", "Valencia, CA United States");
@@ -1345,8 +1345,8 @@
addEmployeeToCollection(employeeList, "Derrik Khoo Sin Huat", "CTO", "aksinhuat(a)aes.com", "The AES Corporation", "864-233-4064", "Sydney, Australia");
addEmployeeToCollection(employeeList, "Rick Kelsven", "Network Analyst", "rkelsven(a)rudny.com", "Rudny's Inc", "208-356-4991", "Bangkok, Thailand");
+ */
-
return employeeList;
}
Modified: root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml 2010-02-19 16:50:37 UTC (rev 16474)
+++ root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml 2010-02-19 16:57:18 UTC (rev 16475)
@@ -13,30 +13,29 @@
<h:body>
<h:form id="form1">
- <rich:dataTable var="record" value="#{dataBean.employeeList}" rows="20" sortMode="single" visualModel="#{dataBean.dataTableVisualModel}">
+ <rich:dataTable var="record" value="#{dataBean.employeeList}" rows="20" sortMode="single">
<f:facet name="caption">
<h:outputText id="captioFacet1" value="Caption Facet" />
</f:facet>
<f:facet name="header">
- <rich:colGroup id="headerFacet1" >
+ <rich:colGroup id="headerFacet1">
<rich:column colspan="3"><h:outputText id="headerFacet12" value="header column 1"> </h:outputText></rich:column>
<rich:column breakBefore="true"><h:outputText id="headerFacet13" value="header column 2"></h:outputText></rich:column>
<rich:column colspan="2"><h:outputText id="headerFacet14" value="header column 3"></h:outputText></rich:column>
</rich:colGroup>
</f:facet>
- <rich:column id="column_name" sortBy="test1" sortIconAsc="resources/images/asc.gif" sortIconDesc="resources/images/desc.gif" sortIconUnsort="resources/images/unsort.gif">
+ <rich:column id="column_name" sortBy="#{record.name}" sortIconAsc="resources/images/asc.gif" sortIconDesc="resources/images/desc.gif" sortIconUnsort="resources/images/unsort.gif">
<f:facet name="header">
<h:outputText id="columnHeader1" value="Column Header Facet"/>
</f:facet>
-
- <rich:toggleControl forId="expandedSubTable" expandControl="resources/images/+.gif" collapseControl="resources/images/-.gif" />
+
<h:outputText value="#{record.name}" />
<f:facet name="footer">
<h:outputText id="columnFooter1" value="Column Footer Facet 1"/>
</f:facet>
</rich:column>
- <rich:column id="column_title" sortBy="test2" sortIconAsc="resources/images/asc.gif" sortIconDesc="resources/images/desc.gif" sortIconUnsort="resources/images/unsort.gif">
+ <rich:column id="column_title" sortBy="#{record.title}" sortIconAsc="resources/images/asc.gif" sortIconDesc="resources/images/desc.gif" sortIconUnsort="resources/images/unsort.gif">
<f:facet name="header">
<h:outputText id="columnHeader2" value="Column Header Facet 2"/>
</f:facet>
@@ -47,14 +46,12 @@
<h:outputText value="#{record.EMail}" />
</rich:column>
-
-
<rich:subTable id="expandedSubTable" var="company" value="#{record.company}" rows="20" switchType="ajax" expanded="true">
<f:facet name="header">
<rich:colGroup id="headerFacet1" >
- <rich:column><h:outputText id="headerFacet12" value="company"> </h:outputText></rich:column>
- <rich:column><h:outputText id="headerFacet13" value="office location"></h:outputText></rich:column>
- <rich:column><h:outputText id="headerFacet14" value="phone"></h:outputText></rich:column>
+ <rich:column><h:outputText id="headerFacet12" value="company"> </h:outputText></rich:column>
+ <rich:column><h:outputText id="headerFacet13" value="office location"></h:outputText></rich:column>
+ <rich:column><h:outputText id="headerFacet14" value="phone"></h:outputText></rich:column>
</rich:colGroup>
</f:facet>
14 years, 10 months
JBoss Rich Faces SVN: r16474 - root/ui-sandbox/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-02-19 11:50:37 -0500 (Fri, 19 Feb 2010)
New Revision: 16474
Modified:
root/ui-sandbox/trunk/pom.xml
Log:
Modified: root/ui-sandbox/trunk/pom.xml
===================================================================
--- root/ui-sandbox/trunk/pom.xml 2010-02-19 16:47:57 UTC (rev 16473)
+++ root/ui-sandbox/trunk/pom.xml 2010-02-19 16:50:37 UTC (rev 16474)
@@ -19,32 +19,35 @@
<build>
<plugins>
<plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <executions>
- <execution>
- <id>cdk-generate-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- <!--execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>compile-templates</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-test-sources</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>generate-tests</goal>
- </goals>
- </execution-->
- </executions>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <configuration>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <inherited>false</inherited>
+ <configuration>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
- </plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ </plugins>
</build>
<dependencies>
@@ -92,6 +95,7 @@
<artifactId>jsf-mock</artifactId>
<scope>test</scope>
</dependency>
+
</dependencies>
<modules>
14 years, 10 months