You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexander Zotter <al...@msit.at> on 2012/03/14 13:17:55 UTC

Control panels through Ajax

 

Hi,

 

I´m trying to achieve a 4 Panel Page, which has a navigating panel (which is
a wicket tree basically) and a detailpanel which should show detail for the
selected element.

 

My problem is how to redirect the ajax target from one Panel to the other.
Are there any best practice examples, because I´ve been searching for a
while now and wasn´t able to get panelbased ajax architecture examples.

 

Thx

 


RE: Control panels through Ajax

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> I´m really new to web programming, so how should that solve my Problem? If I got it right the mediator does only know the colleagues which would be Panels in my case. But the methods of these colleague Panels are hidden because of inheritance (myPanel is child of Panel). Could you describe this solution a bit deeper?

In general terms:

class A extends Panel {

	private ABMediator mediator;

		//...
		add(new AjaxLink<Void>("theLink") {
			public void onClick(AjaxRequestTarget target) {
				mediator.callIntoB(target);
		});
	}
}

class B extends Panel {

	// ...

	public methodForTheMediator(AjaxRequestTarget target) {
		// Do something
		target.addComponent(someBComponent);
	}
}

class ABMediator {
	private A a;
	private B b;

	// ...

	public void callIntoB(AjaxRequestTarget target) {
		b. methodForTheMediator(target);
	}
}

You could also leave out passing around the target and instead get it using AjaxRequestTarget.get(). As you see, the method invoked on B is public in this case.

- Tor Iver

RE: Control panels through Ajax

Posted by saschisch87 <al...@msit.at>.
Wilhelmsen Tor Iver wrote
> 
>> My problem is how to redirect the ajax target from one Panel to the
>> other.
> 
> If Panel A needs to invoke anything in Panel B then Panel A should have a
> reference to Panel B (or to a mediator object that knows about it), and
> send the AjaxRequestTarget (which applies to the entire Page's component
> structure) so that (the mediator or) Panel B can add the required
> component to it.
> 
> http://en.wikipedia.org/wiki/Mediator_pattern
> 
> 

I´m really new to web programming, so how should that solve my Problem? If I
got it right the mediator does only know the colleagues which would be
Panels in my case. But the methods of these colleague Panels are hidden
because of inheritance (myPanel is child of Panel). Could you describe this
solution a bit deeper?

thx for your fast reply btw

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Control-panels-through-Ajax-tp4471697p4471741.html
Sent from the Users forum 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: Control panels through Ajax

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> My problem is how to redirect the ajax target from one Panel to the other.

If Panel A needs to invoke anything in Panel B then Panel A should have a reference to Panel B (or to a mediator object that knows about it), and send the AjaxRequestTarget (which applies to the entire Page's component structure) so that (the mediator or) Panel B can add the required component to it.

http://en.wikipedia.org/wiki/Mediator_pattern

- Tor Iver

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


Re: Control panels through Ajax

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I think the best approach is to share models between the panels
combined with events.
I.e. Panel A uses the model to decide which node is the selected one
in the Tree. Panel B uses the model to decide what details to show for
this node.
If Panel A has a reference to Panel B then you can just do:
target.add(panelB). But if there is no direct reference then you can
use the Event system in Wicket 1.5. See
http://www.wicket-library.com/wicket-examples/events/ for an example.
Wicket sends automatically an event with the AjaxRequestTarget as a
payload for each Ajax request. You may use it or you may fire your own
event with your own payload additionally.

On Wed, Mar 14, 2012 at 2:17 PM, Alexander Zotter
<al...@msit.at> wrote:
>
>
> Hi,
>
>
>
> I´m trying to achieve a 4 Panel Page, which has a navigating panel (which is
> a wicket tree basically) and a detailpanel which should show detail for the
> selected element.
>
>
>
> My problem is how to redirect the ajax target from one Panel to the other.
> Are there any best practice examples, because I´ve been searching for a
> while now and wasn´t able to get panelbased ajax architecture examples.
>
>
>
> Thx
>
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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