el - Is it mandatory initialize "sub-objects" when use JSF? -


i have class called customer , called person. class customer has property person, see code bellow;

public class customer{     private string name;    private person person; } 

but when try use #{customermanagedbean.customer.person.id} got error because can't reach property id person, because person null.

so changed code to:

public class customer{     public customer{    person = new person();    }     private string name;    private person person; } 

and works fine. mandatory initialize objects inside class before using it?

yes, is. setter method invoked on final property, id. jsf, or more specifically, el, won't autocreate nested properties you. model (the backing bean) responsible that. should in fact create person in customermanagedbean class, not in customer class.

that works managed beans because managed beans via @managedbean or @named explicitly registered auto-created when not exist in el scope yet. in turn not apply nested properties.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -