• 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

NullPointerException in getter method

 
Ranch Hand
Posts: 103
jQuery Netbeans IDE Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
I am new to jsf and facing some issues dealing with it.
I am making a simple jsp file which is backed by a class.
Every Component I am using the page is bounded to some property in the backing java class.
example

and In the class


Now on the value change listener event of some other component in the same page ,
i have to update the value of this field.
I am using following code in the valueChangeListener method of the event causing component.



But I am getting NullPointerException at this line.
Please explain me how to remove this.
Also what is the difference between value and binding attribute of the jsf component?
Is it ok to bind every form component to a property in the managed bean?

Thanks in advance.
 
Saloon Keeper
Posts: 27762
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
JSF is different. I don't like to even use the term "JSP" in JSP, because the ".jsp" files in JSF aren't really JSP files, just JSF View definitions whose filename extension just happens to be ".jsp".

Binding is something that I think was required in the early days when JSF was still being designed and the documentation ended up polluting the Internet forevermore. These days, the only really good excuse for using binding is if you plan to dynamically build GUI elements on the webpage - a practice that itself is generally not encouraged. For the most part, your programming will be simpler and cleaner if you use "value=" attributes instead. You you tried, in fact, won't work, because binding is done to a JSF UIComponent object, not to a data properly. I recommend getting a good book on JSF.

Like Binding, Listeners are also used over-much. You don't need to use them to set properties. JSF will set your properties from the view directly without you needing to code anything other than a POJO property-set method in the backing bean. Listeners do have their uses, but they mostly are needed for things like updating cascaded drop-down lists of the country/state/city variety and not for simple data access.
 
Prash Singh
Ranch Hand
Posts: 103
jQuery Netbeans IDE Notepad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Tim,

Thanks for your reply.

Can you please recommend me some good book for Jsf ?


 
Tim Holloway
Saloon Keeper
Posts: 27762
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

Prash Singh wrote:Dear Tim,

Thanks for your reply.

Can you please recommend me some good book for Jsf ?




I'm not up to date on JSF books myself. I found Kito Mann's JSF in action to be good myself.

And for the benefit of those I've confused even more than usual,


I don't like to even use the term "JSP" in JSP



should have been


I don't like to even use the term "JSP" in JSF



 
reply
    Bookmark Topic Watch Topic
  • New Topic