I have this on
Form1:
<h:selectOneMenu id="page" binding="#{pageList.selectedPage}"
valueChangeListener="#{pageList.changePage}" onchange="pageChanged()">
<f:selectItems value="#{pageList.selectPages}" />
</h:selectOneMenu>
<h:commandButton id="btnSubmit" value="#{msg.BTN_SEARCH_LABEL}" action="#{MyBean1.submit}"
The
changePage() method is:
public void changePage(ValueChangeEvent event)
{
String value = (String) event.getNewValue();
this.setSelectedPage(value);
FacesContext.getCurrentInstance().renderResponse();
}
The
pageChanged() event is JavaScript triggering the onclick event of the submit button (of course, I can also use onchange="submit()" - I won't go in detail here why I'm not using it):
function pageChanged() {
document.getElementById("Form1:btnSubmit").click();
}
And the
submit method of Form1 I tried to get the value of the new selected page:
Object bean1 = FacesUtil.getRequestMap("pageList");
selectedPage = ((PageListing) bean1).getSelectedPage();
The above codes do not return the new selected page value from the h:selectOneMenu - instead, it returns the previous page value. I'm a bit vague around the valueChangeListener method. Can someone enlighten me?
Edited by: icepax on 5/12/2009 17:21