• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display text using outputText conditionally in the DataTable

 
Amitkumar Fulambarkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am iterating a list and displaying the data in the DataTable. However, The list has the objects with the boolean values. I want to display some string value depending on the boolean value in the datatable.


I tried to implement the customized convertor as below. However, my convertor doesn't get called. I don't see any error in the log too. Can someone please suggest if I am doing any wrong.



JSP:



faces-config.xml



Regards
Amit
 
Amitkumar Fulambarkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody help me on this, please?
 
Ilya Kudelin
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at 'rendered' parameter of JSF tags
<hutputText value="smth" rendered="false"/> will not be displayed at the page.
You also can use property from backing bean that has type boolean.

 
Amitkumar Fulambarkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get this.

How rendered attribute comes into picture? How is it related to Convertor? I know if we set the rendered="false" it won't render the component on UI.However, not sure how it applies to my case.

Please elaborate your views.

Thanks
Amit
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not usually worth the trouble to build a converter for boolean displays. It's easier to just provide 2 outputTexts, one for true and one for false and switch them on and off by their "rendered" attributes:


As far as your converter is concerned, I don't see anything wrong, so it may be you mis-capitalized something or made some other non-obvious mistake in the specs.
 
Ilya Kudelin
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:It's easier to just provide 2 outputTexts

Also, you can use <h:panelGroup rendered="boolean"> to hide or display a bundle of objects(links,forms,messages,ui:repeats).
 
Amitkumar Fulambarkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all.

I have some scenarios wherein I need to make the Convertor implementation working in my project. For this scenario, I dropped the idea to use Convertor. I replaced the properties in the bean from boolean to String and managed to set the values 'X' and empty string in the bean itself.

The idea to use the boolean value for rendered attribute was good. However, this doesn't applies to my case. In my case I am iterating a list and displaying the data in DataTable.
So rendered attribute will not help here.

I am still fighting with getting the convertor working for one more scenario. Here is my situation, while iterating the list, if the data for the property is null, I have to keep the column empty,however, if it is not null value I have to display as '*'.

Does the <f: Covertor> works in datatable?

Could you give me some specific pointers to cross check?

Thanks
Amit
 
Amitkumar Fulambarkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could some one help me out with this, please?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic