• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Special Characters '&' and ':'

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Whenever there are characters such as '&' or ':' that are stored in the attributes of beans which are string arrays, they won't display in a JSF (1.2 Mojarra) page.
In fact, the entire h:dataTable will not get rendered. I'm not seeing any exceptions thrown in my Tomcat 6.0.20 logs either.

I know that when the data are stored in my beans that the special characters are in there, via println() statements.

In this "beanName" example, the ADDRESS field sometimes contains addresses that are the intersections of two roads, such as: 1st & Washington. When this particular search ocurrs, no results are rendered for this dataTable and I'm of the opinion it has something to do with the '&' character. When I change the underlying data and replace '&' with the word "and", the record is displayed.

Strangely, I can output the '&' and ':' characters to the page as strings, but not via the beanName.attribute in a method binding statement.

Why is that?




private BACasemap[] bacasemaprecord;

 
Saloon Keeper
Posts: 28486
210
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
There are 5 "magic" characters in XML, and they apply here. Those characters are "& ' " < >". You can't use these magic characters directly because they're ambiguous in terms of the XML meta-language, so you'll usually need to use entity objects in their place. The equivalent entity definitions are "&amp; &apos; &quot; &lt; &gt;". Note the terminating semicolons - they're critical.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This means we cannot use any editable fields for displaying them properly?
 
Tim Holloway
Saloon Keeper
Posts: 28486
210
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

dwarakanathan thiru wrote:This means we cannot use any editable fields for displaying them properly?



I think that they're discussing that over in this thread: https://coderanch.com/t/488943/JSF/java/Usage-inputTextarea-JSF . But if you mean "can you enter a text such as 'Savings & Loan' in an ordinary textinput control?", that's not a problem and you don't need to so anything special.
 
author
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Most JSF components have an escape attribute. If you set that to false, the "magic" characters will be displayed as expected.

Best regards,
Bart
 
dwarakanathan thiru
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim,
I have a text field and drop down. On change of the drop down, I wanted to populate the text area. I can very well past MANDARIN in a text area, but its the way it is populated is tricky.

If at all the "&" was not getting converted to "& A M P ;" in my JSP file, the chinese character would have displayed properly on populate.

Bart,
I agree. But for inputTextArea this attribute is not present.

 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic