[jboss-user] [JBoss Seam] - Re: SelectOneMenu and OneToMany Seam 2.0 setup
damianharvey
do-not-reply at jboss.com
Thu Oct 18 05:04:04 EDT 2007
You really should take a look at some of the examples and read the reference. I found it *extremely* useful to use SeamGen to start with. Gives you something that works right away.
For starters, you need something to provide a list of zipcodes. In your page you have:<s:selectItems value="#{zipCodes.resultList}" var="zip" label="#{zip.zipcodeNumber}" />
But zipCodes is an entity and has no method called getResultList() or resultList(). You have 2 easy options:
1. Add an entityQuery to your components.xml<framework:entity-query name="zipCodeList"
| ejbql="select z from ZipCodes z"/>
2. Create a Bean that builds the list:
| @Name("zipCodeList")
| public class ZipCodeList() {
| @In(create=true)
| EntityManager entityManager; //actually you need to add this to your components.xml as well!
|
| public List<ZipCodes> getResultList() {
| return entityManager.createQuery("select z from ZipCodes z").getResultList();
| }
| }
And then your page should have:
<s:selectItems value="#{zipCodeList.resultList}" var="zip" label="#{zip.zipcodeNumber}" />
Don't forget to add an entityManager to your components.xml:
<persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/OracleDS"/>
Have a play with that. There are a few other things you need to fix up as well but you should find them.
Cheers,
Damian.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4096440#4096440
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4096440
More information about the jboss-user
mailing list