Re: difference between Link(SomePage.class) and Link(new SomePage())
auron wrote: Sorry to be the wicket newbie, but I was wondering if you guys could help me to understand how Links work. I understand that when you do Link(SomePage.class), it calls the zero param constructor of SomePage, and when you do Link(new SomePage(someParams)) you can call other constructors, but besides this, what are the other differences? I assume you're talking about PageLink not Link? new PageLink(id, SomePage.class) will generate a URL which will construct a new page when you click on it. new PageLink(id, new SomePage()) obviously creates a SomePage instance right then and there. The page instance is stored in the session and dug out if the user clicks on the link. You should obviously try to create links which create new pages when you click on them, not when you construct the link (i.e. the former). For this reason, in Wicket 1.3 we've deprecated the second form as this seemed to confuse people. Instead, use a normal Link and call setResponsePage() in the onClick(). At least, then it'll be obvious what you're doing and encourage people to only construct their new pages within a click handler, rather than within the constructor for the original page. Regards, Al - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
difference between Link(SomePage.class) and Link(new SomePage())
Hey all, Sorry to be the wicket newbie, but I was wondering if you guys could help me to understand how Links work. I understand that when you do Link(SomePage.class), it calls the zero param constructor of SomePage, and when you do Link(new SomePage(someParams)) you can call other constructors, but besides this, what are the other differences? I have a LoginPage that renders a login form if the zero param constructor is called, and when LoginPage(false) is called, it signs out the user first and then renders a login page. The problem is that when I use Link(new LoginPage(false)) to sign out the user, it does indeed sign out the user, but a wicket page expired message is rendered rather than the LoginPage. public LoginPage() { this(true); } public LoginPage(boolean isLogin) { Model simpleUser = new Model(new SimpleUser()); add(new SignInForm(loginform, simpleUser)); ACPSession session = getACPSession(); if (isLogin) { if (session.isSignedIn()) { error(getLocalizer().getString(login.errors.alreadysignedin, LoginPage.this)); } } else { if (session.isSignedIn()) { info(getLocalizer().getString(login.info.signedout)); session.signOut(); //after this, Page Expired error. } } } Hope this made sense, any help is greatly appreciated. Thank you, jin -- View this message in context: http://www.nabble.com/difference-between-Link%28SomePage.class%29-and-Link%28new-SomePage%28%29%29-tf4738073.html#a13549579 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: difference between Link(SomePage.class) and Link(new SomePage())
Hey Igor - Thanks for the reply. Unfortunately I am still having some trouble finding the solution for this. I've been using nabble to search the forums and so far I cannot find anything of use (perhaps my search terms aren't effective). it seems that main problem is that when invalidating a session and calling a page that was previously within the session, the page expires, which makes sense, but I need a way to tell wicket to use a new page and new session? once this happens. The closest thing I found on the mailing list were these threads: http://www.nabble.com/Page-expiration-tf4191798.html#a11972501 http://www.nabble.com/Clearing-Session-tf4684426.html#a13452853 Any help is greatly appreciated. Thanks. igor.vaynberg wrote: search the archives for this. this is a common mistake and has been explained/corrected on this mailing list a multitude of times. -igor On 11/2/07, auron [EMAIL PROTECTED] wrote: Hey all, Sorry to be the wicket newbie, but I was wondering if you guys could help me to understand how Links work. I understand that when you do Link(SomePage.class), it calls the zero param constructor of SomePage, and when you do Link(new SomePage(someParams)) you can call other constructors, but besides this, what are the other differences? I have a LoginPage that renders a login form if the zero param constructor is called, and when LoginPage(false) is called, it signs out the user first and then renders a login page. The problem is that when I use Link(new LoginPage(false)) to sign out the user, it does indeed sign out the user, but a wicket page expired message is rendered rather than the LoginPage. public LoginPage() { this(true); } public LoginPage(boolean isLogin) { Model simpleUser = new Model(new SimpleUser()); add(new SignInForm(loginform, simpleUser)); ACPSession session = getACPSession(); if (isLogin) { if (session.isSignedIn()) { error(getLocalizer().getString(login.errors.alreadysignedin, LoginPage.this)); } } else { if (session.isSignedIn()) { info(getLocalizer().getString(login.info.signedout)); session.signOut(); //after this, Page Expired error. } } } Hope this made sense, any help is greatly appreciated. Thank you, jin -- View this message in context: http://www.nabble.com/difference-between-Link%28SomePage.class%29-and-Link%28new-SomePage%28%29%29-tf4738073.html#a13549579 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/difference-between-Link%28SomePage.class%29-and-Link%28new-SomePage%28%29%29-tf4738073.html#a13556635 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: difference between Link(SomePage.class) and Link(new SomePage())
boolean loggedIn = session.get().isSignedIn(); MySignInForm.setVisible(!loggedIn); then you can set your expired page settings to point to the page with your SignInForm hope this assists your design decision why should you invalidate a session by passing parameter to another page why not just call session.invalidate() from Link.onClick? On 11/2/07, auron [EMAIL PROTECTED] wrote: Hey Igor - Thanks for the reply. Unfortunately I am still having some trouble finding the solution for this. I've been using nabble to search the forums and so far I cannot find anything of use (perhaps my search terms aren't effective). it seems that main problem is that when invalidating a session and calling a page that was previously within the session, the page expires, which makes sense, but I need a way to tell wicket to use a new page and new session? once this happens. The closest thing I found on the mailing list were these threads: http://www.nabble.com/Page-expiration-tf4191798.html#a11972501 http://www.nabble.com/Clearing-Session-tf4684426.html#a13452853 Any help is greatly appreciated. Thanks. igor.vaynberg wrote: search the archives for this. this is a common mistake and has been explained/corrected on this mailing list a multitude of times. -igor On 11/2/07, auron [EMAIL PROTECTED] wrote: Hey all, Sorry to be the wicket newbie, but I was wondering if you guys could help me to understand how Links work. I understand that when you do Link(SomePage.class), it calls the zero param constructor of SomePage, and when you do Link(new SomePage(someParams)) you can call other constructors, but besides this, what are the other differences? I have a LoginPage that renders a login form if the zero param constructor is called, and when LoginPage(false) is called, it signs out the user first and then renders a login page. The problem is that when I use Link(new LoginPage(false)) to sign out the user, it does indeed sign out the user, but a wicket page expired message is rendered rather than the LoginPage. public LoginPage() { this(true); } public LoginPage(boolean isLogin) { Model simpleUser = new Model(new SimpleUser()); add(new SignInForm(loginform, simpleUser)); ACPSession session = getACPSession(); if (isLogin) { if (session.isSignedIn()) { error(getLocalizer().getString(login.errors.alreadysignedin, LoginPage.this)); } } else { if (session.isSignedIn()) { info(getLocalizer().getString(login.info.signedout)); session.signOut(); //after this, Page Expired error. } } } Hope this made sense, any help is greatly appreciated. Thank you, jin -- View this message in context: http://www.nabble.com/difference-between-Link%28SomePage.class%29-and-Link%28new-SomePage%28%29%29-tf4738073.html#a13549579 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/difference-between-Link%28SomePage.class%29-and-Link%28new-SomePage%28%29%29-tf4738073.html#a13556635 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]