This content has been marked as final.
Show 5 replies
-
1. Re: Seam Application Framework : association management
norman.richards Jan 8, 2007 12:29 PM (in response to patrick.antivackis)Here's one way to get started, I suppose. In general, I think you'd want to combine an EntityQuery with an EntityHome though, and not mess about with manually managing it like this.
@Name("fooList") public class FooList extends EntityQuery { @DataModelSelection Foo selectedFoo; @DataModel public List getAllFoo() { return super.getResultList(); } public void actOnSelected() { .... use selectedFoo } }
-
2. Re: Seam Application Framework : association management
patrick.antivackis Jan 8, 2007 3:42 PM (in response to patrick.antivackis)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 -
3. Re: Seam Application Framework : association management
atzbert Jan 8, 2007 5:06 PM (in response to patrick.antivackis)In fact there is a very convenient way to realize this. by using the http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamSelectItemsNewDesign component.
<si:selectItems value="#{countries.resultList}" var="country" label="#{country.countryName}" noSelectionLabel="Select One..."/>
:)
ps: I guess I don't know how to use the url formatter correctly...it always prints the url instead of the text I entered in the tag :/ -
4. Re: Seam Application Framework : association management
atzbert Jan 8, 2007 5:12 PM (in response to patrick.antivackis)I forgot..., u probably wanna surround the si:selectitems with a h:selectone or smth similar:
<h:selectOneMenu value="#{person.country}" > <si:selectItems value="#{countries.resultList}" var="country" label="#{country.countryName}" noSelectionLabel="Select One..."/> </h:selectOneMenu>
:P -
5. Re: Seam Application Framework : association management
patrick.antivackis Jan 10, 2007 4:46 AM (in response to patrick.antivackis)Thanks Atzbert, your link to the selectItems was great, have example using the framewrok inside. Just what i was looking for