You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Natia Gdzelishvili <ng...@gmail.com> on 2008/09/03 09:06:14 UTC

Problem with aso

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..

Re: Problem with aso

Posted by Hugo Palma <hu...@gmail.com>.
You could also add the created=false parameter to the ApplicationState 
annotation if you want to keep the assignment and not have to copy every 
field to the ASO object.

Martijn Brinkers wrote:
> Just a guess,
>
> I'm not sure, correct me if I'm wrong, but I don't think you can just
> replace the ASO like you are doing.
>
> getMerchantCreator().login probably does not return an ASO object. You
> should make a shallow copy (ie copy all relevant info) from the returned
> object to you ASO object.
>
> Martijn
>
> On Wed, 2008-09-03 at 12:56 +0400, Natia Gdzelishvili wrote:
>   
>> no
>>
>> On Wed, Sep 3, 2008 at 12:52 PM, Sven Homburg <ho...@googlemail.com>wrote:
>>
>>     
>>> any exception stack ?
>>>
>>> 2008/9/3 Natia Gdzelishvili <ng...@gmail.com>
>>>
>>>       
>>>> 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..
>>>>
>>>>         
>>>
>>> --
>>> with regards
>>> Sven Homburg
>>> http://www.chenillekit.org
>>> http://tapestry5-components.googlecode.com
>>>
>>>       
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   

Re: Problem with aso

Posted by Martijn Brinkers <ma...@gmail.com>.
Just a guess,

I'm not sure, correct me if I'm wrong, but I don't think you can just
replace the ASO like you are doing.

getMerchantCreator().login probably does not return an ASO object. You
should make a shallow copy (ie copy all relevant info) from the returned
object to you ASO object.

Martijn

On Wed, 2008-09-03 at 12:56 +0400, Natia Gdzelishvili wrote:
> no
> 
> On Wed, Sep 3, 2008 at 12:52 PM, Sven Homburg <ho...@googlemail.com>wrote:
> 
> > any exception stack ?
> >
> > 2008/9/3 Natia Gdzelishvili <ng...@gmail.com>
> >
> > > 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..
> > >
> >
> >
> >
> > --
> > with regards
> > Sven Homburg
> > http://www.chenillekit.org
> > http://tapestry5-components.googlecode.com
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
no

On Wed, Sep 3, 2008 at 12:52 PM, Sven Homburg <ho...@googlemail.com>wrote:

> any exception stack ?
>
> 2008/9/3 Natia Gdzelishvili <ng...@gmail.com>
>
> > 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..
> >
>
>
>
> --
> with regards
> Sven Homburg
> http://www.chenillekit.org
> http://tapestry5-components.googlecode.com
>

Re: Problem with aso

Posted by Sven Homburg <ho...@googlemail.com>.
any exception stack ?

2008/9/3 Natia Gdzelishvili <ng...@gmail.com>

> 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..
>



-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
can anyone help me, what I'm doing wrong...

On Wed, Sep 3, 2008 at 11:06 AM, Natia Gdzelishvili <ngdzelishvili@gmail.com
> wrote:

> 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..
>

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
no assignment cant be done
 currUser = u;  // "currUser cannot be resolved" when i;m inspecting
currUser

On Wed, Sep 3, 2008 at 1:02 PM, Hugo Palma <hu...@gmail.com> wrote:

> When you say that you can't access currUser what exactly does that mean ?
> That it's always null ?
>
>
> Natia Gdzelishvili wrote:
>
>> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem with aso

Posted by Hugo Palma <hu...@gmail.com>.
When you say that you can't access currUser what exactly does that mean 
? That it's always null ?

Natia Gdzelishvili wrote:
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 03 Sep 2008 06:24:44 -0300, Fernando Padilla <fe...@alum.mit.edu>  
escreveu:

> So you should use another class to contain a reference to the current  
> active user, call it "UserContainer".

I would call it "Session", then it could be used to hold more info about  
the user session.

Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Marcus <mv...@gmail.com>.
Hi Natia,
My suggestions:
- put the setter's on Visit class.
- remove methods noteLogIn() and noteLogOut() , when you want to logout just
attrib null to ASO, inside any page.

and try this approach:

@ApplicationState
private Visit _visit;

public Object submitLoginForm() {
       Class nextPage;
       try {
           getMerchantCreator().login(username, password);

           User u = getMerchantCreator().getUser();
           _visit.setLoggedIn = true;
           _visit.setMyLoginId = u.getUserName();

           nextPage = ViewAllMerchants.class;

       } catch (UserNotFoundException e) {
           nextPage = Login.class;
           e.printStackTrace();
       }
       return nextPage;
   }


Marcus

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
yes i've tried many times

On Wed, Sep 3, 2008 at 5:09 PM, Geoff Callender <
geoff.callender.jumpstart@gmail.com> wrote:

> Crazy thought - in your old project, if you're using Eclipse, have you
> tried Project > Clean... ?
>
>
> On 03/09/2008, at 11:05 PM, Natia Gdzelishvili wrote:
>
>  no I'm not tapestry 4 user  I'm new in tapestry
>> i thins there is some problem with my project, i've make new project anad
>> tested aso and it is working, I'll try to find out what it is
>> thank you
>>
>> On Wed, Sep 3, 2008 at 4:59 PM, Geoff Callender <
>> geoff.callender.jumpstart@gmail.com> wrote:
>>
>>  Yeah, old habits die hard.
>>>
>>>
>>> On 03/09/2008, at 10:52 PM, Thiago H. de Paula Figueiredo wrote:
>>>
>>> Em Wed, 03 Sep 2008 08:44:43 -0300, Geoff Callender <
>>>
>>>> geoff.callender.jumpstart@gmail.com> escreveu:
>>>>
>>>>       @ApplicationState
>>>>
>>>>>      private Visit _visit;
>>>>>      private boolean _visitExists;
>>>>>
>>>>>
>>>> Visit? Can I guess you were a long time Tapestry 4 user? :)
>>>>
>>>> Thiago
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem with aso

Posted by Geoff Callender <ge...@gmail.com>.
Crazy thought - in your old project, if you're using Eclipse, have you  
tried Project > Clean... ?

On 03/09/2008, at 11:05 PM, Natia Gdzelishvili wrote:

> no I'm not tapestry 4 user  I'm new in tapestry
> i thins there is some problem with my project, i've make new project  
> anad
> tested aso and it is working, I'll try to find out what it is
> thank you
>
> On Wed, Sep 3, 2008 at 4:59 PM, Geoff Callender <
> geoff.callender.jumpstart@gmail.com> wrote:
>
>> Yeah, old habits die hard.
>>
>>
>> On 03/09/2008, at 10:52 PM, Thiago H. de Paula Figueiredo wrote:
>>
>> Em Wed, 03 Sep 2008 08:44:43 -0300, Geoff Callender <
>>> geoff.callender.jumpstart@gmail.com> escreveu:
>>>
>>>        @ApplicationState
>>>>       private Visit _visit;
>>>>       private boolean _visitExists;
>>>>
>>>
>>> Visit? Can I guess you were a long time Tapestry 4 user? :)
>>>
>>> Thiago
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
no I'm not tapestry 4 user  I'm new in tapestry
i thins there is some problem with my project, i've make new project anad
tested aso and it is working, I'll try to find out what it is
thank you

On Wed, Sep 3, 2008 at 4:59 PM, Geoff Callender <
geoff.callender.jumpstart@gmail.com> wrote:

> Yeah, old habits die hard.
>
>
> On 03/09/2008, at 10:52 PM, Thiago H. de Paula Figueiredo wrote:
>
>  Em Wed, 03 Sep 2008 08:44:43 -0300, Geoff Callender <
>> geoff.callender.jumpstart@gmail.com> escreveu:
>>
>>         @ApplicationState
>>>        private Visit _visit;
>>>        private boolean _visitExists;
>>>
>>
>> Visit? Can I guess you were a long time Tapestry 4 user? :)
>>
>> Thiago
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem with aso

Posted by Geoff Callender <ge...@gmail.com>.
Yeah, old habits die hard.

On 03/09/2008, at 10:52 PM, Thiago H. de Paula Figueiredo wrote:

> Em Wed, 03 Sep 2008 08:44:43 -0300, Geoff Callender <geoff.callender.jumpstart@gmail.com 
> > escreveu:
>
>> 	@ApplicationState
>> 	private Visit _visit;
>> 	private boolean _visitExists;
>
> Visit? Can I guess you were a long time Tapestry 4 user? :)
>
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 03 Sep 2008 08:44:43 -0300, Geoff Callender  
<ge...@gmail.com> escreveu:

> 	@ApplicationState
> 	private Visit _visit;
> 	private boolean _visitExists;

Visit? Can I guess you were a long time Tapestry 4 user? :)

Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Geoff Callender <ge...@gmail.com>.
For the record, you CAN reassign an ASO (eg. curruser = u).  Don't  
know what I was thinking. Sorry if I misled anyone.

Cheers,

Geoff

On 03/09/2008, at 9:44 PM, Geoff Callender 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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>


Re: Problem with aso

Posted by Geoff Callender <ge...@gmail.com>.
I'm stumped.
When you say "can't be resolved", I'm guessing you're using debug in  
an IDE.  Which IDE?
Field u is a detached entity which may have some lazy-loaded fields.  
Is the IDE showing that?  What if you print u, _visitExists and _visit  
before and after  _visit.noteLogIn(u) ?  Are they OK? Are they null?   
Do they cause LazyInitializationException?  Of course, don't print  
_visit if _visitExists is false.

On 03/09/2008, at 10:44 PM, Natia Gdzelishvili wrote:

> 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 <
> geoff.callender.jumpstart@gmail.com> 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  
>>> <ca...@taptu.com>
>>> 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 <
>>>>> geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
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 <
geoff.callender.jumpstart@gmail.com> 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 <ca...@taptu.com>
>> 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 <
>>>> geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem with aso

Posted by Geoff Callender <ge...@gmail.com>.
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  
> <ca...@taptu.com> 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 <
>>> geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
i've solved it, thank you all for helping

On Wed, Sep 3, 2008 at 8:46 PM, Marcus <mv...@gmail.com> wrote:

> Hi Natia,
> just correcting:
>
> _visit.setMyLoginId(u.getUserName());
>
> and check Jonathan's tip. (old Tapestry libraries in your classpath.)
>
>
> Marcus
>

Re: Problem with aso

Posted by Marcus <mv...@gmail.com>.
Hi Natia,
just correcting:

_visit.setMyLoginId(u.getUserName());

and check Jonathan's tip. (old Tapestry libraries in your classpath.)


Marcus

RE: Problem with aso

Posted by Jonathan Barker <jo...@gmail.com>.
Whenever I see, "It worked in 5.0.x", my first suggestion is always to make
sure that you don't have old Tapestry libraries floating around in your
classpath.



> -----Original Message-----
> From: Natia Gdzelishvili [mailto:ngdzelishvili@gmail.com]
> Sent: Wednesday, September 03, 2008 08:14
> To: Tapestry users
> Subject: Re: Problem with aso
> 
> 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 <ca...@taptu.com>
> 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 <
> > > geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
> > >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>>>
> > >>> --------------------------------------------------------------------
> -
> > >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >>> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>>
> > >>>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
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 <ca...@taptu.com> 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 <
> > geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
> >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem with aso

Posted by Carl Crowder <ca...@taptu.com>.
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 <
> geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Marcus <mv...@gmail.com>.
Hi Natia,

Can you post ASO code?

Marcus

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
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 <
geoff.callender.jumpstart@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: Problem with aso

Posted by Geoff Callender <ge...@gmail.com>.
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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


Re: Problem with aso

Posted by Sven Homburg <ho...@googlemail.com>.
a short sample

public class UserASO<USER extends IUser>
{
    private USER userEntity;
    private Logger logger;

    public UserASO(final Logger logger)
    {
        this.logger = logger;
        logger.info("UserASO created");
    }

    public USER getUserEntity()
    {
        return userEntity;
    }

    public void setUserEntity(USER userEntity)
    {
        this.userEntity = userEntity;
    }

    public boolean isLoggedIn()
    {
        return getUserEntity() != null;
    }
}

    public static void contributeASOs(final Logger logger,
                                      @InjectService("Request")Request
request,
                                      MappedConfiguration<Class,
ApplicationStateContribution> configuration)
    {
        ApplicationStateCreator<UserASO> creator = new
ApplicationStateCreator<UserASO>()
        {
            public UserASO create()
            {
                return new VisitStateObject<User>(logger);
            }
        };

        configuration.add(UserASO.class, new
ApplicationStateContribution("session", creator));
    }

    @ApplicationState
    private UserASO userASO;

    userASO.setUser(yourUserObject);



2008/9/3 Sven Homburg <ho...@googlemail.com>

> the aso created internal by tapestry
> you should not create the object by youself
>
> aso should used as container
>
> 2008/9/3 Natia Gdzelishvili <ng...@gmail.com>
>
> I'm not using userExists,
>> in tapestry 5.0.9 everything was working, i was doing the same
>>
>> On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fe...@alum.mit.edu>
>> 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: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
>
>
>
> --
> with regards
> Sven Homburg
> http://www.chenillekit.org
> http://tapestry5-components.googlecode.com
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
ok, but why I can not make assignment?

On Wed, Sep 3, 2008 at 2:53 PM, Sven Homburg <ho...@googlemail.com>wrote:

> the aso created internal by tapestry
> you should not create the object by youself
>
> aso should used as container
>
> 2008/9/3 Natia Gdzelishvili <ng...@gmail.com>
>
> > I'm not using userExists,
> > in tapestry 5.0.9 everything was working, i was doing the same
> >
> > On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fe...@alum.mit.edu>
> > 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: users-unsubscribe@tapestry.apache.org
> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>
> > >>
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
>
>
> --
> with regards
> Sven Homburg
> http://www.chenillekit.org
> http://tapestry5-components.googlecode.com
>

Re: Problem with aso

Posted by Sven Homburg <ho...@googlemail.com>.
the aso created internal by tapestry
you should not create the object by youself

aso should used as container

2008/9/3 Natia Gdzelishvili <ng...@gmail.com>

> I'm not using userExists,
> in tapestry 5.0.9 everything was working, i was doing the same
>
> On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fe...@alum.mit.edu>
> 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: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>



-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: Problem with aso - a further query

Posted by ph...@digiatlas.org.
Quoting Hugo Palma <hu...@gmail.com>:

> You have two ways of setting the currUser DAO:
>
> 1. Copy fields from one object to another.
> Just add this to your code:
>
> currUser.setUsername(user.getUsername);
> currUser.setPassword(user.getPassword);
> .....
>
> You don't have to assign the currUser field. That will the done for you
> by Tapestry.
>
> 2. Declare the ASO like this:
>
> @ApplicationState(created=false)
> private User currUser;
>
> assign the field like this:
>
> currUser = u;
>


In which case I am getting confused reading this thread because I have  
not done it that way and it works (unlike that for the OP):


public class Index
{

...

	@ApplicationState
	private User user;

...

	Object onSubmitFromLoginForm()
	{
		Class nextPage = null;
		User authenticatedUser =  
Security.getSecurity().authenticate(userName, password, session);

		if (authenticatedUser != null)
		{

			if (authenticatedUser.getRole() == User.Role.admin)
			{
				nextPage = Administration.class;
			}

			else
			{
				nextPage = UserAdministration.class;
			}

			user= authenticatedUser;

		}
		else
...


So why does this work?  Or am I getting myself confused - to me it  
looks like my code and that of the OP work in the same way, and yet I  
can see why it shouldn't work...





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
I've made both but it doesn't work
i.ve added
${user.getUserName} and on another  page there is "merchantregform Start
PageApplicationStateManager "

On Wed, Sep 3, 2008 at 2:56 PM, Hugo Palma <hu...@gmail.com> wrote:

> You have two ways of setting the currUser DAO:
>
> 1. Copy fields from one object to another.
> Just add this to your code:
>
> currUser.setUsername(user.getUsername);
> currUser.setPassword(user.getPassword);
> .....
>
> You don't have to assign the currUser field. That will the done for you by
> Tapestry.
>
> 2. Declare the ASO like this:
>
> @ApplicationState(created=false)
> private User currUser;
>
> assign the field like this:
>
> currUser = u;
>
>
> Natia Gdzelishvili wrote:
>
>> I've tried to do this:
>> currUser=new User();
>> and then set some values but it does not work...
>>
>> On Wed, Sep 3, 2008 at 2:26 PM, Natia Gdzelishvili
>> <ng...@gmail.com>wrote:
>>
>>
>>
>>> I'm not using userExists,
>>> in tapestry 5.0.9 everything was working, i was doing the same
>>>
>>>
>>> On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fern@alum.mit.edu
>>> >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: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>

Re: Problem with aso

Posted by Hugo Palma <hu...@gmail.com>.
You have two ways of setting the currUser DAO:

1. Copy fields from one object to another.
Just add this to your code:

currUser.setUsername(user.getUsername);
currUser.setPassword(user.getPassword);
.....

You don't have to assign the currUser field. That will the done for you 
by Tapestry.

2. Declare the ASO like this:

@ApplicationState(created=false)
private User currUser;

assign the field like this:

currUser = u;

Natia Gdzelishvili wrote:
> I've tried to do this:
> currUser=new User();
> and then set some values but it does not work...
>
> On Wed, Sep 3, 2008 at 2:26 PM, Natia Gdzelishvili
> <ng...@gmail.com>wrote:
>
>   
>> I'm not using userExists,
>> in tapestry 5.0.9 everything was working, i was doing the same
>>
>>
>> On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fe...@alum.mit.edu>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: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>
>   

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
I've tried to do this:
currUser=new User();
and then set some values but it does not work...

On Wed, Sep 3, 2008 at 2:26 PM, Natia Gdzelishvili
<ng...@gmail.com>wrote:

> I'm not using userExists,
> in tapestry 5.0.9 everything was working, i was doing the same
>
>
> On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fe...@alum.mit.edu>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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: Problem with aso

Posted by Natia Gdzelishvili <ng...@gmail.com>.
I'm not using userExists,
in tapestry 5.0.9 everything was working, i was doing the same

On Wed, Sep 3, 2008 at 1:24 PM, Fernando Padilla <fe...@alum.mit.edu> 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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem with aso

Posted by Fernando Padilla <fe...@alum.mit.edu>.
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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem with aso

Posted by José Paumard <Jo...@orange.fr>.
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org