| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd"> |
| |
| <document> |
| <header> |
| <title>XMLForm Wizard's How-To Step 3</title> |
| |
| <authors> |
| <person name="Heidi Brannan" |
| email="heidi@wkwyw.net" /> |
| </authors> |
| </header> |
| |
| <body> |
| <s1 title="Step 3: Form instance model"> |
| <s2 title="HowToBean.java"> |
| <p>Next, we create the simple JavaBean which holds the data provided |
| by users on each form. Each value has a corresponding set and get |
| method. Of course, the accessors that are to be used with |
| <link href="http://jakarta.apache.org/commons/jxpath/index.html">JXPath</link> |
| need to exist in standard bean form.</p> |
| <p>Note when you run the example for the first time, default |
| values pre-populate the form. These values come directly from |
| the model bean. If users were simply editing existing information about |
| themselves, providing a model bean from persistent storage would provide the |
| expected results.</p> |
| |
| <p>Copy the file below, and save it as HowToBean.java in the folder |
| \src\java\org\apache\cocoon\samples\xmlform\howto</p> |
| |
| <source> |
| <![CDATA[ |
| package org.apache.cocoon.samples.xmlform.howto; |
| |
| import java.util.Set; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.ArrayList; |
| |
| import org.w3c.dom.*; |
| import javax.xml.parsers.*; |
| import javax.xml.transform.*; |
| |
| /** |
| * |
| * A sample JavaBean used as a Form model. |
| * |
| */ |
| |
| public class HowToBean |
| { |
| private String username = "DonaldDuck"; |
| private String email = "donald@disney.com"; |
| private String password = "secret123"; |
| private boolean organicGardening = true; |
| private boolean cooking = true; |
| private boolean smallholdingManagement = true; |
| private boolean flowers = true; |
| private boolean vegetables = true; |
| private boolean fruitTrees = true; |
| private boolean traditionalRecipes = true; |
| private boolean soups = true; |
| private boolean veganCookery = true; |
| private boolean pigKeeping = true; |
| private boolean pygmyGoats = true; |
| private boolean henKeeping = true; |
| |
| public HowToBean () |
| { |
| |
| } |
| |
| public String getUserName() { |
| return username; |
| } |
| |
| public void setUserName(String newUserName) { |
| username = newUserName; |
| } |
| |
| public String getPassword() { |
| return password; |
| } |
| |
| public void setPassword(String newPassword) { |
| password = newPassword; |
| } |
| |
| public String getEmail() { |
| return email; |
| } |
| |
| public void setEmail(String newEmail) { |
| email = newEmail; |
| } |
| |
| public boolean getOrganicGardening() |
| { |
| return organicGardening; |
| } |
| |
| public void setOrganicGardening( boolean newOrganicGardening ) |
| { |
| organicGardening = newOrganicGardening; |
| } |
| |
| public boolean getCooking() |
| { |
| return cooking; |
| } |
| |
| public void setCooking( boolean newCooking ) |
| { |
| cooking = newCooking; |
| } |
| |
| public boolean getSmallholdingManagement() |
| { |
| return smallholdingManagement; |
| } |
| |
| public void setSmallholdingManagement( boolean newSmallholdingManagement ) |
| { |
| smallholdingManagement = newSmallholdingManagement; |
| } |
| |
| public boolean getFlowers() |
| { |
| return flowers; |
| } |
| |
| public void setFlowers( boolean newFlowers ) |
| { |
| flowers = newFlowers; |
| } |
| |
| public boolean getVegetables() |
| { |
| return vegetables; |
| } |
| |
| public void setVegetables( boolean newVegetables ) |
| { |
| vegetables = newVegetables; |
| } |
| |
| public boolean getFruitTrees() |
| { |
| return fruitTrees; |
| } |
| |
| public void setFruitTrees( boolean newFruitTrees ) |
| { |
| fruitTrees = newFruitTrees; |
| } |
| |
| public boolean getTraditionalRecipes() |
| { |
| return traditionalRecipes; |
| } |
| |
| public void setTraditionalRecipes( boolean newTraditionalRecipes ) |
| { |
| traditionalRecipes = newTraditionalRecipes; |
| } |
| |
| public boolean getSoups() |
| { |
| return soups; |
| } |
| |
| public void setSoups( boolean newSoups ) |
| { |
| soups = newSoups; |
| } |
| |
| public boolean getVeganCookery() |
| { |
| return veganCookery; |
| } |
| |
| public void setVeganCookery( boolean newVeganCookery ) |
| { |
| veganCookery = newVeganCookery; |
| } |
| |
| public boolean getPigKeeping() |
| { |
| return pigKeeping; |
| } |
| |
| public void setPigKeeping( boolean newPigKeeping ) |
| { |
| pigKeeping = newPigKeeping; |
| } |
| |
| public boolean getPygmyGoats() |
| { |
| return pygmyGoats; |
| } |
| |
| public void setPygmyGoats( boolean newPygmyGoats ) |
| { |
| pygmyGoats = newPygmyGoats; |
| } |
| |
| public boolean getHenKeeping() |
| { |
| return henKeeping; |
| } |
| |
| public void setHenKeeping( boolean newHenKeeping ) |
| { |
| henKeeping = newHenKeeping; |
| } |
| } |
| ]]> |
| </source> |
| <p>Now we move on to <link href="howto-xmlform-wizard-4.html">Step 4: |
| Writing the Action</link></p> |
| </s2> |
| </s1> |
| </body> |
| </document> |