Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I conditionally output text in JSF?

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Currently I have this JSF output tag:

<hutputText value='#{ConfigGridPage.appConfig}' escape='false'/>

I only want to output this text block if the a request parameter, named "ConfigAction" is equal to "load" or "save". Otherwise, I want to output an empty string. How do I do this?

Thanks, - Dave
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the 'rendered' attribute.

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A follow up question on this. Let's say if the condition is met, I want the normal outputText to be rendered, but if the condition fails, I instead want just "[]" to be output. How could I do that?

Thanks, - Dave
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two ways:


or
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic