Hi WarnerJan,
The code you showed should work. The link doesn't have to be connected to the
page.
Btw Page has a "addControl" method, not an "add" method. Are you sure "this" is
a page?
I suggest you enable trace mode and see if the controls onProcess methods are called. Have you
perhaps overridden one of the containers onProcess method without calling super.onProcess?
Here is a small test to show that actions are fired for nested controls:
public class TestPage extends BorderPage {
private ActionLink myLink = new ActionLink("link", this, "onLinkClick");
public void onInit() {
C c1 = new C();
c1.setName("c1");
addControl(c1);
C c2 = new C();
c2.add(myLink);
c1.add(c2);
// Hierarchy -> c1.c2.myLink
}
public boolean onLinkClick() {
msg = "ControlListenerPage#" + hashCode()
+ " object method <tt>onLinkClick()</tt> invoked.";
return true;
}
class C extends AbstractContainer {
}
}
WarnerJan Veldhuis wrote:
Hi,
How do I go about firing actionevents for nested controls? This is my code:
8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
ActionLink first = new ActionLink("firstLink", this, "onFirst");
first.setParameter("configuration", String.valueOf(configID));
first.setImageSrc("/resources/images/icons/first.png");
navigation.add(first); //navigation = an AbstractContainer
container.add(navigation); //container = another AbstractContainer
this.add(container); // "this" is the page
>8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8
The method public boolean onFirst() is never reached.I assume it has to
do with the ActionLink not being in the Page but in a container which is
in a container. What do I do wrong here?
Cheers,
WarnerJan