Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Problem using rendered attribute in Command Button  RSS feed

 
Greenhorn
Posts: 14
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...!!!
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
remove immediate attribute,can ypu send me jsp page i will check
 
Nitin Tonk
Greenhorn
Posts: 14
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already tried by removing the immediate attribute.
But it doesnt works.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!