[jboss-user] [JBoss Seam] - Re: Seam Application Framework : association management

patrick.antivackis do-not-reply at jboss.com
Mon Jan 8 15:42:01 EST 2007


Hello Norman, thank for your time and help, so to make it clearer just let's stick to the example in chapter 14. We have the person class :

  | @Entity
  | public class Person {
  |     @Id private Long id;
  |     private String firstName;
  |     private String lastName;
  |     private Country nationality;
  |     
  |     //getters and setters...
  | }
  | 

The personHome class :

  | <h1>
  |     <h:outputText rendered="#{!personHome.managed}" value="Create Person"/>
  |     <h:outputText rendered="#{personHome.managed}" value="Edit Person"/>
  | </h1>
  | <h:form>
  |     <div>First name: <h:inputText value="#{person.firstName}"/></div>
  |     <div>Last name: <h:inputText value="#{person.lastName}"/></div>
  |     <div>
  |         <h:commandButton value="Create Person" action="#{personHome.persist}" rendered="#{!personHome.managed}"/>
  |         <h:commandButton value="Update Person" action="#{personHome.update}" rendered="#{personHome.managed}"/>
  |         <h:commandButton value="Delete Person" action="#{personHome.remove}" rendered="#{personHome.managed}"/>
  |     </div>
  | </h:form>
  | 
  | @Name("personHome")
  | public class PersonHome extends EntityHome<Person> {
  |     
  |     @In Country country;
  |     
  |     @Factory("person")
  |     public Person initPerson() { return getInstance(); }
  |     
  |     public void migrate()
  |     {
  |         getInstance().setCountry(country);
  |         update();
  |     }
  | }
  | 

A country class, let's say :

  | @Entity
  | public class Country {
  |     @Id private Long id;
  |     private String countryName;
  |     
  |     //getters and setters...
  | }
  | 
The database is populated with countries.

An entity query for the countries ;

  | <framework:entity-query name="countries" ejbql="select c from Country c"/>
  | 

The editPerson as defined in the example :

  | <h1>
  |     <h:outputText rendered="#{!personHome.managed}" value="Create Person"/>
  |     <h:outputText rendered="#{personHome.managed}" value="Edit Person"/>
  | </h1>
  | <h:form>
  |     <div>First name: <h:inputText value="#{person.firstName}"/></div>
  |     <div>Last name: <h:inputText value="#{person.lastName}"/></div>
  |     <div>
  |         <h:commandButton value="Create Person" action="#{personHome.persist}" rendered="#{!personHome.managed}"/>
  |         <h:commandButton value="Update Person" action="#{personHome.update}" rendered="#{personHome.managed}"/>
  |         <h:commandButton value="Delete Person" action="#{personHome.remove}" rendered="#{personHome.managed}"/>
  |     </div>
  | </h:form>
  | 

My question is : Is there an easy way to add a country selector in the editPerson page ?

Thank you



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3999197#3999197

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3999197



More information about the jboss-user mailing list