You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pr...@apache.org on 2005/11/23 02:20:12 UTC

svn commit: r348336 - in /myfaces/examples/trunk/sandbox: images/nav-minus.gif images/nav-plus.gif inputAjax.jsp src/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java

Author: prophecy
Date: Tue Nov 22 17:20:10 2005
New Revision: 348336

URL: http://svn.apache.org/viewcvs?rev=348336&view=rev
Log:
- can use images for selectBoolean now instead of the default checkbox.

Added:
    myfaces/examples/trunk/sandbox/images/nav-minus.gif   (with props)
    myfaces/examples/trunk/sandbox/images/nav-plus.gif   (with props)
Modified:
    myfaces/examples/trunk/sandbox/inputAjax.jsp
    myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java

Added: myfaces/examples/trunk/sandbox/images/nav-minus.gif
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/images/nav-minus.gif?rev=348336&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/examples/trunk/sandbox/images/nav-minus.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/examples/trunk/sandbox/images/nav-plus.gif
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/images/nav-plus.gif?rev=348336&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/examples/trunk/sandbox/images/nav-plus.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: myfaces/examples/trunk/sandbox/inputAjax.jsp
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/inputAjax.jsp?rev=348336&r1=348335&r2=348336&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/inputAjax.jsp (original)
+++ myfaces/examples/trunk/sandbox/inputAjax.jsp Tue Nov 22 17:20:10 2005
@@ -57,101 +57,117 @@
     random text into the Date field.</p>
 <f:view>
 
-    <h:form>
-        <h:panelGrid columns="2" columnClasses="bold,normal">
-            <h:outputText value="Input Some Text"/>
-            <h:panelGrid columns="1">
-                <s:inputTextAjax value="#{inputAjaxBean.text1}"
-                                 id="text1"
-                                 forceId="true"></s:inputTextAjax>
-                <f:verbatim>This component demonstrates ajax updating ability when you change the
-                    text.</f:verbatim>
-            </h:panelGrid>
-
-            <h:outputText value="Input Some Text2"/>
-            <h:panelGrid columns="1">
-                <s:inputTextAjax value="#{inputAjaxBean.text2}"
-                                 id="text2"
-                                 forceId="true"
-                                 showOkButton="true"
-                                 showCancelButton="true"
-                                 validator="#{inputAjaxBean.validateText2}"></s:inputTextAjax>
-                <s:message for="text2" styleClass="error"/>
-                <f:verbatim>This component demonstrates ajax updating ability, but you must click Ok for it to send.
-                    Cancel will clear the text and not send an update.</f:verbatim>
-            </h:panelGrid>
-
-            <h:outputText value="Input a Date"/>
-            <h:panelGrid columns="1">
-                <s:inputTextAjax value="#{inputAjaxBean.date1}"
-                                 id="date1"
-                                 forceId="true">
-                    <s:convertDateTime pattern="yyyy-MM-dd"/>
-                </s:inputTextAjax>
-                <s:message for="date1" styleClass="error"/>
-                <f:verbatim>This component demonstrates error handling capabilities, enter an invalid string to see the
-                    error returned from the server through ajax.</f:verbatim>
-            </h:panelGrid>
-
-
-            <h:outputText value="Select Some Boxes"/>
-            <h:panelGrid columns="1">
-                <s:selectManyCheckboxAjax
-                        id="smcb"
+<h:form>
+    <h:panelGrid columns="2" columnClasses="bold,normal">
+        <h:outputText value="Input Some Text"/>
+        <h:panelGrid columns="1">
+            <s:inputTextAjax value="#{inputAjaxBean.text1}"
+                             id="text1"
+                             forceId="true"></s:inputTextAjax>
+            <f:verbatim>This component demonstrates ajax updating ability when you change the
+                text.</f:verbatim>
+        </h:panelGrid>
+
+        <h:outputText value="Input Some Text2"/>
+        <h:panelGrid columns="1">
+            <s:inputTextAjax value="#{inputAjaxBean.text2}"
+                             id="text2"
+                             forceId="true"
+                             showOkButton="true"
+                             showCancelButton="true"
+                             validator="#{inputAjaxBean.validateText2}"></s:inputTextAjax>
+            <s:message for="text2" styleClass="error"/>
+            <f:verbatim>This component demonstrates ajax updating ability, but you must click Ok for it to send.
+                Cancel will clear the text and not send an update.</f:verbatim>
+        </h:panelGrid>
+
+        <h:outputText value="Input a Date"/>
+        <h:panelGrid columns="1">
+            <s:inputTextAjax value="#{inputAjaxBean.date1}"
+                             id="date1"
+                             forceId="true">
+                <s:convertDateTime pattern="yyyy-MM-dd"/>
+            </s:inputTextAjax>
+            <s:message for="date1" styleClass="error"/>
+            <f:verbatim>This component demonstrates error handling capabilities, enter an invalid string to see the
+                error returned from the server through ajax.</f:verbatim>
+        </h:panelGrid>
+
+
+        <h:outputText value="Select Some Boxes"/>
+        <h:panelGrid columns="1">
+            <s:selectManyCheckboxAjax
+                    id="smcb"
+                    forceId="true"
+                    value="#{inputAjaxBean.chosenValues}">
+                <f:selectItems
+                        value="#{inputAjaxBean.checkboxItems}"/>
+            </s:selectManyCheckboxAjax>
+            <f:verbatim>This component demonstrates ajax updating ability on a checkboxes.</f:verbatim>
+        </h:panelGrid>
+
+        <h:outputText value="Select A Radio Button"/>
+        <h:panelGrid columns="1">
+            <s:selectOneRadioAjax
+                    id="radio1"
+                    forceId="true"
+                    value="#{inputAjaxBean.radioValue}">
+                <f:selectItems
+                        value="#{inputAjaxBean.radioItems}"/>
+            </s:selectOneRadioAjax>
+            <f:verbatim>This component demonstrates ajax updating ability on a radio buttons.</f:verbatim>
+        </h:panelGrid>
+
+        <h:outputText value="Toggle Switch"/>
+        <h:panelGrid columns="1">
+            <h:panelGroup>
+                <s:selectBooleanCheckboxAjax
+                        id="toggle1"
                         forceId="true"
-                        value="#{inputAjaxBean.chosenValues}">
-                    <f:selectItems
-                            value="#{inputAjaxBean.checkboxItems}"/>
-                </s:selectManyCheckboxAjax>
-                <f:verbatim>This component demonstrates ajax updating ability on a checkboxes.</f:verbatim>
-            </h:panelGrid>
-
-            <h:outputText value="Select A Radio Button"/>
-            <h:panelGrid columns="1">
-                <s:selectOneRadioAjax
-                        id="radio1"
+                        value="#{inputAjaxBean.toggle1}"/>
+                <h:outputText value="Got Milk?"/>
+            </h:panelGroup>
+            <s:message for="toggle1" styleClass="error"/>
+            <f:verbatim>This component demonstrates ajax updating ability based on a toggle switch.</f:verbatim>
+        </h:panelGrid>
+
+        <h:outputText value="Toggle Switch With Images"/>
+        <h:panelGrid columns="1">
+            <h:panelGroup>
+                <s:selectBooleanCheckboxAjax
+                        id="toggle2"
                         forceId="true"
-                        value="#{inputAjaxBean.radioValue}">
-                    <f:selectItems
-                            value="#{inputAjaxBean.radioItems}"/>
-                </s:selectOneRadioAjax>
-                <f:verbatim>This component demonstrates ajax updating ability on a radio buttons.</f:verbatim>
-            </h:panelGrid>
-
-            <h:outputText value="Toggle Switch"/>
-            <h:panelGrid columns="1">
-                <h:panelGroup>
-                    <s:selectBooleanCheckboxAjax
-                            id="toggle1"
-                            forceId="true"
-                            value="#{inputAjaxBean.toggle1}"/>
-                    <h:outputText value="Got Milk?"/>
-                </h:panelGroup>
-                <t:message for="toggle1" styleClass="error"/>
-                <f:verbatim>This component demonstrates ajax updating ability based on a toggle switch.</f:verbatim>
-            </h:panelGrid>
-
-        </h:panelGrid>
-        <t:div id="statusDiv" forceId="true"></t:div>
-        <h:commandButton action="#{inputAjaxBean.submit}" value="Submit"/>
-    </h:form>
-
-    <h:outputLink value="inputAjax.jsf"><h:outputText value="Refresh"></h:outputText></h:outputLink>
-
-    <t:htmlTag value="br"/>
-    <h:outputText value="Current chosen checkbox values in server model"/>
-    <t:htmlTag value="br"/>
-    <h:dataTable
-            value="#{inputAjaxBean.chosenValues}"
-            var="cvalue">
-        <h:column>
-            <f:facet name="header">
-                <h:outputText value="value"/>
-            </f:facet>
-            <h:outputText value="#{cvalue}"/>
-        </h:column>
+                        value="#{inputAjaxBean.toggle2}"
+                        onImage="images/nav-plus.gif"
+                        offImage="images/nav-minus.gif"/>
+                <h:outputText value="Got Juice?"/>
+            </h:panelGroup>
+            <s:message for="toggle2" styleClass="error"/>
+            <f:verbatim>This component demonstrates ajax updating ability based on a toggle switch.</f:verbatim>
+        </h:panelGrid>
+
+
+    </h:panelGrid>
+    <t:div id="statusDiv" forceId="true"></t:div>
+    <h:commandButton action="#{inputAjaxBean.submit}" value="Submit"/>
+</h:form>
+
+<h:outputLink value="inputAjax.jsf"><h:outputText value="Refresh"></h:outputText></h:outputLink>
+
+<t:htmlTag value="br"/>
+<h:outputText value="Current chosen checkbox values in server model"/>
+<t:htmlTag value="br"/>
+<h:dataTable
+        value="#{inputAjaxBean.chosenValues}"
+        var="cvalue">
+    <h:column>
+        <f:facet name="header">
+            <h:outputText value="value"/>
+        </f:facet>
+        <h:outputText value="#{cvalue}"/>
+    </h:column>
 
-    </h:dataTable>
+</h:dataTable>
 
 </f:view>
 

Modified: myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java?rev=348336&r1=348335&r2=348336&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java (original)
+++ myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java Tue Nov 22 17:20:10 2005
@@ -42,7 +42,7 @@
     private List radioItems;
 
     private boolean toggle1 = false;
-
+    private boolean toggle2 = false;
 
     /**
      * Simple validator to show error handling messages in examples, returns an error if value string is
@@ -169,6 +169,16 @@
     public void setToggle1(boolean toggle1)
     {
         this.toggle1 = toggle1;
+    }
+
+    public boolean isToggle2()
+    {
+        return toggle2;
+    }
+
+    public void setToggle2(boolean toggle2)
+    {
+        this.toggle2 = toggle2;
     }
 
 }