Hello,
thank you for the answers.
I created my own RequestCycleListener and have another question.
public MyRequestCycleListener extends AbstractRequestCycleListener {
public onBeginRequest(RequestCycle cycle) {
super.onBeginRequest(cycle);
MyAuthenticatedSession session = (MyAuthenticatedSession)Session.get();
if (session.isSignedIn()) {
System.out.println("Is signed in");
// this is planned
// String email = session.getAuthenticatedMail();
// ObjectId userID = userDAO.getUserID(email);
// cycle.setMetaData("userID", userID);
}
else {
System.out.println("Is not signed in");
}
}
}
public MyApplication extends AuthenticatedWebApplication {
public void init() {
super.init();
IRequestCycleListener cycle = new MyRequestCycleListener();
getRequestCycleListener().add(cycle);
}
}
public MyPage extends WebPage() {
public MyPage ...
}
My question is as follows:
I load "MyPage" and the onBeginRequest method is called multiple times during
the load of the page (between 2 and 8 times) and displays the lines "Is signed
in".
I planned to store the email ID of the User in the session and load the User
data in the onBeginRequest function of the RequestCycleListener. But ... I only
want to load the User data once per request.
What do I wrong? Any help?
Thanks,
Andre
On Mon, 22 Apr 2013 11:03:43 +0530
vineet semwal <[email protected]> wrote:
> yes,you can store some key in session like emailId and then retrieve and
> store the user and related data in request cycle metadata ,as you are
> storing in requestcycle metadata ,scope of the data will be for the whole
> request only .
> no need to create your own requestcycle for that,create your requestcycle
> listener which onbeginrequest stores the user related data in requestcycle
> metadata
>
>
> On Mon, Apr 22, 2013 at 1:55 AM, Andre Schütz <[email protected]> wrote:
>
> > I plan to implement a project with AuthenticatedWebApplication. The users
> > have to sign up for an account. My question is regarding the user data that
> > I have to load during each request of the single pages.
> >
> > The project will be as follows:
> > (1) User logs into the system
> > (2) The dashboard will be loaded
> > (3) The user clicks the menu and gets a different representation of the
> > information
> >
> > I would like to know the following two things:
> >
> > (a) The user registers with his email and a password (The email is unique
> > in the database). I wanted to store the email in the
> > AuthenticatedWebSession and load the desired user data during each request
> > of a WebPage. Would that be a good idea?
> >
> > (b) I read in the documentation about the WebRequestCycle. Would it be
> > useful to implement an own WebRequestCycle for the loading of the user data?
> >
> > I hope to hear some opinions. Thanks in advance.
> > Andre
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
>
> --
> regards,
>
> Vineet Semwal
--
Andre Schütz <[email protected]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]