Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OutputFormat according to boolean  RSS feed

 
Dylan Honorez
Ranch Hand
Posts: 30
AngularJS Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've only been busy with jsf now for a couple of weeks. I'm now trying to adjust my output according to a simple boolean.

I used to do this with <c:if> tags, but I'm looking for a more jsf-friendly way.

I tried the outputFormat, using the choice format, but that only works with numbers (integers only?). I'm looking for the same, but then for booleans. So then I wrote a converter which converts my boolean to an int. However, when I use the <f:param> tag inside my outputFormat, the converter no longer works?

What am I missing, or better, is there another jsf friendly way?

Specifying a bit more: I want to render a boolean property (true/false) to "Yes/No". But on that same page I want to render another boolean property to "subscribed/opted out".

I could make a Convertor every time I want to convert a boolean to a certain text, but that seems like a silly option.

If I could do something like


That would be awesome! Also note that I can't use a third-party JSF implementation, I want to accomplish it with the Sun Implementation.

[ April 02, 2008: Message edited by: Dylan Honorez ]
[ April 02, 2008: Message edited by: Dylan Honorez ]
 
Yasir Bajwa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haven't tested it, try

<hutputText value="#{myBean.myBooleanProperty ? 'Yes' : 'No'}" />
 
Dylan Honorez
Ranch Hand
Posts: 30
AngularJS Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha that totally works! And so simple! Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!