• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to display text using outputText conditionally in the DataTable

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody help me on this, please?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at 'rendered' parameter of JSF tags
<h:outputText 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: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could some one help me out with this, please?
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic