myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmarinsc...@apache.org
Subject svn commit: r374858 - in /myfaces/tomahawk/trunk/examples/simple/src/main: java/org/apache/myfaces/examples/aliasexample/ webapp/ webapp/WEB-INF/
Date Sat, 04 Feb 2006 11:17:11 GMT
Author: mmarinschek
Date: Sat Feb  4 03:17:01 2006
New Revision: 374858

URL: http://svn.apache.org/viewcvs?rev=374858&view=rev
Log:
added test-case for component-binding

Added:
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/ComponentBindingHolderBase.java
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/FirstComponentBindingHolder.java
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/SecondComponentBindingHolder.java
Modified:
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/aliasBean.jsp

Added: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/ComponentBindingHolderBase.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/ComponentBindingHolderBase.java?rev=374858&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/ComponentBindingHolderBase.java
(added)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/ComponentBindingHolderBase.java
Sat Feb  4 03:17:01 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.myfaces.examples.aliasexample;
+
+import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Martin Marinschek (latest modification by $Author: matzew $)
+ * @version $Revision: 167718 $ $Date: 2005-03-24 17:47:11 +0100 (Do, 24 Mär 2005) $
+ */
+public abstract class ComponentBindingHolderBase
+{
+    protected HtmlPanelGroup _panelGroup;
+
+    public HtmlPanelGroup getPanelGroup()
+    {
+        if(_panelGroup == null)
+        {
+            _panelGroup = (HtmlPanelGroup) createComponent(HtmlPanelGroup.COMPONENT_TYPE);
+            _panelGroup.getChildren().add(createOutputText());
+        }
+
+        return _panelGroup;
+    }
+
+    public void setPanelGroup(HtmlPanelGroup panelGroup)
+    {
+        _panelGroup = panelGroup;
+        _panelGroup.getChildren().add(createOutputText());
+    }
+
+    protected UIComponent createComponent(String type)
+    {
+        return FacesContext.getCurrentInstance().getApplication().createComponent(type);
+    }
+
+    private HtmlOutputText createOutputText()
+    {
+        HtmlOutputText text = (HtmlOutputText) createComponent(HtmlOutputText.COMPONENT_TYPE);
+        text.setValue(getText());
+        return text;
+    }
+
+    protected abstract String getText();
+
+}

Added: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/FirstComponentBindingHolder.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/FirstComponentBindingHolder.java?rev=374858&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/FirstComponentBindingHolder.java
(added)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/FirstComponentBindingHolder.java
Sat Feb  4 03:17:01 2006
@@ -0,0 +1,19 @@
+package org.apache.myfaces.examples.aliasexample;
+
+import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.component.html.HtmlOutputText;
+
+/**
+ * @author Martin Marinschek (latest modification by $Author: matzew $)
+ * @version $Revision: 167718 $ $Date: 2005-03-24 17:47:11 +0100 (Do, 24 Mär 2005) $
+ */
+public class FirstComponentBindingHolder extends ComponentBindingHolderBase
+{
+
+    protected String getText()
+    {
+        return "first";
+    }
+
+
+}

Added: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/SecondComponentBindingHolder.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/SecondComponentBindingHolder.java?rev=374858&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/SecondComponentBindingHolder.java
(added)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/aliasexample/SecondComponentBindingHolder.java
Sat Feb  4 03:17:01 2006
@@ -0,0 +1,17 @@
+package org.apache.myfaces.examples.aliasexample;
+
+import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.component.html.HtmlOutputText;
+
+/**
+ * @author Martin Marinschek (latest modification by $Author: matzew $)
+ * @version $Revision: 167718 $ $Date: 2005-03-24 17:47:11 +0100 (Do, 24 Mär 2005) $
+ */
+public class SecondComponentBindingHolder extends ComponentBindingHolderBase
+{
+
+    protected String getText()
+    {
+        return "second";
+    }
+}

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml?rev=374858&r1=374857&r2=374858&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml Sat
Feb  4 03:17:01 2006
@@ -72,6 +72,18 @@
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
 
+    <managed-bean>
+        <managed-bean-name>firstComponentBindingHolder</managed-bean-name>
+        <managed-bean-class>org.apache.myfaces.examples.aliasexample.FirstComponentBindingHolder</managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+    </managed-bean>
+
+    <managed-bean>
+        <managed-bean-name>secondComponentBindingHolder</managed-bean-name>
+        <managed-bean-class>org.apache.myfaces.examples.aliasexample.SecondComponentBindingHolder</managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+    </managed-bean>
+
     <!-- Managed Beans for collapsiblePanel.jsp -->
     <managed-bean>
         <managed-bean-name>firstCollapsiblePanelBean</managed-bean-name>

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/aliasBean.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/aliasBean.jsp?rev=374858&r1=374857&r2=374858&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/aliasBean.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/aliasBean.jsp Sat Feb  4 03:17:01
2006
@@ -85,6 +85,21 @@
 			</t:div>
         </t:aliasBeansScope>
 
+        <h2>aliasBean with component-binding - if everything works, you should see
'first' followed by 'second'</h2>
+        <t:aliasBean alias="#{holder}" value="#{firstComponentBindingHolder}" >
+            <f:subview id="simulatedIncludedSubform3">
+                <%-- The next tags could be inserted by an %@ include or jsp:include --%>
+                <h:panelGroup binding="#{firstComponentBindingHolder.panelGroup}"/>
+            </f:subview>
+        </t:aliasBean>
+
+        <t:aliasBean alias="#{holder}" value="#{firstComponentBindingHolder}" >
+            <f:subview id="simulatedIncludedSubform3">
+                <%-- The next tags could be inserted by an %@ include or jsp:include --%>
+                <h:panelGroup binding="#{secondComponentBindingHolder.panelGroup}"/>
+            </f:subview>
+        </t:aliasBean>
+
         <br/><br/>
 
         <h:commandButton/>



Mime
View raw message