maybe i have to add some configuration in appmodule... package ge.bog.merchants.regform.pages;
import ge.bog.merchants.exception.UserNotFoundException; import ge.bog.merchants.model.User; import ge.bog.merchants.regform.helper.Visit; import ge.bog.merchants.regform.services.IBusinessServicesLocator; import ge.bog.merchants.services.iface.IMerchantCreatorLocal; import org.apache.tapestry5.annotations.ApplicationState; import org.apache.tapestry5.annotations.OnEvent; import org.apache.tapestry5.ioc.annotations.Inject; public class Login { private String username; private String password; @Inject private IBusinessServicesLocator _businessServicesLocator; // @ApplicationState (create=false) // private User currUser; // private boolean currUserExists; @ApplicationState private Visit _visit; private boolean _visitExists; Object onActivate() { if (_visitExists) { @SuppressWarnings("unused") String blah = _visit.getMyLoginId(); } // if (currUserExists){ // String blah = currUser.getUserName(); // } return null; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @SuppressWarnings("unchecked") @OnEvent(value = "submit", component = "loginForm") public Object submitLoginForm() { Class nextPage; try { getMerchantCreator().login(username, password); User u = null; u = getMerchantCreator().getUser(); // currUser.setUserName(u.getUserName()); // currUser = u; _visit.noteLogIn(u); nextPage = ViewAllMerchants.class; } catch (UserNotFoundException e) { nextPage = Login.class; e.printStackTrace(); } return nextPage; } private IMerchantCreatorLocal getMerchantCreator() { return _businessServicesLocator.getMerchantCreatorLocal(); } } On Wed, Sep 3, 2008 at 4:29 PM, Geoff Callender < [EMAIL PROTECTED]> wrote: > I can't see anything obviously wrong. Can you post the whole Login class - > all of it. > > > On 03/09/2008, at 10:13 PM, Natia Gdzelishvili wrote: > > public class Visit { >> // The logged in user >> private boolean _loggedIn = false; >> private String _myLoginId = null; >> >> public void noteLogIn(User user) { >> _loggedIn = true; >> _myLoginId = user.getUserName(); >> >> } >> >> public void noteLogOut() { >> _loggedIn = false; >> _myLoginId = null; >> } >> >> public boolean isLoggedIn() { >> return _loggedIn; >> } >> >> public String getMyLoginId() { >> return _myLoginId; >> } >> >> } >> >> >> >> @ApplicationState >> private Visit _visit; >> private boolean _visitExists; >> >> public Object submitLoginForm() { >> Class nextPage; >> try { >> getMerchantCreator().login(username, password); >> User u = null; >> u = getMerchantCreator().getUser(); >> _visit.noteLogIn(u); >> nextPage = ViewAllMerchants.class; >> >> } catch (UserNotFoundException e) { >> nextPage = Login.class; >> e.printStackTrace(); >> } >> return nextPage; >> } >> >> On Wed, Sep 3, 2008 at 4:06 PM, Carl Crowder <[EMAIL PROTECTED]> >> wrote: >> >> Is this actually a compilation error? >>> >>> Natia Gdzelishvili wrote: >>> >>>> in version 5.0.9 it is working >>>> >>>> I've addedvist class but still same situation _visit cannot be resolved >>>> >>>> On Wed, Sep 3, 2008 at 3:44 PM, Geoff Callender < >>>> [EMAIL PROTECTED]> wrote: >>>> >>>> Fernando's right. Your field curruser starts out as an ASO but if you >>>>> reassign it (eg. curruser = u) then it becomes something else which is >>>>> >>>> not >>> >>>> an ASO. >>>>> >>>>> Your code looks like it's a mod of JumpStart, but JumpStart actually >>>>> >>>> does >>> >>>> the same kind of thing Fernando's saying: >>>>> >>>>> @ApplicationState >>>>> private Visit _visit; >>>>> private boolean _visitExists; >>>>> >>>>> <snipped> >>>>> >>>>> User user = getSecurityFinderService().authenticateUser(_loginId, >>>>> _password); >>>>> >>>>> // Store the user in the Visit >>>>> >>>>> _visit.noteLogIn(user); >>>>> >>>>> and Visit then sets its fields based on the user. That way it remains >>>>> an >>>>> ASO. >>>>> >>>>> public void noteLogIn(User user) { >>>>> _loggedIn = true; >>>>> _myUserId = user.getId(); >>>>> _myLoginId = user.getLoginId(); >>>>> } >>>>> >>>>> HTH, >>>>> >>>>> Geoff >>>>> >>>>> >>>>> >>>>> On 03/09/2008, at 7:24 PM, Fernando Padilla wrote: >>>>> >>>>> Also, i thought you were to think of an ASO almost as a singleton or a >>>>> >>>>>> service. Tapestry will create it for you on first access. I didn't >>>>>> >>>>> know >>> >>>> you could set it. Even if I'm wrong, using this design pattern might >>>>>> >>>>> clean >>> >>>> things up a little. >>>>>> >>>>>> >>>>>> So you should use another class to contain a reference to the current >>>>>> active user, call it "UserContainer". >>>>>> >>>>>> >>>>>> @AplicationState >>>>>> private UserContainer currUser; >>>>>> >>>>>> >>>>>> and it would have methods like: >>>>>> >>>>>> currUser.hasUser() >>>>>> currUser.setUser(User user) >>>>>> currUser.getUser() >>>>>> >>>>>> >>>>>> or whatever you like. >>>>>> >>>>>> >>>>>> >>>>>> José Paumard wrote: >>>>>> >>>>>> Natia, >>>>>>> I think there is a mistake in your code : >>>>>>> private User currUser ; >>>>>>> private boolean userExists ; >>>>>>> I dont think T5 will link userExists and currUser, currUser should be >>>>>>> named user, or userExists currUserExists (please correct me if I'm >>>>>>> >>>>>> wrong). >>> >>>> That said, what do you mean "I cant access currUser", do you mean that >>>>>>> the ASO is null in other classes that want to read it ? Or do you >>>>>>> mean >>>>>>> >>>>>> that >>> >>>> userExists is always false (which is normal, see above). >>>>>>> José >>>>>>> Natia Gdzelishvili a écrit : >>>>>>> >>>>>>> I'm using tapestry 5.0.14 ,i vahe problem with aso, my code is: >>>>>>>> >>>>>>>> public class Login { >>>>>>>> private String username; >>>>>>>> private String password; >>>>>>>> @Inject >>>>>>>> private IBusinessServicesLocator _businessServicesLocator; >>>>>>>> @ApplicationState >>>>>>>> private User currUser; >>>>>>>> private boolean userExists; >>>>>>>> >>>>>>>> >>>>>>>> public String getUsername() { >>>>>>>> return username; >>>>>>>> } >>>>>>>> >>>>>>>> public void setUsername(String username) { >>>>>>>> this.username = username; >>>>>>>> } >>>>>>>> >>>>>>>> public String getPassword() { >>>>>>>> return password; >>>>>>>> } >>>>>>>> >>>>>>>> public void setPassword(String password) { >>>>>>>> this.password = password; >>>>>>>> } >>>>>>>> >>>>>>>> @SuppressWarnings("unchecked") >>>>>>>> @OnEvent(value = "submit", component = "loginForm") >>>>>>>> public Object submitLoginForm() { >>>>>>>> Class nextPage; >>>>>>>> try { >>>>>>>> User u=getMerchantCreator().login(username, password); >>>>>>>> //*returns >>>>>>>> some object* >>>>>>>> currUser = u; /*/ currUser object cannot be resolved* >>>>>>>> nextPage = ViewAllMerchants.class; >>>>>>>> >>>>>>>> } catch (UserNotFoundException e) { >>>>>>>> nextPage = Login.class; >>>>>>>> e.printStackTrace(); >>>>>>>> } >>>>>>>> return nextPage; >>>>>>>> } >>>>>>>> >>>>>>>> private IMerchantCreatorLocal getMerchantCreator() { >>>>>>>> return _businessServicesLocator.getMerchantCreatorLocal(); >>>>>>>> } >>>>>>>> } >>>>>>>> >>>>>>>> i cannot access curruser... >>>>>>>> please help.. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>> >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>>>>>> For additional commands, e-mail: [EMAIL PROTECTED] >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>>>>> For additional commands, e-mail: [EMAIL PROTECTED] >>>>>> >>>>>> >>>>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >