-
1. Re: selectOneMenu Example
niox.nikospara.yahoo.com Aug 11, 2009 4:13 PM (in response to aigleborgne)Hello,
The usage of <s:selectItems> seems suspicious:
The component and the iteration variable both have the same name
pays
. Could you change the name of one (e.g. the iteration variable) and see what happens, just in case...Additionally, you outject the list field of the pays component but access it through pays: #{pays.list}. This is redundant (I suggest you change the select items to: <s:selectItems value="#{list}" .../>).
Last, from the code it seems that the signature of #{individuAction.idpays} should be:
public void setIdpays(ReferentielpaysBO x) {...} public ReferentielpaysBO getIdpays() {...}
I.e. idpays is a property of type ReferentielpaysBO, same as the list.
-
2. Re: selectOneMenu Example
aigleborgne Aug 11, 2009 4:52 PM (in response to aigleborgne)Thanks for help. I have changed my code following your instructions but it doesn't work. I have another error through.
JSF:
<h:selectOneMenu id="selectPays" value="#{individuAction.idpays}"> <s:selectItems value="#{listePays}" var="pay" label="#{pay.libpays}"/> <s:convertEntity /> </h:selectOneMenu>
Bean:
@Name("pays") @Scope(ScopeType.APPLICATION) public class PaysList implements java.io.Serializable { private static final long serialVersionUID = -7402234629771271315L; @In("#{referenceService}") protected ReferenceService referenceService; @Out private List<ReferentielpaysBO> listePays; @Factory("listePays") public List<ReferentielpaysBO> getListePays() { this.listePays = referenceService.retrievePays(); return this.listePays; } public void setListePays(List<ReferentielpaysBO> listePays) { this.listePays = listePays; } }
I have renamed list to listePays. I guess @Out contexts have to be unique. So listePays is more explicit than list.
In my JSF, I just refer to listePays as you suggested.Relating to stored value, I'll see later. It should print my menu at least (I've tried with some selectItem and it worked.)
My final goal is to stored selected country into people bean (individuAction). indivduAction is a bean used to view and edit IndividuadresseBO. But I haven't finished this part yet. I'm starting with simple things like oneMenuSelect...
For information, here is the BO:
@Entity @Table(name = "INDIVIDUADRESSE") @NamedQueries({ @NamedQuery( name=ALL, query="from IndividuadresseBO") }) @Name("individuadresseBO") public class IndividuadresseBO implements java.io.Serializable { public class QN{ public static final String ALL = "IndividuadresseBO.all"; } private static final long serialVersionUID = 1L; @Id @Column(name = "IDINDIVIDU" , nullable=false) private Long idindividu; ... @ManyToOne @JoinColumn(name="IDPAYS") @ForeignKey(name="FK_INDADRESSE_REFPAYS") @Fetch(FetchMode.JOIN) private ReferentielpaysBO pays;
-
3. Re: selectOneMenu Example
aigleborgne Aug 11, 2009 4:55 PM (in response to aigleborgne)I forgot to print my new error:
Could not instantiate Seam component: org.jboss.seam.ui.entityLoader
In console:
Can not set static javassist.util.proxy.MethodFilter field org.jboss.seam.ui.JpaEntityLoader_$$_javassist_seam_10._method_filter to org.jboss.seam.Component$1
Can not set static javassist.util.proxy.MethodFilter field org.jboss.seam.ui.JpaEntityLoader_$$_javassist_seam_10._method_filter to org.jboss.seam.Component$1
-
4. Re: selectOneMenu Example
aigleborgne Aug 12, 2009 7:37 AM (in response to aigleborgne)Nobody can help me on this?
If I could have find somewhere a working example of a selectOneMenu...
I tried this example : http://maniezhilan.blogspot.com/2008/11/seam-framework-cheat-sheets-2.html
But it doesn't work! -
5. Re: selectOneMenu Example
niox.nikospara.yahoo.com Aug 12, 2009 9:26 AM (in response to aigleborgne)Hello again,
Have you completed the settings required for <s:convertEntity> in components.xml, as described in ch.32 of the documentation? Could you show the relevant code?
Could you show the code of the individuAction component, especially the part related to idpays?
-
6. Re: selectOneMenu Example
aigleborgne Aug 12, 2009 9:56 AM (in response to aigleborgne)It worked!
You was right about s:convertEntity. I have read nowhere that I needed to set components.xml.
In fact, Seam is meant to have very little xml configuration... But I admit that I haven't read documentation yet.So, I've just removed convertEntity and it worked immediatly :)
A big thank you for your precious help!
-
7. Re: selectOneMenu Example
aigleborgne Aug 17, 2009 5:35 PM (in response to aigleborgne)I'm still having problems with selectOneMenu.
As said in my last post, my list is now working : I can load my page without any error, and the list is working as intended.
But if I select something and validate, I get this error:
Erreur de conversion quand la valeur com.pndata.pnasso.business.bo.ReferentielpaysBO@2b9789b9 est commise pour le modele null Converter.
(in english, something like Converting error when value ... is commited for model ...
I suppose I need to add <s:convertEntity /> to my selectOneMenu but well, I had this error when added:
Could not instantiate Seam component: org.jboss.seam.ui.entityLoader
I have followed this:
http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html_single/#controls
Read many posts relating to this problem, but I can't manage to solve this.
My entity manager is declared in my service:
@PersistenceContext
private EntityManager em;
I guess I will use an id instead of object for the value, so no converter are needed... -
8. Re: selectOneMenu Example
jamesjmp Aug 18, 2009 11:26 AM (in response to aigleborgne)Have you tried with a new converter? (not s:convertEntity) but a new one special for you type, and then use it this way inside h:selectOneMenu code block:
<f:converter converterId="project.yourConverter"/>
And don´t forget to configure it in faces-config.xml
-
9. Re: selectOneMenu Example
lvdberg Aug 18, 2009 1:15 PM (in response to aigleborgne)Hi Arnaud,
Be aware that Seam intercepts stuff with the @In annotation, meaning that a refernce to Entitymanagere annotated with @PersistenceContext is NOT handled by Seam but by the ejb-container.
Try changing the anntoation to @In and see if that helps. The convertEntity seam.tag is very usefull if you want direct entityhandling in your pages.