[Logo]
Forums Register Login
Problem using rendered attribute in Command Button
I am using rendered attribute to hide a command button

<t:commandButton styleClass="btn" id="createGrp"
immediate="true"
action="createGroup2"
value="Create Group"
rendered="#{folderBean.canManageGroups}">
</t:commandButton>


Rendering does works fine in this case.
But when the command button is clicked.it goes back to the root page.
Help...!!!
remove immediate attribute,can ypu send me jsp page i will check
I already tried by removing the immediate attribute.
But it doesnt works.
"Nitin KT",
Please check your private messages.
-Ben
Hello Nitin,

You need to have a look at your action attribute. It should be an EL expression, that should point to some method on your managed bean. It it returns nothing or null, you will be redirected back to the page the call came from.

If you have a navigation case defined in your faces config xml file, and this method returns a String that matches this navigation case, then you will be redirected to the page defined in your navigation case.
Thanks Darryl,

I have used this code in my JSP.
createGroup2 is under the navigation rule in faces-config

<t:commandButton styleClass="btn" id="createGrp"
action="createGroup2" value="Create Group"
rendered="#{folderBean.canManageGroups}" >
<t:updateActionListener property="#{group.folderId}" value="#{folderBean.folderFullPath}"/>
</t:commandButton>

The problem is that i do get the value of rendered as "true" but the action is not called.
[ June 27, 2008: Message edited by: Nitin Tonk ]
During the restore view your managed bean might return false for the EL expression "#{folderBean.canManageGroups}", so JSF cannot create <h:commandButton> component and bind the action.

Instead of rendered attribute you can use <c:if>.

For example:
<c:if test="#{folderBean.canManageGroups}">
<h:commandButton .../>
</c:if>
I just came across the same problem. I personally reckon its a bug in the spec and/or implementation as it should decode all components that were displayed originally not ones based on the state of the model at the decode phase time.

My solution was to use Tomahawk's saveState. It restores the previous value to the model so you can use it in the rendered attribute. I've got more detail here.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Oct 18, 2017 18:04:39.