Author: konstantin.mishin
Date: 2011-01-13 11:26:56 -0500 (Thu, 13 Jan 2011)
New Revision: 20995
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
trunk/cdk/generator/src/main/resources/META-INF/schema/cdk-template.xsd
trunk/cdk/generator/src/main/resources/META-INF/templates/java/define-object.ftl
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
trunk/ui/input/ui/src/main/templates/input.template.inc
trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml
Log:
RF-10095
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2011-01-13
15:49:52 UTC (rev 20994)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2011-01-13
16:26:56 UTC (rev 20995)
@@ -540,7 +540,7 @@
}
String type = cdkObjectElement.getType();
DefineObjectStatement statement = addStatement(DefineObjectStatement.class);
- statement.setObject(name, type, value);
+ statement.setObject(name, type, value, cdkObjectElement.isCast());
}
/*
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java 2011-01-13
15:49:52 UTC (rev 20994)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java 2011-01-13
16:26:56 UTC (rev 20995)
@@ -48,6 +48,9 @@
@XmlAttribute(required = true)
private String type;
+ @XmlAttribute
+ private boolean cast;
+
@XmlAttribute(name = "type-arguments")
private String typeArguments;
@@ -126,4 +129,12 @@
visitor.visitElement(this);
}
+ public void setCast(boolean cast) {
+ this.cast = cast;
+ }
+
+ public boolean isCast() {
+ return cast;
+ }
+
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2011-01-13
15:49:52 UTC (rev 20994)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2011-01-13
16:26:56 UTC (rev 20995)
@@ -44,6 +44,8 @@
private String name;
+ private boolean cast;
+
private final ELParser parser;
private final Logger log;
@@ -69,9 +71,10 @@
* the initializationExpression to set
* @throws ParsingException
*/
- public void setObject(String name, String type, String initializationExpression) {
+ public void setObject(String name, String type, String initializationExpression,
boolean cast) {
try {
this.name = name;
+ this.cast = cast;
if (!Strings.isEmpty(initializationExpression)) {
initializationStatement = parser.parse(initializationExpression, this,
TypesFactory.OBJECT_TYPE);
initializationStatement.setParent(this);
@@ -117,4 +120,8 @@
return null != initializationStatement ? Collections.<TemplateStatement>
singletonList(initializationStatement)
: Collections.<TemplateStatement> emptyList();
}
+
+ public boolean isCast() {
+ return cast;
+ }
}
Modified: trunk/cdk/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2011-01-13
15:49:52 UTC (rev 20994)
+++ trunk/cdk/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2011-01-13
16:26:56 UTC (rev 20995)
@@ -531,6 +531,11 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute type="xs:boolean" name="cast">
+ <xs:annotation>
+ <xs:documentation><p>Defines whether type cast is
needed.</p></xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates/java/define-object.ftl
===================================================================
---
trunk/cdk/generator/src/main/resources/META-INF/templates/java/define-object.ftl 2011-01-13
15:49:52 UTC (rev 20994)
+++
trunk/cdk/generator/src/main/resources/META-INF/templates/java/define-object.ftl 2011-01-13
16:26:56 UTC (rev 20995)
@@ -1 +1 @@
-${type} ${name} <#if initializationStatement?exists> =
${initializationStatement}</#if>;
\ No newline at end of file
+${type} ${name} <#if initializationStatement?exists> = <#if
cast>(${type})</#if>${initializationStatement}</#if>;
\ No newline at end of file
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java 2011-01-13
15:49:52 UTC (rev 20994)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java 2011-01-13
16:26:56 UTC (rev 20995)
@@ -25,7 +25,7 @@
public void testDefineVariable() throws Exception {
expect(typesFactory.getType("java.lang.String")).andReturn(TypesFactory.STRING_TYPE);
controller.replay();
- statement.setObject("foo","java.lang.String",null);
+ statement.setObject("foo","java.lang.String",null, false);
String code = statement.getCode();
controller.verify();
verifyCode(code, "String"," foo","!=");
@@ -41,7 +41,7 @@
expect(typesFactory.getType("java.lang.String")).andReturn(TypesFactory.STRING_TYPE);
parsedExpression.setParent(statement);expectLastCall();
controller.replay();
-
statement.setObject("foo","java.lang.String",HTTP_EXAMPLE_COM);
+
statement.setObject("foo","java.lang.String",HTTP_EXAMPLE_COM,
false);
String code = statement.getCode();
verifyCode(code, HTTP_EXAMPLE_COM,"String","=");
controller.verify();
@@ -55,7 +55,7 @@
expect(parsedExpression.getRequiredMethods()).andStubReturn(Collections.<HelperMethod>emptySet());
parsedExpression.setParent(statement);expectLastCall();
controller.replay();
- statement.setObject("foo",null,HTTP_EXAMPLE_COM);
+ statement.setObject("foo",null,HTTP_EXAMPLE_COM, false);
String code = statement.getCode();
verifyCode(code, "Integer","foo","=");
controller.verify();
Modified: trunk/ui/input/ui/src/main/templates/input.template.inc
===================================================================
--- trunk/ui/input/ui/src/main/templates/input.template.inc 2011-01-13 15:49:52 UTC (rev
20994)
+++ trunk/ui/input/ui/src/main/templates/input.template.inc 2011-01-13 16:26:56 UTC (rev
20995)
@@ -25,6 +25,7 @@
<span class="rf-insl-inp-cntr">
<input
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
name="#{clientId}" type="text"
class="rf-insl-inp #{component.attributes['inputClass']}"
value="#{getInputValue(facesContext, component)}"
- cdk:passThrough="accesskey disabled size:inputSize tabindex"
readonly="#{!component.attributes['enableManualInput']}"
- style="#{component.attributes['showInput'] ? null : 'display:
none;'}" maxlength="#{maxlength > 0 ? maxlength : null}"/>
+ cdk:passThrough="accesskey disabled tabindex"
readonly="#{!component.attributes['enableManualInput']}"
+ style="#{component.attributes['showInput'] ? null : 'display:
none;'}" maxlength="#{maxlength > 0 ? maxlength : null}"
+ size="#{inputSize > 0 ? inputSize : null}"/>
</span>
\ No newline at end of file
Modified: trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml 2011-01-13
15:49:52 UTC (rev 20994)
+++ trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml 2011-01-13
16:26:56 UTC (rev 20995)
@@ -39,7 +39,8 @@
</cc:interface>
<cc:implementation>
<span id="#{clientId}" class="rf-insl
#{component.attributes['styleClass']}" cdk:passThroughWithExclusions="id
class">
- <cdk:call expression='int maxlength = (Integer)
component.getAttributes().get("maxlength");' />
+ <cdk:object name="maxlength" type="Integer"
cast="true" value="#{component.attributes['maxlength']}"
/>
+ <cdk:object name="inputSize" type="Integer"
cast="true" value="#{component.attributes['inputSize']}"
/>
<c:if test="#{isInputPosition(component, 'left') ||
isInputPosition(component, 'top')}">
<xi:include xpointer="xpointer(/*)" href="input.template.inc"
/>
<c:if test="#{isInputPosition(component, 'top') and
component.attributes['showInput']}">