jsf 2 - Button action called upon second click -
i have 2 command buttons , 1 select 1 menu. need phone call bean method depending on buttons selected , selected item in menu.
<h:form id="form1"> <h:outputlabel value="menu:" /> <h:commandbutton value ="en" action="#{bean.exec}" > <f:setpropertyactionlistener target="#{bean.menu}" value='en' /> </h:commandbutton> <h:commandbutton value ="fr" action="#{bean.exec}" > <f:setpropertyactionlistener target="#{bean.menu}" value='fr' /> </h:commandbutton> <h:outputlabel value="id:" /> <h:selectonemenu value="#{bean.id}"> <f:selectitems value="#{bean.idlist}" /> <f:ajax listener="#{bean.exec}" render ="form1" /> </h:selectonemenu> </h:form>
however, although first button updates properties , calls action method, sec button gives me next message
warning: facesmessage(s) have been enqueued, may not have been displayed
and view doesn't updated on fist click. however, on sec click, properties updated , view.
how caused , how can solve it?
i did see log, dont understand error: shows: form1:j_idt124: validation error: value not valid value , where?
it's easier identify value if give input components id , attach <h:message>
them follows:
<h:outputlabel for="id" value="id:" /> <h:selectonemenu id="id" value="#{bean.id}"> <f:selectitems value="#{bean.idlist}" /> <f:ajax listener="#{bean.exec}" render ="form1" /> </h:selectonemenu> <h:message for="id" />
this way form1:id
label instead of form1:j_idt124
. alternatively, can specify label
of input component:
<h:selectonemenu label="id" ... />
as "value not valid" error, error when selected value not match 1 of available values during processing form submit. can in turn happen when property behind #{bean.idlist}
has incompatibly changed during processing form submit. can in turn happen when bean request scoped. putting bean in view scope should prepare it.
button jsf-2
No comments:
Post a Comment