Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I prevent this value from getting escaped?

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

I'm using MyFaces 1.1.6 withi Tomahawk 1.1.9 on JBoss 5.1. I have



Thing is, if the value is empty, what actually gets output is " ", but I don't want this ... I want " ". However, I do want the value of "contactInfo.organization" to be escaped. Not sure if "escaped" is the right word to use here but hopefully you know what I'm talking about.

Thanks, - Dave
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you're doing this the hard way. And I'm not 100% sure that EL supports the trinary operator, but I'm too lazy to RTFM.

Just say:
code
<hutputText value="#{contactInfo.organization}"/>
[/code]

If the property value is null or an empty string, nothing will display. Otherwise the value will display. When you said display " ", it took you at your word. Since HTML is normally insensitive to spaces, it forced a space entity ( ) to ensure that what displayed was what you told it to. Notice I didn't say "what you wanted"!
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason I asked for a " " is because the structure of the HTML is such that a blank space (" ") will cause the display to look off so I need something there in its place.

That said, I have experimented but it doesn't appear possible to do what I'm asking, unless you know an answer to the question posed.

Thanks, - Dave
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Alvarado wrote:The reason I asked for a " " is because the structure of the HTML is such that a blank space (" ") will cause the display to look off so I need something there in its place.

That said, I have experimented but it doesn't appear possible to do what I'm asking, unless you know an answer to the question posed.

Thanks, - Dave


Now I'm confused. It appears you don't want a " ", you want a " ", but I don't know the difference between " " and " ".

An outputText element should still occupy a niche, even when displaying a null string, so that wouldn't upset grid and datatable views, so I'm totally
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic