Author: drobiazko
Date: Fri Aug 19 11:36:41 2011
New Revision: 1159599

URL: http://svn.apache.org/viewvc?rev=1159599&view=rev
Log:
Added reference documentation for Checklist component

Added:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.xdoc
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/checklist_ref.png
   (with props)
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ChecklistDemo.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java?rev=1159599&r1=1159598&r2=1159599&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java
 Fri Aug 19 11:36:41 2011
@@ -30,6 +30,13 @@ import java.util.List;
 import java.util.Set;
 
 /**
+ * Multiple selection component, used as an alternative to the {@link Palette} 
component. 
+ * Generates a UI consisting of a list of check boxes. 
+ * 
+ * @since 5.3
+ * 
+ * @see Form
+ * @see Palette
  * @tapestrydoc
  */
 public class Checklist extends AbstractField

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.xdoc
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.xdoc?rev=1159599&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.xdoc
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.xdoc
 Fri Aug 19 11:36:41 2011
@@ -0,0 +1,116 @@
+<document>
+    <body>
+        <section name="Examples">
+
+            <p>
+                For this example, we'll implement a page from an e-commerce 
order wizard; the page collects information
+                about special handling for the order:
+            </p>
+
+            <p>
+                <br/>
+                <img src="checklist_ref.png"/>
+            </p>
+
+            <subsection name="SpecialHandling.java">
+
+            <p>
+                Now let's see how the component can be used.
+            </p>
+            
+                <source><![CDATA[
+public enum SpecialHandling
+{
+    EXPRESS_SERVICE, GIFT_WRAP, GIFT_BASKET, CUSTOM_ENGRAVING, 
SHIPPING_INSURANCE,
+    EXTENDED_WARRANTY
+}]]>        </source>
+
+                <p>
+                    In this contrived example, the possible types of special 
handling are defined using
+                    an enum. It's more likely, in the real world, that this 
would be defined in terms
+                    of a database entity.
+                </p>
+            </subsection>
+
+            <subsection name="OrderHandling.tml">
+                <source><![CDATA[
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";>
+    <body>
+        <h1>Special Handling</h1>
+
+        <t:form>
+
+            <t:checklist t:id="handling" encoder="encoder" model="model"/>
+
+            <br/>
+
+            <input type="submit" value="Continue"/>
+
+        </t:form>
+
+    </body>
+</html>]]></source>
+
+                <p>
+                    Here we are able to omit the selected parameter (the list 
of selected items) because the Checklist
+                    component's id matches a property of the page.
+                </p>
+
+                <p>
+                    The model parameter will define the available options that 
can be selected. The encoder parameter
+                    will define how to translate server side values (the enum 
values) into client side strings and back.
+                </p>
+
+            </subsection>
+
+            <subsection name="OrderHandling.java">
+                <source><![CDATA[
+public class OrderHandling {
+    @Property
+    @Persist
+    private List<SpecialHandling> handling;
+
+    @Inject
+    private Messages messages;
+
+    public ValueEncoder getEncoder() {
+        return new EnumValueEncoder(SpecialHandling.class);
+    }
+
+    public SelectModel getModel() {
+        return new EnumSelectModel(SpecialHandling.class, messages);
+    }
+}]]></source>
+
+                <p>
+                    Tapestry has built-in public classes that help convert 
enum types into value encoders
+                    and select models.
+                </p>
+
+                <p>
+                    Injecting a Messages object gives a component access to 
its own message catalog.
+                </p>
+
+                <p>
+                    The Checklist component will read the handling property 
when rendering (it's ok for it to be null).
+                    When the form is submitted, it will create a new List and 
update the handling property.
+                </p>
+
+            </subsection>
+        </section>
+
+        <section name="Notes">
+
+            <p>The Checklist component can be customized through CSS. 
Following CSS rules are used:</p>
+
+
+            <dl>
+                    <dt>t-checklist-row</dt>
+                    <dd>Each checkbox and its label is enclosed by a div 
element whose css attribute is set to t-checklist-row.</dd>
+
+            </dl>
+
+        </section>
+
+    </body>
+</document>
\ No newline at end of file

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/checklist_ref.png
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/checklist_ref.png?rev=1159599&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/checklist_ref.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ChecklistDemo.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ChecklistDemo.java?rev=1159599&r1=1159598&r2=1159599&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ChecklistDemo.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ChecklistDemo.java
 Fri Aug 19 11:36:41 2011
@@ -1,3 +1,17 @@
+// Copyright 2011 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.tapestry5.integration.app1.pages;
 
 import org.apache.tapestry5.ValueEncoder;


Reply via email to