JSF 2 - Ajax - Form not completely rendered -
my ajax codes rendering form using newly-selected locale are:
<h:selectonemenu id="selectlang" immediate="true" value="#{langlisting.language}"> <f:ajax listener="#{langlisting.changelocale}" render="@form" /> <f:selectitems value="#{langlisting.languages}" /> </h:selectonemenu>
however, since above codes in in header file called header.xhtml, above codes render content of header.xhtml when switch locales between english , french. index.xhtml structure follow:
header.xhtml menu.xhtml body content id of "contentsection" footer.xhtml
how can render menu.xhtml, body section , footer.xhtml @ same time render header.xhtml?
the @form
affects content of parent <h:form>
only. use @all
instead.
<f:ajax listener="#{langlisting.changelocale}" render="@all" />
see description of render
attribute in <f:ajax>
tag documentation.
however, since changing locale affects entire page anyway, consider fire synchronous request instead of ajaxical one. achieve this, remove <f:ajax>
tag, add onchange="submit()"
dropdown , move code inside changelocale()
setlanguage()
method. see this answer concrete example.
Comments
Post a Comment