You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by nc...@apache.org on 2003/02/23 17:05:55 UTC
cvs commit: jakarta-tapestry/doc/src/Tutorial2 tutorial-chapter-forms.xml
nclayton 2003/02/23 08:05:55
Modified: doc/src/Tutorial2 tutorial-chapter-forms.xml
Log:
Inserted visit object and tidied up a few items
Revision Changes Path
1.4 +92 -35 jakarta-tapestry/doc/src/Tutorial2/tutorial-chapter-forms.xml
Index: tutorial-chapter-forms.xml
===================================================================
RCS file: /home/cvs/jakarta-tapestry/doc/src/Tutorial2/tutorial-chapter-forms.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- tutorial-chapter-forms.xml 26 Jan 2003 12:21:25 -0000 1.3
+++ tutorial-chapter-forms.xml 23 Feb 2003 16:05:54 -0000 1.4
@@ -87,35 +87,29 @@
</programlisting>
</figure>
- <para>We will now write a page specification to handle these fields, using standard InputText fields:</para>
+ <para>We will now write a page specification to handle these fields, using standard &TextField;'s:</para>
<figure>
<title>Page Specification for Part One</title>
<programlisting>
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<!DOCTYPE page-specification PUBLIC
- "-//Howard Lewis Ship//Tapestry Specification 1.3//EN"
- "http://tapestry.sf.net/dtd/Tapestry_1_3.dtd">
-
<page-specification class="tutorial.forms.Part1">
<bean name="delegate" class="net.sf.tapestry.valid.ValidationDelegate"/>
<component id="form" type="Form">
- <binding name="delegate" expression="beans.delegate"/>
+ <binding name="delegate" expression="beans.delegate"/>
</component>
-
+
<component id="name" type="TextField">
<binding name="value" expression="visit.userName"/>
</component>
-
+
<component id="dateOfBirth" type="TextField">
- <binding name="value" expression="visit.dateOfBirth"/>
+ <binding name="value" expression="visit.dateOfBirthAsString"/>
</component>
<component id="favColour" type="TextField">
<binding name="value" expression="visit.favoriteColour"/>
</component>
-
+
<component id="submit" type="Submit">
<binding name="listener" expression="listeners.enterDetails"/>
</component>
@@ -185,7 +179,76 @@
<figure>
<title>The Visit Object, Part One</title>
<programlisting>
- INSERT VISIT OBJECT HERE WHEN DONE
+ public class VisitorState implements Serializable
+ {
+ /**
+ * Returns the dateOfBirth.
+ * @return String
+ */
+ public Date getDateOfBirth()
+ {
+ return dateOfBirth;
+ }
+
+ public String getDateOfBirthAsString()
+ {
+ return DateFormat.getDateInstance().format(dateOfBirth);
+ }
+
+ /**
+ * Returns the favoriteColour.
+ * @return String
+ */
+ public String getFavoriteColour()
+ {
+ return favoriteColour;
+ }
+
+ /**
+ * Returns the name.
+ * @return String
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * Sets the dateOfBirth.
+ * @param dateOfBirth The dateOfBirth to set
+ */
+ public void setDateOfBirth(Date dateOfBirth)
+ {
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ /**
+ * Sets the favoriteColour.
+ * @param favoriteColour The favoriteColour to set
+ */
+ public void setFavoriteColour(String favoriteColour)
+ {
+ this.favoriteColour = favoriteColour;
+ }
+
+ public void setDateOfBirthAsString(String newDOB) throws ParseException
+ {
+ dateOfBirth = DateFormat.getDateInstance().parse(newDOB);
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setUserName(String name)
+ {
+ this.userName = name;
+ }
+
+ private String userName;
+ private Date dateOfBirth = new Date(0);
+ private String favoriteColour;
+ }
</programlisting>
</figure>
@@ -231,48 +294,42 @@
<figure>
<title>Component Specification, with StringValidator</title>
<programlisting>
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<!DOCTYPE page-specification PUBLIC
- "-//Howard Lewis Ship//Tapestry Specification 1.3//EN"
- "http://tapestry.sf.net/dtd/Tapestry_1_3.dtd">
-
<page-specification class="tutorial.forms.Part2">
<bean name="delegate" class="net.sf.tapestry.valid.ValidationDelegate"/>
<bean name="stringValidator" class="net.sf.tapestry.valid.StringValidator" lifecycle="page">
- <set-property name="required" expression="true"/>
- <set-property name="clientScriptingEnabled" expression="false"/>
- </bean>
+ <set-property name="required" expression="true"/>
+ <set-property name="clientScriptingEnabled" expression="false"/>
+ </bean>
<component id="form" type="Form">
- <binding name="delegate" expression="beans.delegate"/>
+ <binding name="delegate" expression="beans.delegate"/>
</component>
-
+
<component id="body" type="Body"/>
-
+
<component id="name" type="ValidField">
<binding name="value" expression="visit.userName"/>
- <binding name="validator" expression='beans.stringValidator'/>
- <static-binding name="displayName">User name</static-binding>
+ <binding name="validator" expression='beans.stringValidator'/>
+ <static-binding name="displayName">User name</static-binding>
</component>
-
+
<component id="dateOfBirth" type="ValidField">
- <binding name="value" expression="visit.dateOfBirth"/>
- <binding name="validator" expression='beans.stringValidator'/>
- <static-binding name="displayName">Date of birth</static-binding>
+ <binding name="value" expression="visit.dateOfBirthAsString"/>
+ <binding name="validator" expression='beans.stringValidator'/>
+ <static-binding name="displayName">Date of birth</static-binding>
</component>
<component id="favColour" type="ValidField">
<binding name="value" expression="visit.favoriteColour"/>
- <binding name="validator" expression='beans.stringValidator'/>
- <static-binding name="displayName">Favorite colour</static-binding>
+ <binding name="validator" expression='beans.stringValidator'/>
+ <static-binding name="displayName">Favorite colour</static-binding>
</component>
-
+
<component id="errors" type="Delegator">
<binding name="delegate" expression="beans.delegate.firstError"/>
</component>
-
+
<component id="submit" type="Submit">
<binding name="listener" expression="listeners.enterDetails"/>
</component>