You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "marioosh.net" <ma...@gmail.com> on 2010/03/01 10:26:37 UTC

Re: Ajax refresh outer panel


marioosh.net wrote:
> 
> I have LoginPanel like below:
> 
> public class LoginPanel extends Panel {
> 
> 	public LoginPanel(String id) {	
> 		super(id);
> 
> 		MySession.get().setLoginPanel(this);
> 		this.setOutputMarkupId(true);
> 
> 		if(MySession.get().getUser() != null) {
> 			add(new LoggedPanel("panel"));
> 		} else {
> 			add(new LoggedOutPanel("panel"));
> 		}
> 	}
> }
> 
> I have save in MySession reference to this panel.
> 
> public final class MySession extends WebSession {
> 
> 	private Tuser user;
> 	private LoginPanel loginPanel;
> 	
> 	public LoginPanel getLoginPanel() {
> 		return loginPanel;
> 	}
> 
> 	public void setLoginPanel(LoginPanel loginPanel) {
> 		this.loginPanel = loginPanel;
> 	}
> 
> 	public static MySession get() {
> 		return (MySession)Session.get();
> 	}
> ...
> }
> 
> Is possible to reload LoginPanel from inner panels: LoggedPanel and
> LoggedOutPanel ?
> I have do that like below, but it doesn't reload LoginPanel:
> 
> public class LoggedOutPanel extends Panel {
> 	private final Tuser b = new Tuser();
> 
> 	public LoggedOutPanel(String id) {
> 		super(id);
> 		...
> 		AjaxSubmitLink ok = new AjaxSubmitLink("ok") {
> 			@Override
> 			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> 
> 				//ajax reload loginpanel
> 				LoginPanel lp = MySession.get().getLoginPanel();
> 				target.addComponent(lp);			
> 
> 			}
> 		};
> 		...
> 	}
> }
> 
> 
> -- 
> Greetings,
> marioosh
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

Idiscover that ajax in my example works! :) I need ONLY one hint:
Where and how do i have to put code to replacing LoggedPanel with
LoggedOutPanel and vice versa:
	if(MySession.get().getUser() != null) {
		//replace LoggedOutPanel with LoggedPanel
	} else {
                //replace LoggedPanel with LoggedOutPanel
	}

I see that i can override onRender method in WebPage class... 
Anybody help with that ?

-- 
View this message in context: http://old.nabble.com/Ajax-refresh-outer-panel-tp27721145p27741408.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Ajax refresh outer panel

Posted by Riyad Kalla <rk...@gmail.com>.
If there was a <div wicket:id="loggedState"> container in your HTML that
contained your loggedIn or loggedOut panel, then I imagine in your page code
you would have a WebMarkupContainer that you did a removeAll() on then added
the appropriate panel to it when building the page.

I imagine your loggedOut panel has a Username/Password field and a "Login"
button on it, so that'll post to the server at which point you could do that
work?

-R

On Mon, Mar 1, 2010 at 3:47 AM, Bert <ta...@gmail.com> wrote:

> If i recall correctly, then you can't change the component tree once
> the rendering started. Not 100% sure here.
>
> What i would do is to add both panels and override the isVisible()
> funktion in them. In there you check is a user
> is logged in or not ..
>
> Bert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Ajax refresh outer panel

Posted by Bert <ta...@gmail.com>.
If i recall correctly, then you can't change the component tree once
the rendering started. Not 100% sure here.

What i would do is to add both panels and override the isVisible()
funktion in them. In there you check is a user
is logged in or not ..

Bert

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