Unable to get the Value of ComboBox
badeddin Aug 24, 2011 6:15 PMHello, I have a table QuestionReponse and it contains an Object Reponse which representes a foreign key to the Table Reponse, I want to use a ComboBox to choose the Reponse object to put it in the QuestionReponse Table.
There is the code I used for the ComboBox
<h:selectOneMenu value="#{selectedReponse}" id="selectedReponse"
style=" width : 303px;">
<f:selectItem itemLabel="#{questionreponseHome.instance.reponse}"
itemValue="" />
<s:selectItems value="#{reponseAction.initReponseToTrack()}"
var="_reponse" label="#{_reponse.reponse}" />
<s:convertEntity />
<a:support event="onchange" action="#{reponseAction.test()}" />
</h:selectOneMenu>And for the bean there is the code:
@Scope(ScopeType.PAGE)
@Name("reponseAction")
public class ReponseActionBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4083573734422505830L;
@In(create = true)
private ReponseList reponseList;
@In(create = true)
ReponseHome reponseHome;
@In(create = true)
QuestionreponseHome questionreponseHome;
@DataModel
private List<Reponse> reponseToTrack = new ArrayList<Reponse>();
@Out(required = false)
@In(required = false)
@Logger private Log log;
private Reponse selectedReponse = new Reponse();
@Factory("reponseToTrack")
public List<Reponse> initReponseToTrack() {
reponseToTrack = reponseList.getResultList();
System.out.println("initReponseToTrack");
return reponseToTrack;
}
public Reponse getSelectedReponse() {
System.out.println("Get Selected Reponse");
if (this.selectedReponse != null) {
log.info(">>>>> get getSelectedReponse selectedReponse = "
+ this.selectedReponse.getReponse());
}
return this.selectedReponse;
}
public void setSelectedReponse(Reponse reponse) {
System.out.println("Set Selected Reponse");
this.selectedReponse = reponse;
}
public void test() {
System.out.println("test");
System.out.println(selectedReponse == null ? "null" : selectedReponse.getIdreponse());
reponseHome.getInstance().setIdreponse(selectedReponse.getIdreponse());
}
}
I noticed that in each call of the Test Method
selectedReponse is null.
Please help me, I can't go forward in my project without your help.
Thank You