pass parameter in a <h:selectOneMenu>
Hello
Im working on a Jboss-Seam project with Facelets. Everything works fine but it is really hard to pass a parameter to a bean. This would be nice for using dynamic methods.
I trying to pass a parameter in a <h:selectOneMenu> section to a bean method. I tryed many different ways but it still not works.
1.
First i tried it with <f:param> and <f:setPropertyActionListener>
This solution works fine with commandButtons and commandLinks but not in a selectOneMenu.
- http://justfiveminutes.wordpress.com/2006/07/12/passing-parameters-to-links-in-facelets/
2.
My second try i startet with the el-functors library. This is very useful but didn't work in a
selectOneMenu too. i got a javax.faces.el.PropertyNotFoundException
- http://forum.java.sun.com/thread.jspa?threadID=759750&messageID=4340566
The Files:
faces-config
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/javaee
http://java.sun.com/xml/ns/web-facesconfig_1_2.xsd">
<application>
<el-resolver>
org.jboss.seam.jsf.SeamELResolver
</el-resolver>
</application>
<lifecycle>
<phase-listener>
org.jboss.seam.jsf.SeamPhaseListener
</phase-listener>
</lifecycle>
</faces-config>
The selectOneMenu section in the facelet:
<h:selectOneMenu id="test" >
<f:selectItems value="#{myBean.nameList$['bla']}"/>
</h:selectOneMenu>
and the session bean:
@Stateful
@Scope(ScopeType.SESSION)
@Name("myBean")
publicclass myBeanBeanimplements myBean{
......
public List<SelectItem> getNameList(String name){
......
}
Unfortunately this version didn't work either. But this would be the nicest solution.
So i found a third possibilty:
-http://forum.java.sun.com/thread.jspa?threadID=759079&messageID=4336534
And i also tried this but i only got a null value. It also worked with commandButtons and commandLinks but not with the selectOneMenu :(
the Files:
the selectOnMenu section in the Facelet:
<h:selectOneMenu id="test" binding="#{myBean.text}" >
<f:attribute name="att" value="test"/>
<f:selectItems value="#{myBean.items}"/>
</h:selectOneManue>
The methods in the bean:
private HtmlSelectOneMenu text;
publicvoid setText(HtmlSelectOneMenu text){
this.text = text;
String name = (String) text.getAttributes().get("att");
System.out.println(name);
}
public HtmlSelectOneMenu getText(){
return text;
}
I tryed this not only with HtmlSelectOneMenu also with:
-UIComponent
-UISelectItem
-UISelectOne
-HtmlOutputText
But it didn't work.
Any Ideas ?

