Properties specifications questions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Properties specifications questions

Vinicius Carvalho
Hello there! I've a couple of questions about this topic:

I have a login page, that after the user is logged I'd like to have
the user object available for the rest of the application (aka it's
stored on the session) a persistent property exists only for a given
page right? Well I tried the global then. My login method looks like
this:

public void authenticate(IRequestCycle cycle) {
                User user = new User();
                user.setLogin(getUsername());
                user.setPassword(getPassword());
                boolean authenticate = getUserService().authenticate(user);
                if(authenticate){
                        Map global = (Map)getGlobal();
                        global.put("user",user);
                        cycle.activate("Start");
                }
                cycle.activate("Home");
               
        }

So I go to the Start page. In my page template I'd like to have
something like this:
<span jwcid="@Insert" value="ognl:user.login"> </span>
And my start.page:
<page-specification class="net.sf.webfeeds.view.start.StartPage">
        <property-specification name="user"
type="net.sf.webfeeds.model.persistence.user.User"/>
</page-specification>
My StartPage.java
public abstract class StartPage extends BasePage {
        public User getUser(){
                return (User)((Map)getGlobal()).get("user");
        }
}
I`m getting a an error, as getUser is non abstract. Ok. Whats the
procedure here? Set it as abstract and on the method pageBeginRender
set its value?

Thanks a lot

Vinicius

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Properties specifications questions

Jamie Orchard-Hays
Global isn't where to put it--it's shared by all engine instances (it's
application, not session bound). Put it in your Visit object. That's
session bound.



Vinicius Carvalho wrote:

> Hello there! I've a couple of questions about this topic:
>
> I have a login page, that after the user is logged I'd like to have
> the user object available for the rest of the application (aka it's
> stored on the session) a persistent property exists only for a given
> page right? Well I tried the global then. My login method looks like
> this:
>
> public void authenticate(IRequestCycle cycle) {
> User user = new User();
> user.setLogin(getUsername());
> user.setPassword(getPassword());
> boolean authenticate = getUserService().authenticate(user);
> if(authenticate){
> Map global = (Map)getGlobal();
> global.put("user",user);
> cycle.activate("Start");
> }
> cycle.activate("Home");
>
> }
>
> So I go to the Start page. In my page template I'd like to have
> something like this:
> <span jwcid="@Insert" value="ognl:user.login"> </span>
> And my start.page:
> <page-specification class="net.sf.webfeeds.view.start.StartPage">
> <property-specification name="user"
> type="net.sf.webfeeds.model.persistence.user.User"/>
> </page-specification>
> My StartPage.java
> public abstract class StartPage extends BasePage {
> public User getUser(){
> return (User)((Map)getGlobal()).get("user");
> }
> }
> I`m getting a an error, as getUser is non abstract. Ok. Whats the
> procedure here? Set it as abstract and on the method pageBeginRender
> set its value?
>
> Thanks a lot
>
> Vinicius
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]