You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by id...@apache.org on 2007/08/08 19:57:54 UTC

svn commit: r563965 - in /myfaces/tobago/trunk/example/test/src/main: java/org/apache/myfaces/tobago/example/test/SessionController.java webapp/partial.jsp

Author: idus
Date: Wed Aug  8 10:57:52 2007
New Revision: 563965

URL: http://svn.apache.org/viewvc?view=rev&rev=563965
Log:
example for checkbox to change required state of a field

Added:
    myfaces/tobago/trunk/example/test/src/main/webapp/partial.jsp
Modified:
    myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java

Modified: myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java?view=diff&rev=563965&r1=563964&r2=563965
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java (original)
+++ myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java Wed Aug  8 10:57:52 2007
@@ -24,8 +24,10 @@
 
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 
 public class SessionController {
 
@@ -44,6 +46,31 @@
   private Date validityStart;
   private Date validityEnd;
 
+  private boolean suppressProcessing;
+
+  private List<Row> suppressProcessingList = Arrays.asList(new Row(), new Row());
+
+  public static class Row {
+    private boolean suppressProcessing;
+    private String input;
+
+    public boolean isSuppressProcessing() {
+      return suppressProcessing;
+    }
+
+    public void setSuppressProcessing(boolean suppressProcessing) {
+      this.suppressProcessing = suppressProcessing;
+    }
+
+    public String getInput() {
+      return input;
+    }
+
+    public void setInput(String input) {
+      this.input = input;
+    }
+  }
+
   public SessionController() {
     Calendar calendar = Calendar.getInstance();
     calendar.set(2002, 0, 1);
@@ -116,5 +143,21 @@
 
   public void setValidityEnd(Date validityEnd) {
     this.validityEnd = validityEnd;
+  }
+
+  public boolean isSuppressProcessing() {
+    return suppressProcessing;
+  }
+
+  public void setSuppressProcessing(boolean suppressProcessing) {
+    this.suppressProcessing = suppressProcessing;
+  }
+
+  public List<Row> getSuppressProcessingList() {
+    return suppressProcessingList;
+  }
+
+  public void setSuppressProcessingList(List<Row> suppressProcessingList) {
+    this.suppressProcessingList = suppressProcessingList;
   }
 }

Added: myfaces/tobago/trunk/example/test/src/main/webapp/partial.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/partial.jsp?view=auto&rev=563965
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/partial.jsp (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/partial.jsp Wed Aug  8 10:57:52 2007
@@ -0,0 +1,70 @@
+<%--
+ * 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.
+--%>
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<%@ page pageEncoding="UTF-8" %>
+
+<f:view>
+  <tc:page width="500" height="300" id="page">
+
+    <tc:panel>
+      <f:facet name="layout">
+        <tc:gridLayout margin="10px" rows="fixed;*;fixed"/>
+      </f:facet>
+
+      <tc:box label="Test" id="panel">
+        <f:facet name="layout">
+          <tc:gridLayout rows="fixed" columns="*;2*"/>
+        </f:facet>
+        <tc:form>
+          <tx:selectBooleanCheckbox label="Don't process" value="#{controller.suppressProcessing}">
+            <f:facet name="change">
+              <tc:command>
+                <%--
+                <tc:attribute name="renderedPartially" value=":page:panel"/>
+                --%>
+              </tc:command>
+            </f:facet>
+          </tx:selectBooleanCheckbox>
+        </tc:form>
+        <tx:in label="Input" required="#{not controller.suppressProcessing}"/>
+      </tc:box>
+
+      <tc:sheet value="#{controller.suppressProcessingList}" var="row" columns="*;2*">
+        <tc:column label="Don't process">
+          <tc:form>
+            <tc:selectBooleanCheckbox value="#{row.suppressProcessing}">
+              <f:facet name="change">
+                <tc:command>
+                  <%--
+                  <tc:attribute name="renderedPartially" value=":page:panel"/>
+                  --%>
+                </tc:command>
+              </f:facet>
+            </tc:selectBooleanCheckbox>
+          </tc:form>
+        </tc:column>
+        <tc:column label="Input">
+          <tc:in value="#{row.input}" required="#{not row.suppressProcessing}"/>
+        </tc:column>
+      </tc:sheet>
+      <tc:button label="Submit"/>
+    </tc:panel>
+  </tc:page>
+</f:view>