Apache XML Forrest

the Apache XML site
 
   

How to build an XMLForm Wizard, Step Three

PDF
PDF

Step Three: JavaBean

HowToBean.java

Next we create the simple JavaBean which holds the data filled in the form. Each value has a set and get method. Each value must map with the form data. This is done using JXPath.

Copy the file below and save it as HowToBean.java in the folder \apache\xml-cocoon2\src\scratchpad\src\org\apache\cocoon\samples\xmlform

        
package org.apache.cocoon.samples.xmlform;

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 domain object used as a Form model.
 * Notice that it has mixed content: 
 * JavaBean properties and 
 * DOM Nodes, which are handled correctly by the
 * framework when referenced via XPath.
 *
 */

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 traditionalReciepes = true;
  private boolean soups = true;
  private boolean veganCookery = true;
  private boolean pigKeeping = true;
  private boolean pygmyGoats = true;
  private boolean henKeeping = true;
  private Node system;

  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 getTraditionalReciepes() 
    {
    return traditionalReciepes;
    }
  
  public void setTraditionalReciepes( boolean newTraditionalReciepes ) 
    {
    traditionalReciepes = newTraditionalReciepes;
    }

  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;
    }
}

        

Now we move on to Step 4:HowtoWizardAction.java

Revisions

Find a problem with this document? Consider contacting the mailing lists or submitting your own revision. For instructions, read the How To Submit a Revision.

by Heidi Brannan