jsf - JSF2.0: ManagedProperty Lifecycle? -


i have problem don't understand: behind view have controller managedbean requestscoped , data managedbean, holds data view , sessionscoped.

so there 2 views, login logindata , logincontroller , overview overviewdata , overviewcontroller.

the functionality should that:

  • the user logs application (logincontroller method)
  • if authentication successfull, there redirect overview.xhtml (again in logincontroller method)
  • then overviewdata gets data overviewcontroller, retrieves them business logic layer
  • the overview.xhtml shows retireved data

so, point want fill overviewdata out of logincontroller, right after login! (???or if possible right befor overview view constructed, if possible???).

i tried managedproperties, 1 initiate in logincontroller different object managedproperty in overviewcontroller, although have same name! how possible.

oh boy, doubt guys understand mean, need post code:

logincontroller.java

...         @managedbean     @requestscoped     public class logincontroller {      @managedproperty(value = "#{overviewdata}")     private overviewdata overviewdata;     overviewcontroller overviewcontroller;      public logincontroller(){         overviewcontroller = new overviewcontroller ();     }      string login() throws exception {       usernamepasswordtoken token = new usernamepasswordtoken(logindata.getname(), logindata.getpw().trim());       try {       currentuser.login(token);       overviewcontroller.fillprojects(); ... 

overviewcontroller.java

...         @managedbean     @requestscoped     public class overviewcontroller {      @managedproperty(value = "#{overviewdata}")     private overviewdata overviewdata;      public void fillprojects(){       if(overviewdata == null){         overviewdata = new overviewdata();       }       overviewdata.setprojects(projectservice.getprojects()); //retrieves data business logic     } ... 

overviewdata.java

...     @managedbean(name = "overviewdata")     @sessionscoped     public class overviewdata {      private list<projectdto> projects;  //that's view needs display overview      public void setprojects(list<projectdto> projects) {       this.projects = projects;     } ... 

i hope helps show problem, if don't understand it, pls ask in comment..

would nice if can me :-)

cheers...

you're creating beans using new instead of letting jsf job.

overviewcontroller = new overviewcontroller (); 

and

overviewdata = new overviewdata(); 

this wrong. jsf won't utilize beans you've created way. remove lines , add @managedproperty on overviewcontroller inside logincontroller (and make property private).

@managedproperty(value="#{overviewcontroller}") private overviewcontroller overviewcontroller; 

jsf create bean , set managed property directly after parent bean's construction. have access usual java way (without need nullchecks).


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -