jsf 2 - Problem with f:ajax in JSF requiring double clicks to execute -
i'm having same issue on few places , i'm getting frustrated.
whenever try trigger ajax event requires 2 clicks, first 1 nothing.
i've tried firing first click , manually refresh site again, nothing happens. needs 2 clicks fire event.
the below code shows simple loginform using composite. here login button requires 2 clicks fire.
the main body
<body> <h:outputscript library="js" name="topmenujs.js" /> <div class="topmenu"> <f:ajax execute="pagenavform" render=":currentmaincontent"> <h:form id="pagenavform"> <h:commandlink styleclass="selector" rendered="#{viewerrandsbean.userid.name != null}" action="#{renderhandler.showcreateissue()}" value="create errand" /> <h:commandlink styleclass="selector" rendered="#{viewerrandsbean.userid.name != null}" action="#{renderhandler.showissue()}" value="view errand" /> <h:commandlink styleclass="selector" rendered="#{viewerrandsbean.userid.admin}" action="#{renderhandler.showcreateuser()}" value="create user" /> <h:commandlink styleclass="lastselector" action="#{renderhandler.showlogin()}" value="login" /> </h:form> </f:ajax> <div style="clear:both;" /> </div> <h:panelgroup layout="block" id="currentmaincontent"> <h:panelgroup rendered="#{renderhandler.loginpanel}" id="loginpanel" layout="block"> <ui:include src="/content/login/login.xhtml"> <ui:param name="renderid" value=":pagenavform" /> </ui:include> </h:panelgroup> </h:panelgroup> </body>
and login.xhtml
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:composition> <h:outputstylesheet library="css" name="loginpagecss.css" /> <h:panelgroup class="centerbox"> <h:form> <table> <tr> <td>username</td> <td><h:inputtext value="#{viewerrandsbean.loginname}" /></td> </tr> <tr> <td>password</td> <td><h:inputsecret value="#{viewerrandsbean.loginpass}" /></td> </tr> <tr> <td> <h:commandbutton value="login" action="#{viewerrandsbean.authenticateuser()}" > <f:ajax execute="@form" render="#{renderid}" /> </h:commandbutton> </td> </tr> </table> </h:form> </h:panelgroup> </ui:composition> </html>
thanks in advance :)
-----------edit-----------
i believe i've found root of problem, i'm not sure how can fix or why there.
the problem requiring double click presents after rendering component "rendered = 'boolean'" attribute. or more specific, after goes "rendered = false", "rendered = true".
the following code works intended if rendered set true.
<h:panelgroup rendered="#{renderhandler.loginpanel}" id="loginpanel" layout="block">
here's answer not looking for: instead of using "rendered" hide login form, instead use css hide , javascript show it. you'll better response time form having go server decide show form. realize might not work other situations didn't mention.
i believe working in gray area (to of us) in interaction between jsf 2 , facelets. when ask page during ajax or post-back render new element in composition, adding jsf component tree rather being part of when built scratch. that's why see proper behaviour when set rendered true.
in combination passing parameters between parts of composition, wouldn't guarantee renderid set think when first click login.
you should able confirm outputting value of renderid using h:outputtext.
Comments
Post a Comment