when you do this:

               CSSession session = (CSSession) getSession();

               session.setUser(loggedInUser);

then that method:

CSSession.setUser(User)
{
  this.user = user;
  dirty(); <<< You have to do this here!
}

if you alter your session data you have to call dirty
Then you session wil be stored.

johan


On 6/14/07, verbal evasion <[EMAIL PROTECTED]> wrote:

yeah i got it to work. it wasnt the code, it was some maven weirdness that
was going on. i have a few more questions. currently, when i login, my
authentication mechanism tells me that i have successfully logged in, but it
seems like the session information is not stored?? i have a print in my
isVisible checks and it always says that the user variable is null. i may be
returning the incorrect ResponsePage?

// in constructor
WebMarkupContainer loggedOut = new WebMarkupContainer("loggedOut") {
            public boolean isVisible() {
                boolean rv;
                rv = ((CSSession) getSession()).getUser() == null;
                System.out.println("loggedOut - isVisible? " + rv);
                return rv;
            }
        };
...
    WebMarkupContainer loggedIn = new WebMarkupContainer("loggedIn") {
            public boolean isVisible() {
                boolean rv;
                rv = ((CSSession) getSession()).getUser() != null;
                System.out.println("loggedIn - isVisible? " + rv);

                return rv;
            }
        };
// In submit form
    public void onSubmit() {
            String userId = getUserId();
            String password = getPassword();

            User loggedInUser = null;

            try {
                loggedInUser = UserImpl.authenticate(userId, password);
                // Components can access the Session through getSession()
                CSSession session = (CSSession) getSession();

                session.setUser(loggedInUser);
                System.out.println("Logged in as " + userId);
                logger.debug("Logged in as " + userId);
                //session.get().info("Logged in as " + userId);

                //Index indexPage = new Index(userId, BasePage.this);
                //setResponsePage(indexPage);
                setResponsePage(new Index());
            } catch (AuthenticationException ae) {
                String errMsg = getLocalizer().getString(
                    "login.errors.invalidCredentials ", this);
                // Register this message with the form component.
                error(errMsg);
            }
        }

when i keep logging in, it'll say the following:

20:06:14,806 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,806 INFO  [STDOUT] loggedIn - isVisible? false
20:06:14,810 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,810 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,811 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,811 INFO  [STDOUT] loggedIn - isVisible? false
20:06:14,813 INFO  [STDOUT] loggedIn - isVisible? false
20:06:14,814 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,814 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,815 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,815 INFO  [STDOUT] loggedOut - isVisible? true
20:06:14,816 INFO  [STDOUT] loggedIn - isVisible? false

this is for *one* successful login attempt. why is the constructor run so
many times?  also, the output is wrong. what should i be returning as the
setResponsePage from the onSubmit?

thanks,

verbal




On 6/13/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>
> the form is added to loggedout container, also notice that the form tag
> is inside a div wicket:id="loggedout" so it matches the java hierarchy.
>
> -igor
>
>
> On 6/13/07, verbal evasion < [EMAIL PROTECTED]> wrote:
> >
> > i tried implementing what you had put and i am stuck because
> > "loggedin" and "form" are both in the highest scope of the websitem but in
> > the java code, you have the "form" added to the "loggedin"
> > WeMarkupContainer. that doesnt seem to fly with wicket unless i'm doing
> > something wrong. i tried to take out the html for the login form, but that
> > just doesnt make sense because there will be no corresponding html to
> > describe what should be in the webcontainer.
> >
> > this is my code snippet. thanks in advance.
> >
> >     /*
> >          * loggedOut - username and password
> >          */
> >         WebMarkupContainer loggedOut = new
> > WebMarkupContainer("loggedOut") {
> >             public boolean isVisible() {
> >                 return ((CSSession) getSession()).getUser() == null;
> >             }
> >         };
> >         TextField userIdField = new TextField("userId",
> >                 new PropertyModel(this, "userId"));
> >         PasswordTextField passField = new
> > PasswordTextField("password",
> >                 new PropertyModel(this, "password"));
> >         Form form = new LoginForm("loginForm");
> >
> >         add(loggedOut);
> >         loggedOut.add(form);
> >         form.add(userIdField);
> >         form.add(passField);
> >
> >         /*
> >          * loggedIn - username
> >          */
> >         WebMarkupContainer loggedIn = new
> > WebMarkupContainer("loggedIn") {
> >             public boolean isVisible() {
> >                 return ((CSSession) getSession()).getUser() != null;
> >             }
> >         };
> >         Label userLabel = new Label("userLabel",
> >             new PropertyModel(this, "userId"));
> >
> >         add(loggedIn);
> >         loggedIn.add(userLabel);
> >
> > ...
> >
> >             <div wicket:id="loggedIn">
> >                 <span wicket:id="userLabel"></span>
> >             </div>
> >             <div wicket:id="loggedOut">
> >             <form wicket:id="loginForm">
> >                 User Name    <input type="text"
> > wicket:id="userId"/><br/>
> >                 Password     <input type="password"
> > wicket:id="password"/><br/>
> >                 <input type="submit" value="Login"/>
> >             </form>
> >             </div>
> >
> > On 6/12/07, Eelco Hillenius < [EMAIL PROTECTED]> wrote:
> > >
> > > > <html>
> > > > <body>
> > > > <div wicket:id="loggedin"><span wicket:id="username"></div>
> > > > <div wicket:id="loggedout"><form
> > > > wicket:id="form">...</form></div>
> > > > ...
> > > >
> > > > MyPage() {
> > > >   add(new WebMarkupContainer("loggedin", new
> > > > PropertyModel(this,"session.user.username")) {
> > > >        public boolean isvisible() { return
> > > > ((MySession)getSession()).getUser()!=null; }
> > > >    }
> > > >
> > > >   WebMarkupContainer loggedout=new WebMarkupContainer("loggedout")
> > > {
> > > >        public boolean isvisible() { return
> > > > ((MySession)getSession()).getUser()==null; }
> > > >     }
> > > >  add(loggedout);
> > > >  loggedout.add(new Form("form")....
> > >
> > >
> > > That's the first option. The advantage is that it is generally
> > > easier
> > > to see what you have on your page. The other option - like shown in
> > > the templates example - is a bit cheaper memory wise, as you only
> > > add
> > > what you need.
> > >
> > > Eelco
> > >
> > >
> > > -------------------------------------------------------------------------
> > > This SF.net email is sponsored by DB2 Express
> > > Download DB2 Express C - the FREE version of DB2 express and take
> > > control of your XML. No limits. Just data. Click to get it now.
> > > http://sourceforge.net/powerbar/db2/
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to