aspose file tools
The moose likes JSF and the fly likes Rendered attribute not working Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Rendered attribute not working" Watch "Rendered attribute not working" New topic
Author

Rendered attribute not working

J Miller
Ranch Hand

Joined: Oct 21, 2010
Posts: 62
I’m having a problem with the “rendered” attribute of the <hutputText> and <hutputLink> tags. Basically, the functionality I’m trying to achieve is this:

If a certain field contains something, it appears as a link. If the contents are null or empty, it should appear as text saying “N/A”.

To accomplish this, I’ve added a test to my class that checks the contents of that variable, and returns two values. One value is for the text, and one is for the link, both return either “true” or “false”. If there is something in the variable, then #{customer.customerIdText} returns "false", and #{customer.customerIdLink} returns "true". If there is nothing in the variable, then the opposite happens. Here's how my code snippet looks:



I'm currently also showing the value of the #{customer.customerIdLink} and #{customer.customerIdText} on the page, and both of them ARE returning the correct values. The problem is that nothing at all shows up on the page, neither the link OR the text. It's just blank. I've double checked with the JSF tag library, and both the [outputLink|http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/pdldocs/jsp/h/outputLink.html] and [outputText|http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/pdldocs/jsp/h/outputText.html] tags DO support the "rendered" attribute.

Any ideas why this isn't working?
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 197
You logic seems fine to me...

However, I am not familiar with Richfaces but are you sure you can put content directly inside rich:columnGroup?

Does for example this show on you page?or do you need to add a column like this
J Miller
Ranch Hand

Joined: Oct 21, 2010
Posts: 62
OK, so I got this fixed, and it was related to two things. First off, the rendered attribute must evaluate to a boolean, and I was returning a string. Second, for some reason the <rich:columnGroup> was causing problems. I changed it to a boolean, and lost the columngroup, and now it works!.

Thanks for the response!


Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 197
The returning strings would have been my second guess
I actually thought of that too since you talked about "true" and "false" instead of true and false but then I disregarded that thought since why would you return strings when the tag expects booleans. Well that just shows that I should never assume anything...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Rendered attribute not working
 
Similar Threads
Converter instances
Noob JSF question on h:selectOneMenu item.
Pass value to ManagedBean in Facelet
Help - question on selectOneListbox and page reloads
Webservices-need help