Hi Jonas, hi Cemal,

I think both of you mean similar things. So I need to attributes in my custom panel, one for the referring instance (in my case an instance of Class Index) and one for the component that I want to render (in my case AjaxFallbackDefaultDataTable). So my new custom panel looks like the one below. Agree?

Thank you for your help
Philipp

public class TermIDLinkPanel extends Panel
{
   Index indexInstance;
   Component componentInstance;
public TermIDLinkPanel(Index indexInstance, Component component, String id, final IModel model, final Item item)
   {
       super(id, model);
       this.indexInstance = indexInstance;
       this.componentInstance = component;
...
AjaxLink link = new AjaxLink("link_termID", new PropertyModel(obj, "id"))
       {
           public void onClick(AjaxRequestTarget target)
           {
               target.addComponent(componentInstance);
               Page page = target.getPage();
               //API to change the result list that shall be newly rendered
TermIDLinkPanel.this.indexInstance.updateRelationResultList();
               target.addComponent(componentInstance);
           }
       };
       add(link);
   }
}

Philipp,

I expect your page's constructor creates and adds your custom panel. So,
either make the whole panel invisible, or, if the panel hosts other widgets
that need to be shown before your AjaxLink is clicked, you can provide an
API on your panel to make the ADDT invisble/visible. This would be better
than accessing the ADDT directly (encapsulation).

Is that what you meant? If not, create the simplest possible http://wicket.apache.org/quickstart.html QuickStart (remember to delete the
target folder), zip it up and attach the zip file to your post so we can
take a look.
Regards- Cemal
http://www.jWeekend.co.uk jWeekend

Hi,

I somehow doubt this is considered good practice to let one component
know where in the component tree another component is situated.
The code you propose breaks very easily e.g. if you introduce another
container around the ADDT. Why don't you just pass the ADDT instance into
the AjaxLink?

something like:

final AjaxFallbackDefaultDataTable myADDT = ...

AjaxLink link = new AjaxLink("link", new PropertyModel(obj, "id"))
{
   public void onClick(AjaxRequestTarget target)
   {
          target.addComponent(myADDT);
  }
}


...but I'm not sure if that's a better practice. At least this doesn't
break as easily if you change the position of the ADDT in the component
tree.
Maybe a core-dev could shed some light on this issue?

cheers,
Jonas


On Tue, Jan 27, 2009 at 2:21 PM, Philipp Daumke <dau...@averbis.de> wrote:
Hi all,

I finally my error and post the working solution. I need to use a colon ":"
to find children.

AjaxLink link = new AjaxLink("link", new PropertyModel(obj, "id"))
{
   public void onClick(AjaxRequestTarget target)
   {
          Page page = target.getPage();
          AjaxFallbackDefaultDataTable myADDT=
(AjaxFallbackDefaultDataTable) page.get("tabs:panel:relTable");
          target.addComponent(myADDT);
  }
}

For "tabs", "panel" and "relTable" I put setOutputMarkupId(true);  (don't
know whether this was necessary).

Philipp
Dear Cemal,

thanks for your fast help. You understood what I meant but I still have
the problem, that I don't know how to get the instance myADDT. I tried
Page page = target.getPage();
AjaxFallbackDefaultDataTable myADDT= (AjaxFallbackDefaultDataTable)
page.get("relTable");

but get "myADDT=null". Probably because "relTable" is something like the
2nd or 3rd ancestor on that page (see below)?

Thanks for your help again
Philipp

My Main HTML-Page Index.html:
...
<span wicket:id="tabs" class="tabpanel"></span>
...

Includes this subpage Index$TabPanel1.html
<wicket:panel>
<table class="relTable" cellspacing="0"
wicket:id="relTable">[table]</table>
<(wicket:panel>


Philipp,

I'm not sure I have fully understood what you are after but it may be
that
something as straight forward as making the component to be added (ADDT)
invisible - setVisible(false) - when first added to its parent (eg the
page)
and making it visible in your AjaxLink (AL) onClick implementation.

Don't forget to setOutputMarkupPlaceholderTag(true) as well as
setOutputMarkupId(true) on your ADDT and to add the ADDT to the
AjaxRequestTarget - target.addComponent(myADDT) - in that onClick method.

Regards - Cemal
http://www.jWeekend.co.uk jWeekend

Philipp Daumke-2 wrote:

Dear all,

I look for an example how to render Wicket-Components (in my case an
AjaxDefaultDataTable) triggered by other Components (in my case AjaxLink).
In my case the two components are defined in different Java-Classes. I
looked for a while in the examples and in the wiki, but coudln't find
anything.

I appreciate your help or just a few links to some examples!
All the best
Philipp

To make a silly example, I look for something like:

class1
....
AjaxLink link = new AjaxLink("link", new PropertyModel(obj, "id"))
       {
           public void onClick(AjaxRequestTarget target)
           {
                   getComponent("myAjaxDefaultDataTable").render();
           }
       };
...

class2
...
           add(new
AjaxFallbackDefaultDataTable("myAjaxDefaultDataTable", columns,
relationProvider, 20)
           {
               {
                   setOutputMarkupId(true);
               }
           });
--

Averbis GmbH
c/o Klinikum der Albert-Ludwigs-Universität
Stefan-Meier-Strasse 26
D-79104 Freiburg

Fon: +49 (0) 761 - 203 6707
Fax: +49 (0) 761 - 203 6800
E-Mail: dau...@averbis.de

Geschäftsführer: Dr. med. Philipp Daumke, Kornél Markó
Sitz der Gesellschaft: Freiburg i. Br.
AG Freiburg i. Br., HRB 701080


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




--

Averbis GmbH
c/o Klinikum der Albert-Ludwigs-Universität
Stefan-Meier-Strasse 26
D-79104 Freiburg

Fon: +49 (0) 761 - 203 6707
Fax: +49 (0) 761 - 203 6800
E-Mail: dau...@averbis.de

Geschäftsführer: Dr. med. Philipp Daumke, Kornél Markó
Sitz der Gesellschaft: Freiburg i. Br.
AG Freiburg i. Br., HRB 701080


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



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



--

Averbis GmbH
c/o Klinikum der Albert-Ludwigs-Universität
Stefan-Meier-Strasse 26
D-79104 Freiburg

Fon: +49 (0) 761 - 203 6707
Fax: +49 (0) 761 - 203 6800
E-Mail: dau...@averbis.de

Geschäftsführer: Dr. med. Philipp Daumke, Kornél Markó
Sitz der Gesellschaft: Freiburg i. Br.
AG Freiburg i. Br., HRB 701080


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

Reply via email to