I am using EL expressions in my javascript code as shown below:
cur_step = #{obj1.step};
This works fine when there actually is a value inside obj1.step. However, if there is no value or is null, this is how the javascript is rendered in the browser:
cur_step = ;
This results in javascript error preventing my javascript from executing at all.
How do I fix this problem?
The obj1 object is a java bean populated on the server. FYI, I use JSF2.1 with jboss-el-2.0.jar as my EL implementation.
You could do a null check in your expression:
The empty keyword covers null and empty strings.