jsf 2 - After showing / hiding a JSF element with AJAX how to hide the triggering element? -
i followed intructions given balusc in [this answer][1]
[1]: jsf , f:ajax hiding/showing div , worked. want hide element when command button pressed , element id="incorrectquestion" shown. did in example. have tried lot of combinations couldn't hide command button.
<h:panelgroup rendered="#{not answerresultbean.showincorrectquestions}"> <div id="logindiv" style="width: 400px; text-align: left;"> <center> <f:ajax render="incorrectquestions"> <br /> <h:commandbutton value="#{strings.failedquestions}" action="#{answerresultbean.setshowincorrectquestions(true)}" /> <br /> <br /> </f:ajax> </center> </div> </h:panelgroup> <h:panelgroup id="incorrectquestions"> <h:panelgroup rendered="#{answerresultbean.showincorrectquestions}"> <div id="logindiv" style="width: 400px; text-align: left;"> ...
just put <h:panelgroup> containing button inside <h:panelgroup id="incorrectquestions"> well. way updated on ajax request , rendered condition cause hidden.
by way, try keep code dry. you've there quite code duplication.
<h:panelgroup layout="block" id="logindiv" style="width: 400px; text-align: left;"> <h:commandbutton value="#{strings.failedquestions}" action="#{answerresultbean.setshowincorrectquestions(true)}" style="text-align: center; margin: 10px;" rendered="#{not answerresultbean.showincorrectquestions}"> <f:ajax render="logindiv"> </h:commandbutton> <h:panelgroup rendered="#{answerresultbean.showincorrectquestions}"> ... </h:panelgroup> </h:panelgroup> note <h:panelgroup layout="block"> generates <div>. way there's no need <h:panelgroup><div>.
Comments
Post a Comment