jsf - Inoperative p:commandLink when using #{param} in rendered attribute -


i have page displaying profile, it's url ../faces/savedprofile.xhtml?profileid=1234.

on page have p:pane containing few p:commandlink components, this:

<p:panel rendered="#{profilecontroller.canviewprofile}"> ...     <p:commandlink          id="duplicatelink"         value="duplicate"         action="#{profilecontroller.duplicateprofile}"/> ... </p:panel> 

it works. want add rendering condition:

<p:panel rendered="#{profilecontroller.canviewprofile         , param['profileid'] != null}"> ...     <p:commandlink          id="duplicatelink"         value="duplicate"         action="#{profilecontroller.duplicateprofile}"/> ... </p:panel> 

the p:commandlink displayed, not active. seems action method not being invoked on click. why additional rendering condition kill commandlink?

the rendered attribute not evaluated during http request returns page command link, it's evaluated during http request initiated command link. apparently you're not retaining request parameter during http request causes rendered attribute evaluates false , clicked command link cannot idenfified , hence action event never queued.

this matches point 5 of commandbutton/commandlink/ajax action/listener method not invoked or input value not updated.

the solution in case add <f:param> retain request parameter:

<p:commandlink ...>     <f:param name="profileid" value="#{param.profileid}" /> </p:commandlink> 

unrelated concrete problem, better use empty instead of != null cover empty strings:

<p:panel rendered="#{profilecontroller.canviewprofile , not empty param.profileid}"> 

or better, use <f:viewparam> in combination view scoped bean (and profile converter):

<f:viewparam name="profileid" value="#{profilecontroller.profile}" /> 

with

<p:panel rendered="#{profilecontroller.canviewprofile , not empty profilecontroller.profile}"> 

see also:


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -