myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r803488 - /myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.xhtml
Date Wed, 12 Aug 2009 13:12:15 GMT
Author: lofwyr
Date: Wed Aug 12 13:12:15 2009
New Revision: 803488

URL: http://svn.apache.org/viewvc?rev=803488&view=rev
Log:
sample to show problems with interators

Added:
    myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.xhtml
      - copied, changed from r765257, myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.jsp

Copied: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.xhtml
(from r765257, myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.jsp)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.xhtml?p2=myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.xhtml&p1=myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.jsp&r1=765257&r2=803488&rev=803488&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.jsp
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/best-practice/for-each.xhtml
Wed Aug 12 13:12:15 2009
@@ -1,4 +1,4 @@
-<%--
+<!--
  * 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.
@@ -13,67 +13,32 @@
  * 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.
---%>
+-->
 
-<%@ page import="org.apache.myfaces.tobago.example.demo.bestpractice.BestPracticeController"
%>
-<%@ page import="org.apache.myfaces.tobago.util.VariableResolverUtil" %>
-<%@ page import="javax.faces.context.FacesContext" %>
-<%@ page import="javax.servlet.jsp.jstl.core.LoopTagStatus" %>
-
-<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
-
-<%
-  // load bean before expression in foreach
-  BestPracticeController controller
-      = (BestPracticeController) VariableResolverUtil.resolveVariable(
-      FacesContext.getCurrentInstance(), "bestPracticeController");
-%>
-<%!
-  private String expression(String list, String status, String field, PageContext pageContext)
{
-    int index = ((LoopTagStatus) pageContext.getAttribute(status)).getIndex();
-    return "#{" + list + "[" + index + "]." + field + "}";
-  }
-  private String fixed(int count) {
-    StringBuffer buffer = new StringBuffer();
-    for (int i = 0; i < count; i++) {
-      buffer.append("fixed;");
-    }
-    return buffer.toString();
-  }
-%>
-<f:view locale="#{clientConfigController.locale}">
-  <tc:loadBundle basename="overview" var="overviewBundle"/>
-  <tc:page applicationIcon="icon/favicon.ico" id="page" width="600px" height="400px">
-    <tc:box label="Best Practice - For Each">
-      <f:facet name="layout">
-        <tc:gridLayout rows="<%= "100px;" + fixed(controller.getBirds().size()) + "100px;*"%>"
columns="2*;*"/>
-      </f:facet>
-
-      <tc:cell spanX="2">
-        <tc:out escape="false"
-                value="Is is possible to use the c:forEach tag of the JSTL to iterate over
a list. <br/><b>Warning:</b> <br/>This example is a workaround. <br/>It
is not compatible with further releases! <br/>This example works not with JSP-Tag-Files!"/>
-      </tc:cell>
-
-      <c:forEach items="${bestPracticeController.birds}" varStatus="status">
-        <%
-          String label = expression("bestPracticeController.birds", "status", "name", pageContext);
-          String value = expression("bestPracticeController.birds", "status", "size", pageContext);
-          String action = expression("bestPracticeController.birds", "status", "select",
pageContext);
-        %>
-        <tx:in value="<%=value%>" label="<%=label%>"/>
-        <tc:button label="Select" action="<%=action%>"/>
-      </c:forEach>
-
-      <tc:cell spanX="2">
-        <tc:out value="#{bestPracticeController.status}"/>
-      </tc:cell>
-
-      <tc:cell spanX="2"/>
-
-    </tc:box>
-  </tc:page>
-</f:view>
+<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
+                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:h="http://java.sun.com/jsf/html"
+                xmlns:f="http://java.sun.com/jsf/core">
+  <ui:param name="title" value="Repeat/ForEach Test (not working)"/>
+
+  <!--  XXX not working! -->
+
+  <tc:panel>
+    <!--<f:facet name="layout">-->
+      <!--<tc:gridLayout rows="fixed;fixed;fixed;fixed;fixed;*"/>-->
+    <!--
+    XXX Without a gridLayout, the controls will be rendered, but cannot be seen,
+    XXX because there are behind other elements.
+    XXX With a gridLayout, it doesn't work correktly.
+     -->
+    <!--</f:facet>-->
+    <ui:repeat value="#{bestPracticeController.birds}" var="bird">
+      <tx:in value="#{bird.size}" label="#{bird.name}"/>
+    </ui:repeat>
+    <tc:label value="Not working :-("/>
+    <tc:cell/>
+  </tc:panel>
+</ui:composition>



Mime
View raw message