You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tauren Mills <ta...@groovee.com> on 2007/08/13 09:47:30 UTC

How to replace panelA with panelB using AjaxLink in panelA

My use case can best be described as making wicket-phonebook work
within a single tab of a tabbed panel using AjaxLink for create, edit,
and delete.

Thus, I have a page that contains a TabbedPanel.
One tab of TabbedPanel contains ContactListPanel.
ContactListPanel contains createContact link and a DataTable
DataTable contains rows of data with editContact and deleteContact links.

Clicking on one of those links should replace ContactListPanel with
ContactEditPanel or ContactDeletePanel.  I want the edit and delete
functions to still be within the tabbed interface, not on separate
pages.

I think this is close, but am not sure what is wrong:

	private void addCreateLink() {
		add(new AjaxLink("createLink") {
			@Override
			public void onClick(AjaxRequestTarget target) {
	   			Panel panel = new ContactEditPanel("panel",
	   					new Model(new Contact()));
	   			panel.setOutputMarkupId(true);
	   			getParent().replaceWith(panel);
	   			target.addComponent(panel);
			}
		});
	}

What is the proper way to replace the containing panel from a control
within that panel? I found similar questions posted on this list, but
I haven't got any of those solutions to work for me.

Thanks,
Tauren

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


Re: How to replace panelA with panelB using AjaxLink in panelA

Posted by landtuna <la...@gmail.com>.
Tauren Mills wrote:

>	add(new AjaxLink("createLink") {
>		@Override
>		public void onClick(AjaxRequestTarget target) {
>   			Panel panel = new ContactEditPanel("panel",
>   					new Model(new Contact()));
>   			panel.setOutputMarkupId(true);
>   			getParent().replaceWith(panel);
>   			target.addComponent(panel);
>		}
>	});

> What is the proper way to replace the containing panel from a 
> control within that panel? I found similar questions posted on 
> this list, but I haven't got any of those solutions to work for me.

I think you just need to do target.addComponent(getParent()) instead.  If
the parent contains too much (like the whole page), then put your Panel
inside another Panel, a Fragment, or a div tied to a WebMarkupContainer.
-- 
View this message in context: http://www.nabble.com/How-to-replace-panelA-with-panelB-using-AjaxLink-in-panelA-tf4259660.html#a12161515
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: How to replace panelA with panelB using AjaxLink in panelA

Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/13/07, Tauren Mills <ta...@groovee.com> wrote:
> My use case can best be described as making wicket-phonebook work
> within a single tab of a tabbed panel using AjaxLink for create, edit,
> and delete.
>
> Thus, I have a page that contains a TabbedPanel.
> One tab of TabbedPanel contains ContactListPanel.
> ContactListPanel contains createContact link and a DataTable
> DataTable contains rows of data with editContact and deleteContact links.
>
> Clicking on one of those links should replace ContactListPanel with
> ContactEditPanel or ContactDeletePanel.  I want the edit and delete
> functions to still be within the tabbed interface, not on separate
> pages.
>
> I think this is close, but am not sure what is wrong:
>
>         private void addCreateLink() {
>                 add(new AjaxLink("createLink") {
>                         @Override
>                         public void onClick(AjaxRequestTarget target) {
>                                 Panel panel = new ContactEditPanel("panel",
>                                                 new Model(new Contact()));
>                                 panel.setOutputMarkupId(true);
>                                 getParent().replaceWith(panel);
>                                 target.addComponent(panel);
>                         }
>                 });
>         }
> What is the proper way to replace the containing panel from a control
> within that panel? I found similar questions posted on this list, but
> I haven't got any of those solutions to work for me.

getParent.replace(panel) should work, or
ContactListPanel.this.replaceWith(panel). The difference is that
replaceWith replaces the component you call with the argument, and
replace replaces on of it's childs.

Btw, if you know which type of a containing parent you need (for
instance when you use a tagging interface) but not exactly where it
is, you can quite easily search for it by calling findParent.

Eelco

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