JSF form problem
Hi all,
I'm pretty new to JSF and encountered a tough problem. I have a class called Shop which contains a State object (StateID & State).
Shop.class
package net.climbingrose.models;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
publicclass Shopimplements Serializable{
/** identifier field */
private Integer shopID;
/** persistent field */
private String address1;
/** nullable persistent field */
private String address2;
/** persistent field */
private String city;
/** persistent field */
private String description;
/** persistent field */
private String fax;
/** persistent field */
private String name;
/** nullable persistent field */
private String phone;
/** persistent field */
private String postCode;
/** nullable persistent field */
private String shortName;
/** persistent field */
private State state;
/** persistent field */
private String url;
/**
* Default constructor (Hibernate needs this)
*/
public Shop(){
//Intentionally left blank
}
public Shop(Integer shopID, String address1, String address2,
String city, String description, String fax,
String name, String phone, String postCode,
String shortName, State state, String url){
this.shopID = shopID;
this.address1 = address1;
this.address2 = address2;
this.city = city;
this.description = description;
this.fax = fax;
this.name = name;
this.phone = phone;
this.postCode = postCode;
this.shortName = shortName;
this.state = state;
this.url = url;
}
public Integer getShopID(){
return this.shopID;
}
publicvoid setShopID(int shopID){
this.shopID =new Integer(shopID);
}
publicvoid setShopID(Integer shopID){
this.shopID = shopID;
}
public String getAddress1(){
return this.address1;
}
publicvoid setAddress1(String address1){
this.address1 = address1;
}
public String getAddress2(){
return this.address2;
}
publicvoid setAddress2(String address2){
this.address2 = address2;
}
public String getCity(){
return this.city;
}
publicvoid setCity(String city){
this.city = city;
}
public String getDescription(){
return this.description;
}
publicvoid setDescription(String description){
this.description = description;
}
public String getFax(){
return this.fax;
}
publicvoid setFax(String fax){
this.fax = fax;
}
public String getName(){
return this.name;
}
publicvoid setName(String name){
this.name = name;
}
public String getPhone(){
return this.phone;
}
publicvoid setPhone(String phone){
this.phone = phone;
}
public String getPostCode(){
return this.postCode;
}
publicvoid setPostCode(String postCode){
this.postCode = postCode;
}
public String getShortName(){
return this.shortName;
}
publicvoid setShortName(String shortName){
this.shortName = shortName;
}
public State getState(){
return this.state;
}
publicvoid setState(State state){
this.state = state;
}
public String getUrl(){
return this.url;
}
publicvoid setUrl(String url){
this.url = url;
}
public String toString(){
returnnew ToStringBuilder(this)
.append("shopID", getShopID())
.toString();
}
}
State.java
/*
* WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
* by MyEclipse Hibernate tool integration.
*
* Created Wed Nov 23 01:45:38 EST 2005 by MyEclipse Hibernate Tool.
*/
package net.climbingrose.models;
import java.util.Collection;
/**
* A class that represents a row in the state table. You can customize the
* behavior of this class by editing the class, {@link State()}. WARNING: DO
* NOT EDIT THIS FILE. This is a generated file that is synchronized by
* MyEclipse Hibernate tool integration.
*/
publicclass State{
/**
* The cached hash code value for this instance. Settting to 0 triggers
* re-calculation.
*/
privateint hashValue = 0;
/** The composite primary key value. */
private java.lang.Integer stateID;
/** The value of the simple state property. */
private java.lang.String state;
/**
* Simple constructor of AbstractState instances.
*/
public State(){
}
/**
* Constructor of AbstractState instances given a simple primary key.
*
* @param stateid
*/
public State(java.lang.Integer stateID){
this.setstateID(stateID);
}
/**
* Return the simple primary key value that identifies this object.
*
* @return java.lang.Integer
*/
public java.lang.Integer getStateID(){
return stateID;
}
/**
* Set the simple primary key value that identifies this object.
*
* @param stateID
*/
publicvoid setstateID(java.lang.Integer stateID){
this.hashValue = 0;
this.stateID = stateID;
}
/**
* Return the value of the State column.
*
* @return java.lang.String
*/
public java.lang.String getState(){
return this.state;
}
/**
* Set the value of the State column.
*
* @param state
*/
publicvoid setState(java.lang.String state){
this.state = state;
}
/**
* Implementation of the equals comparison on the basis of equality of the
* primary key values.
*
* @param rhs
* @return boolean
*/
publicboolean equals(Object rhs){
if (rhs ==null)
returnfalse;
if (!(rhsinstanceof State))
returnfalse;
State that = (State) rhs;
if (this.getStateID() ==null || that.getStateID() ==null)
returnfalse;
return (this.getStateID().equals(that.getStateID()));
}
/**
* Implementation of the hashCode method conforming to the Bloch pattern
* with the exception of array properties (these are very unlikely primary
* key types).
*
* @return int
*/
publicint hashCode(){
if (this.hashValue == 0){
int result = 17;
int stateIDValue = this.getStateID() ==null ? 0 :this
.getStateID().hashCode();
result = result * 37 + stateIDValue;
this.hashValue = result;
}
return this.hashValue;
}
}
I have a manage bean called currentShop which I want to update via a form. Every properties (except for 'state') in Shop class is straight forward because they are of primitive types. But I'm not sure how to set up the form for users to update the state in which the shop locates.
Any idea?

