You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Joseph Schmidt <jo...@yahoo.com> on 2009/04/24 22:31:28 UTC

Tree - adding ActionLink doesn't work like PageLink :(

Hi,

Trying to add ActionLinks to a tree, similar to adding PageLinks
from this example:
http://www.avoka.com/click-examples/tree/page-link-tree-page.htm
does not work :(.
Everything is rendered nicely(with the right parameters), but the method 
specified by the ActionLink is never called :(.


thanks,
Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
>> I created in Click Examples a page - ActionLinkTreePage that is 
>> reproduction the problem you mention (see attachment - the example is 
>> based on the PageLinkTreePage).
> 
> 
>  From the example the ActionLinks are added during the rendering event 
> which occurs after the onProcess event. 
Well, I'm calling the method createTree() method in onInit (or Page 
constructor), but the PageLinkTree was the only example that allowed 
make the display the tree like desired.

> Why not use a TreeListener to 
> detect when nodes are selected or not? 
The tree component looks quite confusing, so I adopted the PageLinkTree 
example since that looked simpler and had the generated html code that 
looked at most like what it does :(.

For simplicity, for the API, I would have expected something like the 
Table API - a "Cell Decorator", where the user is responsible for 
decorating the cell (with whatever control it wants), and it's also 
responsible for those events :(.

> Alternatively you might have to 
> look at adding the ActionLinks in the Tree's onInit event so that they 
> are available during processing.
I'll try to figure out how to do it so :).

thanks,
Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Bob Schellink <sa...@gmail.com>.
Adrian A. wrote:

> I created in Click Examples a page - ActionLinkTreePage that is 
> reproduction the problem you mention (see attachment - the example is 
> based on the PageLinkTreePage).


 From the example the ActionLinks are added during the rendering event 
which occurs after the onProcess event. Why not use a TreeListener to 
detect when nodes are selected or not? Alternatively you might have to 
look at adding the ActionLinks in the Tree's onInit event so that they 
are available during processing.

kind regards

bob

Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
>> I did, but the result is the same :(.
>> In Adrian's example, if I add a public ActionLink (only one since I 
>> don't know how many would be):
>> ------
>> public ActionLink alink = new ActionLink("alink");
> 
> 
> Declare your ActionLink as in the table-decorator example which includes 
> the listener (otherwise you just redeclare the same listener for every 
> treeNode):
> 
> public ActionLink alink = new ActionLink("alink", this, "onAddClick");
> 
> This should work.
Yes, so it does work :).

I didn't declared it globally because depending on the node data there
could be different actions attached to it.

thanks,
Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Bob Schellink <sa...@gmail.com>.
Joseph Schmidt wrote:

> I did, but the result is the same :(.
> In Adrian's example, if I add a public ActionLink (only one since I 
> don't know how many would be):
> ------
> public ActionLink alink = new ActionLink("alink");


Declare your ActionLink as in the table-decorator example which 
includes the listener (otherwise you just redeclare the same listener 
for every treeNode):

public ActionLink alink = new ActionLink("alink", this, "onAddClick");

This should work.

kind regards

bob



Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
>> I think the problem is the missing of simply using the "Decorator" in 
>> these cases
>> like it's used with the pure Table:
>> http://www.avoka.com/click-examples/table/table-decorator.htm
>> Here there's also "render()" in the decorator (like in the Tree 
>> example) but it behaves like the user expects - not after onProcess.
> 
> 
> The table-decorator example is subtly different from the Tree example 
> Adrian attached. In the table-decorator the ActionLink is added as a 
> public variable, thus Click automatically adds the ActionLink as a 
> control before the onProcess method.
> 
> In the Tree example the ActionLink is added inside the render method, 
> which occurs after the onProcess method.
But only inside there I know the attributes and parameters for the 
ActionLink call, and also how many of them are :(.

> If you also add the ActionLink as a public variable in the Tree example, 
> it should work.
I did, but the result is the same :(.
In Adrian's example, if I add a public ActionLink (only one since I 
don't know how many would be):
------
public ActionLink alink = new ActionLink("alink");
-----

than instead of:
-----------
ActionLink link = new ActionLink(nodeId,nodeValue,this,"onAddClick");
-----------
I re-use that public "alink" with those attributes:
-----------
alink.setLabel(nodeValue);alink.setListener(this,"onAddClick");
// and the right params:
alink.setParameter("myParam",StringUtils.substringAfter(nodeId,"add_"));
-----------

than the result is the same :(. It's rendered how I want, but the 
desired action method is still not called :( (just like the case when 
I'm not using a public link).


thanks,
Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Bob Schellink <sa...@gmail.com>.
Joseph Schmidt wrote:
>
> I think the problem is the missing of simply using the "Decorator" in 
> these cases
> like it's used with the pure Table:
> http://www.avoka.com/click-examples/table/table-decorator.htm
> Here there's also "render()" in the decorator (like in the Tree example) 
> but it behaves like the user expects - not after onProcess.


The table-decorator example is subtly different from the Tree example 
Adrian attached. In the table-decorator the ActionLink is added as a 
public variable, thus Click automatically adds the ActionLink as a 
control before the onProcess method.

In the Tree example the ActionLink is added inside the render method, 
which occurs after the onProcess method.

If you also add the ActionLink as a public variable in the Tree 
example, it should work.

kind regards

bob

Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
> This is a very common problem, which we get a lot, people adding
> controls in the Page onRender() method. 
I suppose this is because the people have requirements(or have and idea) 
about how the HTML code should look like on the browser.
Nobody thinks/expects that onRender() is practically 
"renderAfterProcess()"/"postProcess" .

> We need to improve the
> documentation around this.  This problem usually comes up with the
> FormTable control.
I think the problem is the missing of simply using the "Decorator" in 
these cases
like it's used with the pure Table:
http://www.avoka.com/click-examples/table/table-decorator.htm
Here there's also "render()" in the decorator (like in the Tree example) 
but it behaves like the user expects - not after onProcess.

thanks,
Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Malcolm Edgar <ma...@gmail.com>.
This is a very common problem, which we get a lot, people adding
controls in the Page onRender() method. We need to improve the
documentation around this.  This problem usually comes up with the
FormTable control.

regards Malcolm Edgar

On Tue, Apr 28, 2009 at 7:28 PM, Joseph Schmidt
<jo...@yahoo.com> wrote:
>>>> Are the ActionLinks being processed?
>>>
>>> No they're not :(. The onProcess method does not appear in the logs,
>>> nor is the action method called.
>>> The PageLink of course does not need this since there's nothing to
>>> process there.
>>>
>>>> Are the  ActionLinks controls
>>>> registered with a parent container or page?
>>>
>>> Yes I added("registered" with addControl() ), the ActionLink controls to
>>> the page :(.
>>
>> I created in Click Examples a page - ActionLinkTreePage that is
>> reproduction the problem you mention (see attachment - the example is based
>> on the PageLinkTreePage).
>
> Thank you very much for the example :).
> This is looking almost like the my code that I showed you and has this
> problem.
>
> Joseph.
>
>

Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
>>> Are the ActionLinks being processed?  
>> No they're not :(. The onProcess method does not appear in the logs,
>> nor is the action method called.
>> The PageLink of course does not need this since there's nothing to 
>> process there.
>>
>>> Are the  ActionLinks controls
>>> registered with a parent container or page?
>> Yes I added("registered" with addControl() ), the ActionLink controls 
>> to the page :(.
> I created in Click Examples a page - ActionLinkTreePage that is 
> reproduction the problem you mention (see attachment - the example is 
> based on the PageLinkTreePage).
Thank you very much for the example :).
This is looking almost like the my code that I showed you and has this 
problem.

Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by "Adrian A." <a....@gmail.com>.
>> Are the ActionLinks being processed?  
> No they're not :(. The onProcess method does not appear in the logs,
> nor is the action method called.
> The PageLink of course does not need this since there's nothing to 
> process there.
> 
>> Are the  ActionLinks controls
>> registered with a parent container or page?
> Yes I added("registered" with addControl() ), the ActionLink controls to 
> the page :(.
I created in Click Examples a page - ActionLinkTreePage that is 
reproduction the problem you mention (see attachment - the example is 
based on the PageLinkTreePage).

A.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
> Are the ActionLinks being processed?  
No they're not :(. The onProcess method does not appear in the logs,
nor is the action method called.
The PageLink of course does not need this since there's nothing to 
process there.

> Are the  ActionLinks controls
> registered with a parent container or page?
Yes I added("registered" with addControl() ), the ActionLink controls to 
the page :(.

thanks,
Joseph.


Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Malcolm Edgar <ma...@gmail.com>.
Are the ActionLinks being processed?  Are the  ActionLinks controls
registered with a parent container or page?

regards Malcolm Edgar

On Mon, Apr 27, 2009 at 7:51 AM, Joseph Schmidt
<jo...@yahoo.com> wrote:
>
>> Trying to add ActionLinks to a tree, similar to adding PageLinks
>> from this example:
>> http://www.avoka.com/click-examples/tree/page-link-tree-page.htm
>> does not work :(.
>> Everything is rendered nicely(with the right parameters), but the method
>> specified by the ActionLink is never called :(.
>
> Any idea how to make that tree example work with ActionLinks too?
>
> Is it possible that those ActionLinks are not picked up by click because
> they're declared in that anonymous inner class?
>
> thanks,
> Joseph.
>
>

Re: Tree - adding ActionLink doesn't work like PageLink :(

Posted by Joseph Schmidt <jo...@yahoo.com>.
> Trying to add ActionLinks to a tree, similar to adding PageLinks
> from this example:
> http://www.avoka.com/click-examples/tree/page-link-tree-page.htm
> does not work :(.
> Everything is rendered nicely(with the right parameters), but the method 
> specified by the ActionLink is never called :(.
Any idea how to make that tree example work with ActionLinks too?

Is it possible that those ActionLinks are not picked up by click because 
they're declared in that anonymous inner class?

thanks,
Joseph.