• 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

El expression in JSF

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,How to validate null pointer exception in EL expression.Here is what m trying to do.I am using ui:textField tag and in text attribute isthis value

text="#{sessionScope.orderInfo.hStuff != null ? sessionScope.orderInfo.hStuff : ""}".I am gettting an error saying
"ui:textField must be followed by either atribute specifications,">" or "/>".Please help
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your actual problem is that you should use singlequotes instead of doublequotes inside the EL expression.

But actually you don't need to do nullchecks in EL. Just write out the full expression. EL won't display the value as "null" or so, just an empty string.
 
Bushra Binte
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,idid that as 'null' was displayed in the textfield.Now i changed to sinquotes,i get this error msg displyed at the top of the screen:
"com.sun.faces.el.impl.ElException: Read-only expressions can't be set"
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, that property holds a String value of "null" instead of the literal null?
 
Bushra Binte
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am afraid its not..
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Haven't seen that before.

What JSF implementation/version and which component library are you using? What application server implementation/version are you using?

Here's a small testcase which should just work on Mojarra 1.2_12 / Tomcat 6.0.18:




In none of the both cases a "null" is displayed. Just an empty string. Exactly as stated in the EL specification.
 
Saloon Keeper
Posts: 27763
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
A lot of times, a database will end up with the actual text word "null" in a column after a binding mechanism has been used to edit the table row. That happens when the display mechanism pushed the word "null" out to the user form and the user then sent it back.

There's a big difference between no value (null) and and empty string (""). Unfortunately, text editing displays usually don't handle that, and people aren't very good at it either. It's best to avoid using null in databases except in cases where null means literally "no data available". Even then, you should be prepared to handle the distinction.

The problem can be even worse for numeric fields than it is for text fields. I've dealt with systems that had major complications because the data store was designed with null numeric fields.
 
Normally trees don't drive trucks. Does this tiny ad have a license?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic