Hi Andrew,
I'm answering this although I am not a developer , but I'm using click
for some time now and i find it quite nice.
Anyway, LinkDecorator handles all kind of keys (not just integers) - for
example if you check the ActionLink methods there is getValue() method
that returns string.
Second, if you want to use link decorator you must use table column
names as they are.
For example :
alpha_key Column-B Column-C ActionLink
ABC Info1 Info2 View Detail Link
DEF Info11 Info22 View Detail Link
GHI Info122 Info222 View Detail Link
AbstractLink[] links = new AbstractLink[] { actionLink };
column.setDecorator(new LinkDecorator(table, links, "alpha_key"));
Also you can write your own LinkDecorator (for example, I wrote a
MyLinkDecorator (Table table, AbstractLink[] links, String[] idProperties)
which accepts any value of arguments).
Hope that was helpful.
Regards,
Ivan
On 4.11.2011 13:25, Andrew Schoener wrote:
All,
I finally sorted out my problem and will post what I found in case it
helps someone else. In my click table, which is based on a mysql
database table, my primary key is alphanumberc, not an "ID".
Therefore, when I was using the basic link decorator like this:
actionColumn.setDecorator(new LinkDecorator(table, actionLinks,
"alpha_key"));
I was not getting the "alpha key" value in my onLinkClick method.
Therefore, I thought I was doing something wrong and went down a more
complicated road (looking at the postal code example that I mentioned
before).
Instead, I added an auto increment ID to my table to prove if that was
the missing link, and of course it was that simple. The link
decorator simply does not appear to handle alpha keys. Just
integers. (correct me if I am wrong)
This is unfortunate for me, though I can overcome it. It would have
been better to be able to have the option of an
ActionLink.getValue_*String*_
Andy
On Fri, Nov 4, 2011 at 7:59 AM, Andrew Schoener
<[email protected] <mailto:[email protected]>> wrote:
Wait... I think I may have found what I am looking for under the
LinkDecorator documentation, postal code example:
http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html
Let me give this a try. Once I get this to work, I will be really
happy about click.
Andy
On Fri, Nov 4, 2011 at 7:52 AM, Andrew Schoener
<[email protected] <mailto:[email protected]>> wrote:
Bob,
I am not sure if this is what I need. And I think I mis-typed
my initial query. What I need to know is any of the other
column's values.
For example, my table is:
Column-A Column-B Column-C ActionLink
ABC Info1 Info2 View
Detail Link
DEF Info11 Info22 View Detail
Link
GHI Info122 Info222 View Detail
Link
When I click the ActionLink, and my onLinkClick method is
trying to build a child table, I need to know the value in the
table under Column-A for the row that was clicked. In my
example above, I click the bottom table row's "View Data
Link", and in my onLinkClick method I need the value of
"GHI". It''ll be dynamic per the row clicked, not set
statically. If that makes any sense.
Andy
On Fri, Nov 4, 2011 at 12:16 AM, Bob Schellink
<[email protected] <mailto:[email protected]>> wrote:
Hi Andrew,
You can use a decorator on the column and add the column
name as a parameter to the link. For example:
final ActionLink link = new ActionLink("link");
Column column = new Column("action");
column.setDecorator(new Decorator() {
public String render(Object object, Context context) {
link.setParameter("COLUMN", "XYZ");
return link.toString();
}
});
table.addColumn(column);
Then when the link is clicked, you can retrieve the
"COLUMN" parameter which contains the name of the link
that was clicked.
Hope this helps.
Kind regards
Bob
On 2011/11/04 04:02 AM, Andrew Schoener wrote:
Newbie here, taking click for a spin.
I have:
* a page extending BorderPage
* I have on the page a Table object
* I am populating the table object with a JDBC helper
class that returns a List of the required data
* I am therefore using table.setRowList(list);
* In my table, I also have an ActionLink added as a
column. The ActionLink is called "View
Detail" on the page
What I want to do is to click the View Detail link in
the page and call a SQL statement to populate
a child Table object
However, to do so, I need to know one of the column
names from the parent table / row to build the
dynamic SQL.
And while I am at it, none of my parent table columns
are called ID.
For the life of me, I cannot figure out how to connect
the dots so that my ActionLink method (eg
"onLinkClick") can look into the columns on the row
for which the View Detail link was clicked.
Thanks
Andy