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 2013/10/08 18:06:06 UTC

svn commit: r1530331 - in /myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main: java/org/apache/myfaces/tobago/example/test/ webapp/WEB-INF/ webapp/test/forEach/

Author: lofwyr
Date: Tue Oct  8 16:06:05 2013
New Revision: 1530331

URL: http://svn.apache.org/r1530331
Log:
try dynamic including

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicBean.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel1.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel2.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel3.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/dynamic-include.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-one.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-three.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-two.xhtml
Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicBean.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicBean.java?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicBean.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicBean.java Tue Oct  8 16:06:05 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DynamicBean {
+
+  private List<DynamicPanel> panels = new ArrayList<DynamicPanel>();
+
+  public String addPanel() {
+
+    switch (panels.size()) {
+      case 0:
+        panels.add(new DynamicPanel1());
+        break;
+      case 1:
+        panels.add(new DynamicPanel2());
+        break;
+      case 2:
+        panels.add(new DynamicPanel3());
+        break;
+      default:
+        FacesContext.getCurrentInstance().addMessage(null,
+            new FacesMessage(FacesMessage.SEVERITY_WARN, "All panels where added!", null));
+    }
+    return null;
+  }
+
+  public String reset() {
+    panels.clear();
+    return "test/forEach/dynamic-include.xhtml";
+  }
+
+  public List<DynamicPanel> getPanels() {
+    return panels;
+  }
+
+}

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel.java?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel.java Tue Oct  8 16:06:05 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+public abstract class DynamicPanel {
+
+  private static final String[] PANEL_FILES = new String[]{
+      "panel-one.xhtml",
+      "panel-two.xhtml",
+      "panel-three.xhtml"};
+
+  private final String name;
+
+  public DynamicPanel() {
+    final String simpleName = this.getClass().getSimpleName();
+    final int number = Integer.parseInt(simpleName.substring(simpleName.length() - 1)) - 1;
+    this.name = PANEL_FILES[number];
+  }
+
+  public String getName() {
+    return name;
+  }
+}

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel1.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel1.java?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel1.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel1.java Tue Oct  8 16:06:05 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+public class DynamicPanel1 extends DynamicPanel {
+
+  public String value;
+
+  public String getValue() {
+    return value;
+  }
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+}

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel2.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel2.java?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel2.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel2.java Tue Oct  8 16:06:05 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+public class DynamicPanel2 extends DynamicPanel {
+
+  public String firstName;
+  public String secondName;
+
+  public String getFirstName() {
+    return firstName;
+  }
+
+  public void setFirstName(String firstName) {
+    this.firstName = firstName;
+  }
+
+  public String getSecondName() {
+    return secondName;
+  }
+
+  public void setSecondName(String secondName) {
+    this.secondName = secondName;
+  }
+}

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel3.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel3.java?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel3.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/DynamicPanel3.java Tue Oct  8 16:06:05 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+public class DynamicPanel3 extends DynamicPanel {
+
+  public String street;
+  public String city;
+
+  public String getStreet() {
+    return street;
+  }
+
+  public void setStreet(String street) {
+    this.street = street;
+  }
+
+  public String getCity() {
+    return city;
+  }
+
+  public void setCity(String city) {
+    this.city = city;
+  }
+}

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml?rev=1530331&r1=1530330&r2=1530331&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml Tue Oct  8 16:06:05 2013
@@ -197,6 +197,12 @@
     <managed-bean-scope>none</managed-bean-scope>
   </managed-bean>
 
+  <managed-bean>
+    <managed-bean-name>dynamic</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.test.DynamicBean</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
   <navigation-rule>
     <navigation-case>
       <from-outcome>navigation</from-outcome>

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/dynamic-include.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/dynamic-include.xhtml?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/dynamic-include.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/dynamic-include.xhtml Tue Oct  8 16:06:05 2013
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:view xmlns="http://www.w3.org/1999/xhtml"
+        xmlns:ui="http://java.sun.com/jsf/facelets"
+        xmlns:f="http://java.sun.com/jsf/core"
+        xmlns:h="http://java.sun.com/jsf/html"
+        xmlns:tc="http://myfaces.apache.org/tobago/component"
+        xmlns:tx="http://myfaces.apache.org/tobago/extension"
+        xmlns:c="http://java.sun.com/jsp/jstl/core">
+
+  <tc:page width="800px" height="800px" label="Dynamic Include">
+    <tc:box label="Dynamic Included Panels">
+      <f:facet name="layout">
+        <tc:gridLayout margin="10px" columns="500px" rows="auto;auto;auto;auto;auto"/>
+      </f:facet>
+      <tc:messages/>
+      <c:forEach var="panel" items="#{dynamic.panels}">
+        <ui:include src="#{panel.name}"/>
+      </c:forEach>
+      <tc:panel>
+        <f:facet name="layout">
+          <tc:gridLayout columns="100px;100px;*" rows="fixed"/>
+        </f:facet>
+        <tc:button label="Next" action="#{dynamic.addPanel}"/>
+        <tc:button label="Reset" immediate="true" action="#{dynamic.reset}"/>
+      </tc:panel>
+    </tc:box>
+  </tc:page>
+</f:view>

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-one.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-one.xhtml?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-one.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-one.xhtml Tue Oct  8 16:06:05 2013
@@ -0,0 +1,16 @@
+<ui:composition
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:tc="http://myfaces.apache.org/tobago/component"
+    xmlns:tx="http://myfaces.apache.org/tobago/extension">
+
+  <tc:panel>
+    <f:facet name="layout">
+      <tc:gridLayout margin="10px" columns="500px" rows="fixed;fixed"/>
+    </f:facet>
+    <tc:separator label="Panel One"/>
+    <tx:in label="Value One" value="#{panel.value}" />
+  </tc:panel>
+</ui:composition>

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-three.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-three.xhtml?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-three.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-three.xhtml Tue Oct  8 16:06:05 2013
@@ -0,0 +1,17 @@
+<ui:composition
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:tc="http://myfaces.apache.org/tobago/component"
+    xmlns:tx="http://myfaces.apache.org/tobago/extension">
+
+  <tc:panel>
+    <f:facet name="layout">
+      <tc:gridLayout margin="10px" columns="500px" rows="fixed;fixed"/>
+    </f:facet>
+    <tc:separator label="Panel Three"/>
+    <tx:in label="Street" value="#{panel.street}" />
+    <tx:in label="City" value="#{panel.city}" />
+  </tc:panel>
+</ui:composition>

Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-two.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-two.xhtml?rev=1530331&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-two.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/forEach/panel-two.xhtml Tue Oct  8 16:06:05 2013
@@ -0,0 +1,17 @@
+<ui:composition
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:tc="http://myfaces.apache.org/tobago/component"
+    xmlns:tx="http://myfaces.apache.org/tobago/extension">
+
+  <tc:panel>
+    <f:facet name="layout">
+      <tc:gridLayout margin="10px" columns="500px" rows="fixed;fixed"/>
+    </f:facet>
+    <tc:separator label="Panel Two"/>
+    <tx:in label="First Name" value="#{panel.firstName}" />
+    <tx:in label="Second Name" value="#{panel.secondName}" />
+  </tc:panel>
+</ui:composition>