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>
  -&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  -&lt;!-- $Id$ --&gt;
  -&lt;!DOCTYPE page-specification PUBLIC 
  -	"-//Howard Lewis Ship//Tapestry Specification 1.3//EN" 
  -	"http://tapestry.sf.net/dtd/Tapestry_1_3.dtd"&gt;
  -
   &lt;page-specification class="tutorial.forms.Part1"&gt;
   	&lt;bean name="delegate" class="net.sf.tapestry.valid.ValidationDelegate"/&gt;
   
   	&lt;component id="form" type="Form"&gt;
  -		&lt;binding name="delegate" expression="beans.delegate"/&gt;	
  +		&lt;binding name="delegate" expression="beans.delegate"/&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="name" type="TextField"&gt;
   		&lt;binding name="value" expression="visit.userName"/&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="dateOfBirth" type="TextField"&gt;
  -		&lt;binding name="value" expression="visit.dateOfBirth"/&gt;
  +		&lt;binding name="value" expression="visit.dateOfBirthAsString"/&gt;
   	&lt;/component&gt;
   
   	&lt;component id="favColour" type="TextField"&gt;
   		&lt;binding name="value" expression="visit.favoriteColour"/&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="submit" type="Submit"&gt;
   		&lt;binding name="listener" expression="listeners.enterDetails"/&gt;
   	&lt;/component&gt;
  @@ -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>
  -&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  -&lt;!-- $Id$ --&gt;
  -&lt;!DOCTYPE page-specification PUBLIC 
  -	"-//Howard Lewis Ship//Tapestry Specification 1.3//EN" 
  -	"http://tapestry.sf.net/dtd/Tapestry_1_3.dtd"&gt;
  -
   &lt;page-specification class="tutorial.forms.Part2"&gt;
   	&lt;bean name="delegate" class="net.sf.tapestry.valid.ValidationDelegate"/&gt;
   
   	&lt;bean name="stringValidator" class="net.sf.tapestry.valid.StringValidator" lifecycle="page"&gt;
  -  		&lt;set-property name="required" expression="true"/&gt;
  -  		&lt;set-property name="clientScriptingEnabled" expression="false"/&gt;
  - 	&lt;/bean&gt;
  +		  &lt;set-property name="required" expression="true"/&gt;
  +		  &lt;set-property name="clientScriptingEnabled" expression="false"/&gt;
  +	 &lt;/bean&gt;
   
   	&lt;component id="form" type="Form"&gt;
  -		&lt;binding name="delegate" expression="beans.delegate"/&gt;	
  +		&lt;binding name="delegate" expression="beans.delegate"/&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="body" type="Body"/&gt;
  -	
  +
   	&lt;component id="name" type="ValidField"&gt;
   		&lt;binding name="value" expression="visit.userName"/&gt;
  -        &lt;binding name="validator" expression='beans.stringValidator'/&gt;
  -        &lt;static-binding name="displayName"&gt;User name&lt;/static-binding&gt;
  +		&lt;binding name="validator" expression='beans.stringValidator'/&gt;
  +		&lt;static-binding name="displayName"&gt;User name&lt;/static-binding&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="dateOfBirth" type="ValidField"&gt;
  -		&lt;binding name="value" expression="visit.dateOfBirth"/&gt;
  -        &lt;binding name="validator" expression='beans.stringValidator'/&gt;
  -        &lt;static-binding name="displayName"&gt;Date of birth&lt;/static-binding&gt;
  +		&lt;binding name="value" expression="visit.dateOfBirthAsString"/&gt;
  +		&lt;binding name="validator" expression='beans.stringValidator'/&gt;
  +		&lt;static-binding name="displayName"&gt;Date of birth&lt;/static-binding&gt;
   	&lt;/component&gt;
   
   	&lt;component id="favColour" type="ValidField"&gt;
   		&lt;binding name="value" expression="visit.favoriteColour"/&gt;
  -        &lt;binding name="validator" expression='beans.stringValidator'/&gt;
  -        &lt;static-binding name="displayName"&gt;Favorite colour&lt;/static-binding&gt;
  +		&lt;binding name="validator" expression='beans.stringValidator'/&gt;
  +		&lt;static-binding name="displayName"&gt;Favorite colour&lt;/static-binding&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="errors" type="Delegator"&gt;
   		&lt;binding name="delegate" expression="beans.delegate.firstError"/&gt;
   	&lt;/component&gt;
  -	
  +
   	&lt;component id="submit" type="Submit"&gt;
   		&lt;binding name="listener" expression="listeners.enterDetails"/&gt;
   	&lt;/component&gt;