Makes sense now :)

regards

Bob



On 2011/11/04 19:04 PM, Andrew Schoener wrote:
Guys and gals,

Would you believe that it is case sensitive?  Here's the deal:

  * in mysql in the talbe ddl, my id column is lower case
  * but my ALPHA_KEY is upper case

Therefore, when I was doing:
LinkDecorator ld = new LinkDecorator(table, actionLinks, "alpha_key");
it was returning null because the prop name is upper case, and my code should 
be:
LinkDecorator ld = new LinkDecorator(table, actionLinks, "ALPHA_KEY");

I knew it was going to be something silly.  Thanks for bearing with me.

Andy


On Fri, Nov 4, 2011 at 11:36 AM, Andrew Schoener <[email protected]
<mailto:[email protected]>> wrote:

    To populate my table, I use:

    table.setRowList(list);

    Where the list is a list of hashmaps that I build from a result set.  Yeah, 
clunky, but ok for
    testing for now.

    To my underlying mysql table, I added an artificial unique key ID to test 
with.  The true
    primary key is ALPHA_KEY.  Both are returned by the SQL select.

    However, when adding columns to my click table, I add neither ID nor 
ALPHA_KEY as columns.  Just
    the other columns from the SQL are added as click columns.

    With that in place, when I do this:

    actionColumn.setDecorator(new LinkDecorator(table, actionLinks, "id"));
    And then later in onLinkClick do this:
    String msg = actionLink.getValueInteger();

    Then everything works fine.  I get my ID column in my action link message.
    But if I instead do this:

    actionColumn.setDecorator(new LinkDecorator(table, actionLinks, 
"alpha_key"));
    And then later in onLinkClick do this:
    String msg = actionLink.getValueInteger();

    I only get null in my message.

    Note that I have tried a test where I do explicitly add my "alpha_key" as a 
column in my click
    table, and still I cannot retrieve the value.

    On Fri, Nov 4, 2011 at 10:16 AM, Ivan Furdi <[email protected] 
<mailto:[email protected]>> wrote:

        Hi,

        can you elaborate how do you fill table - you wrote earlier that you 
use setRowList(list).
        I presume that that is the list of rows which you want to show in table.

        How do you populate table :



        AbstractLink[] links = new AbstractLink[] { actionLink };
             column.setDecorator(new LinkDecorator(table, links, "field1"));


        column = new Column("field1", "Some name for field 1");
        table.addColumn(column);

        or some other way? What im asking is if you have added the field1 to 
the table (not just the
        select )

        This is my code snippet for simple table that works

                 table.setClass(Table.CLASS_ITS);
                 table.setShowBanner(true);
                 table.setSortable(true);

                 table.setSortedColumn(ORDERING_COLUMN);
                 table.setSortedAscending(ORDERING_DIRECTION);
                 table.setSorted(true);

                 table.setStyle("font-size", "10px");

                 Column column = null;

                 editLink.setImageSrc("/images/edit.gif");  //some image for 
link

                 deleteLink.setImageSrc("/images/delete.gif");
                 deleteLink.setAttribute("onclick", "return window.confirm('Are you 
sure?');");

                 column = new Column("Action");
                 column.setTextAlign("center");
                 column.setWidth("50px");
                 AbstractLink[] links = new AbstractLink[] { editLink, 
deleteLink };
                 column.setDecorator(new LinkDecorator(table, links, "field1"));
                 column.setSortable(false);
                 table.addColumn(column);


                 table.addColumn(new Column("field1", "Name of field1"));

                 column = new Column("dateField", "This is date field");
                 column.setFormat("{0,date,dd.MM.yyyy HH:mm}");
                 table.addColumn(column);




        On 4.11.2011 14:53, Andrew Schoener wrote:
        Ivan,

        Using the column name is exactly what I had tried:

            AbstractLink[] links = new AbstractLink[] { actionLink };
            column.setDecorator(new LinkDecorator(table, links, "alpha_key"));

        But later in my onLinkClick method, I try something like this:

           public boolean onLinkClick() {
              String msg = "action link was clicked = trgp_key = " + 
actionLink.getValue();
              addModel("msg", msg);
           }

        I get null returned.  When I do a view page source of my page, I can 
see that the href
        links do not contain the "alpha_key" in the query string.

        <td><a  
href="/compassui/system/tr-code-groups.htm?actionLink=Details&amp;page=0">Details</a></td></tr>

        In fact, the only time I can get that query string to have any value is 
when I use the
        same code as above but replace "alpha_key" with "id".

        So I'm stumped still.  I can add artificial id columns to my database, 
but I (no joke)
        have over 1000 tables in my target system.

        Andy


        On Fri, Nov 4, 2011 at 8:46 AM, Ivan Furdi <[email protected] 
<mailto:[email protected]>> wrote:

            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









        --
        Srdačan pozdrav,

        Ivan Furdi





Reply via email to