You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/11/04 13:06:42 UTC
svn commit: r832715 - in /myfaces/tobago/trunk:
example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/
example/test/src/main/webapp/WEB-INF/ example/test/src/main/webapp/type/
tobago-tool/tobago-tool-apt/src/main/resources/org/apache/m...
Author: lofwyr
Date: Wed Nov 4 12:06:41 2009
New Revision: 832715
URL: http://svn.apache.org/viewvc?rev=832715&view=rev
Log:
TOBAGO-606: Layout Manager
- converting more types to Measure when using ValueExpression/ValueBinding
Added:
myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/
myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/MeasureBean.java
myfaces/tobago/trunk/example/test/src/main/webapp/type/
myfaces/tobago/trunk/example/test/src/main/webapp/type/measure.xhtml
Modified:
myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/faces-config.xml
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
Added: myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/MeasureBean.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/MeasureBean.java?rev=832715&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/MeasureBean.java (added)
+++ myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/type/MeasureBean.java Wed Nov 4 12:06:41 2009
@@ -0,0 +1,67 @@
+package org.apache.myfaces.tobago.example.test.type;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
+
+public class MeasureBean {
+
+ int intWidth = 200;
+ Integer integerWidth = new Integer(250);
+ Measure measureWidth = new PixelMeasure(300);
+ String stringWidth = "350";
+ String stringPxWidth = "400px";
+ long longWidth = 450L;
+ Any anyWidth = new Any();
+
+ public int getIntWidth() {
+ return intWidth;
+ }
+
+ public Integer getIntegerWidth() {
+ return integerWidth;
+ }
+
+ public Measure getMeasureWidth() {
+ return measureWidth;
+ }
+
+ public String getStringWidth() {
+ return stringWidth;
+ }
+
+ public String getStringPxWidth() {
+ return stringPxWidth;
+ }
+
+ public long getLongWidth() {
+ return longWidth;
+ }
+
+ public Any getAnyWidth() {
+ return anyWidth;
+ }
+
+ public static class Any {
+ @Override
+ public String toString() {
+ return "500";
+ }
+ }
+}
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/faces-config.xml?rev=832715&r1=832714&r2=832715&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/faces-config.xml Wed Nov 4 12:06:41 2009
@@ -59,6 +59,12 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>measureBean</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.tobago.example.test.type.MeasureBean</managed-bean-class>
+ <managed-bean-scope>none</managed-bean-scope>
+ </managed-bean>
+
<navigation-rule>
<navigation-case>
<from-outcome>navigation</from-outcome>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/type/measure.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/type/measure.xhtml?rev=832715&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/type/measure.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/type/measure.xhtml Wed Nov 4 12:06:41 2009
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <tc:page id="page">
+ <tc:gridLayoutConstraint width="600px" height="2000px"/>
+<f:facet name="layout">
+ <tc:gridLayout cellspacing="25px"/>
+</f:facet>
+ <!--
+ Test of different ways to set the width of tc:gridLayoutConstraint.
+ There are literals like "100" or "100px" and
+ different types like: Measure, Integer, int, String (?)
+ -->
+
+ <tc:image id="i-0" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="100px" height="95px"/>
+ </tc:image>
+ <tc:image id="i-1" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="150" height="95px"/>
+ </tc:image>
+ <tc:image id="i-2" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.intWidth}" height="95px"/>
+ </tc:image>
+ <tc:image id="i-3" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.integerWidth}" height="95px"/>
+ </tc:image>
+ <tc:image id="i-4" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.measureWidth}" height="95px"/>
+ </tc:image>
+ <tc:image id="i-5" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.stringWidth}" height="95px"/>
+ </tc:image>
+ <tc:image id="i-6" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.stringPxWidth}" height="95px"/>
+ </tc:image>
+ <tc:image id="i-7" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.longWidth}" height="95px"/>
+ </tc:image>
+ <tc:image id="i-8" value="pidgeon-point.jpg">
+ <tc:gridLayoutConstraint width="#{measureBean.anyWidth}" height="95px"/>
+ </tc:image>
+
+ <tc:image id="j-0" value="pidgeon-point.jpg" width="100px" height="95px"/>
+ <tc:image id="j-1" value="pidgeon-point.jpg" width="150" height="95px"/>
+ <tc:image id="j-2" value="pidgeon-point.jpg" width="#{measureBean.intWidth}" height="95px"/>
+ <tc:image id="j-3" value="pidgeon-point.jpg" width="#{measureBean.integerWidth}" height="95px"/>
+ <tc:image id="j-4" value="pidgeon-point.jpg" width="#{measureBean.measureWidth}" height="95px"/>
+ <tc:image id="j-5" value="pidgeon-point.jpg" width="#{measureBean.stringWidth}" height="95px"/>
+ <tc:image id="j-6" value="pidgeon-point.jpg" width="#{measureBean.stringPxWidth}" height="95px"/>
+ <tc:image id="j-7" value="pidgeon-point.jpg" width="#{measureBean.longWidth}" height="95px"/>
+ <tc:image id="j-8" value="pidgeon-point.jpg" width="#{measureBean.anyWidth}" height="95px"/>
+
+ <!-- fixme: this filler is not nice, should work automatically -->
+ <tc:cell>
+ <tc:gridLayoutConstraint width="100px" height="200px"/>
+ </tc:cell>
+
+ <!-- checks below here -->
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout('page:i-0', 0, 0, 100, 95);"/>
+ <tc:script onload="checkLayout('page:i-1', 0, 100, 150, 95);"/>
+ <tc:script onload="checkLayout('page:i-2', 0, 200, 200, 95);"/>
+ <tc:script onload="checkLayout('page:i-3', 0, 300, 250, 95);"/>
+ <tc:script onload="checkLayout('page:i-4', 0, 400, 300, 95);"/>
+ <tc:script onload="checkLayout('page:i-5', 0, 500, 350, 95);"/>
+ <tc:script onload="checkLayout('page:i-6', 0, 600, 400, 95);"/>
+ <tc:script onload="checkLayout('page:i-7', 0, 700, 450, 95);"/>
+ <tc:script onload="checkLayout('page:i-8', 0, 800, 500, 95);"/>
+
+ <tc:script onload="checkLayout('page:j-0', 0, 900, 100, 95);"/>
+ <tc:script onload="checkLayout('page:j-1', 0, 1000, 150, 95);"/>
+ <tc:script onload="checkLayout('page:j-2', 0, 1100, 200, 95);"/>
+ <tc:script onload="checkLayout('page:j-3', 0, 1200, 250, 95);"/>
+ <tc:script onload="checkLayout('page:j-4', 0, 1300, 300, 95);"/>
+ <tc:script onload="checkLayout('page:j-5', 0, 1400, 350, 95);"/>
+ <tc:script onload="checkLayout('page:j-6', 0, 1500, 400, 95);"/>
+ <tc:script onload="checkLayout('page:j-7', 0, 1600, 450, 95);"/>
+ <tc:script onload="checkLayout('page:j-8', 0, 1700, 500, 95);"/>
+
+ </tc:page>
+</f:view>
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg?rev=832715&r1=832714&r2=832715&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg Wed Nov 4 12:06:41 2009
@@ -400,20 +400,22 @@
MeasureProperty(property) ::= <<
-public <property.type> get<property.upperCamelCaseName>() {
+public Measure get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
}
<getValueExpression(property)>
if (vb != null) {
Object object = <getValue(property)>
- if (object instanceof Number) {
- return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
- } else if (object instanceof Measure) {
- <property.type> <property.propertyName> = (<property.type>) object;
+ if (object instanceof Measure) {
+ Measure <property.propertyName> = (Measure) object;
return <property.propertyName>;
+ } else if (object instanceof Number) {
+ return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+ } else if (object instanceof String) {
+ return Measure.parse((String)object);
} else if (object != null) {
- throw new ClassCastException(object.getClass().getName());
+ return Measure.parse(object.toString());
}
}
<if(property.defaultCode)>
@@ -423,7 +425,7 @@
<endif>
}
-public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+public void set<property.upperCamelCaseName>(Measure <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
>>
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg?rev=832715&r1=832714&r2=832715&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg Wed Nov 4 12:06:41 2009
@@ -355,13 +355,15 @@
if (ve != null) {
try {
Object object = <getValue(property)>
- if (object instanceof Number) {
- return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
- } else if (object instanceof Measure) {
- <property.type> <property.propertyName> = (<property.type>) object;
+ if (object instanceof Measure) {
+ Measure <property.propertyName> = (Measure) object;
return <property.propertyName>;
+ } else if (object instanceof Number) {
+ return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+ } else if (object instanceof String) {
+ return Measure.parse((String)object);
} else if (object != null) {
- throw new ClassCastException(object.getClass().getName());
+ return Measure.parse(object.toString());
}
} catch (javax.el.ELException e) {
throw new javax.faces.FacesException(e);