| Author |
Problem using rendered attribute in Command Button
|
Nitin Tonk
Greenhorn
Joined: Jun 24, 2008
Posts: 14
|
|
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...!!!
|
 |
Bhaskar GR
Greenhorn
Joined: Jun 13, 2008
Posts: 28
|
|
|
remove immediate attribute,can ypu send me jsp page i will check
|
 |
Nitin Tonk
Greenhorn
Joined: Jun 24, 2008
Posts: 14
|
|
I already tried by removing the immediate attribute. But it doesnt works.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
"Nitin KT", Please check your private messages. -Ben
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Darryl Nortje
Ranch Hand
Joined: Jun 11, 2002
Posts: 140
|
|
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.
|
 |
Nitin Tonk
Greenhorn
Joined: Jun 24, 2008
Posts: 14
|
|
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 ]
|
 |
Venkat Sadasivam
Ranch Hand
Joined: May 10, 2008
Posts: 139
|
|
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>
|
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
|
 |
Christopher Watts
Greenhorn
Joined: Jun 06, 2009
Posts: 2
|
|
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.
|
 |
 |
|
|
subject: Problem using rendered attribute in Command Button
|
|
|