You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Kristian Lind <kl...@gmail.com> on 2013/07/05 23:37:50 UTC

Table problem

Hi, I am using a table to show a list of items.

The item in the list is a order request.

*orderRequestItemsTable = new Table("orderRequestItemsTable");*
*orderRequestItemsTable.setClass(Table.CLASS_ISI);*
*orderRequestItemsTable.setPageSize(Constants.MAX_PAGE_SIZE);*
*orderRequestItemsTable.setSortable(false);*
*orderRequestItemsTable.addStyleClass("dash_table");*
*.....*
*orderRequestItemsTable.addColumn(createTableColumn("receivedDate",
"Received Time Stamp", "20%", "left", null));
*
*
*
*final PageLink linkToOrder = new PageLink("", "View ", viewer);*
*linkToOrder.addStyleClass("btn_small btn-primary");*
*
*
*orderRequestItemsTable.addColumn(createTableColumn("Order", "Order",
"10%", "left",*
*         new LinkDecorator(orderRequestItemsTable, new
AbstractLink[]{linkToOrder}, "order.id", "order")));*
*       *
*addControl(orderRequestItemsTable);*


The order request object has a boolean variable, and if the value is true i
want to show a blue button, else a green button.
In the code above only a blue button is shown...
*linkToOrder.addStyleClass("btn_small
btn-primary");*

Thanks....


-- 
Best regards

Kris

Re: Table problem

Posted by Kristian Lind <kl...@gmail.com>.
Hi Bob... this worked..

 final PageLink linkToOrder = new PageLink("", "View ", viewer);
        LinkDecorator decorator = new LinkDecorator(orderRequestItemsTable,
new AbstractLink[]{linkToOrder}, "order.id", "order") {
            protected void renderActionLink(HtmlStringBuffer buffer,
AbstractLink link, Context context, Object row, Object value) {
            OrderRequestEnt orderRequestEnt = (OrderRequestEnt) row;
            link.removeStyleClass("btn_small");
            link.removeStyleClass("btn-primary-orange");
            link.removeStyleClass("btn-primary");
            if (orderRequestEnt.isTestOrder()) {
            link.addStyleClass("btn_small btn-primary-orange");
            } else {
            link.addStyleClass("btn_small btn-primary");
            }
            // NB we invoke the super implementation here for default
rendering to continue
                super.renderActionLink(buffer, link, context, row, value);
            }
        };


On Sat, Jul 6, 2013 at 12:25 AM, Bob Schellink <sa...@gmail.com> wrote:

>  Hi,
>
> You probably want to override the LinkDecorator#renderActionLinks method
> to customize your button style:
>
>
> http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html
>
> There is a demo in the javadoc above as well.
>
> regards
>
> Bob
>
>
>
>
> On 2013/07/05 23:37, Kristian Lind wrote:
>
> Hi, I am using a table to show a list of items.
>
>  The item in the list is a order request.
>
>  *orderRequestItemsTable = new Table("orderRequestItemsTable");*
> *orderRequestItemsTable.setClass(Table.CLASS_ISI);*
> *orderRequestItemsTable.setPageSize(Constants.MAX_PAGE_SIZE);*
> *orderRequestItemsTable.setSortable(false);*
> *orderRequestItemsTable.addStyleClass("dash_table");*
> *.....*
> *orderRequestItemsTable.addColumn(createTableColumn("receivedDate",
> "Received Time Stamp", "20%", "left", null));
> *
> *
> *
>  *final PageLink linkToOrder = new PageLink("", "View ", viewer);*
> *linkToOrder.addStyleClass("btn_small btn-primary");*
> *
> *
> *orderRequestItemsTable.addColumn(createTableColumn("Order", "Order",
> "10%", "left",*
> *         new LinkDecorator(orderRequestItemsTable, new
> AbstractLink[]{linkToOrder}, "order.id", "order")));*
> *       *
> *addControl(orderRequestItemsTable);*
>
>
>  The order request object has a boolean variable, and if the value is
> true i want to show a blue button, else a green button.
> In the code above only a blue button is shown... *linkToOrder.addStyleClass("btn_small
> btn-primary");*
>
>  Thanks....
>
>
>  --
> Best regards
>
> Kris
>
>
>


-- 
Best regards

Kristian Lind

Re: Table problem

Posted by Scott Gray <le...@gmail.com>.
Hi Bob,

Any thoughts about changing things so that all controls were rendered from
velocity templates? Doing so would allow users to make global changes
without the need to subclass controls and keep their API somewhat smaller.
 Even when subclasses are needed it could just be a matter of overriding a
getTemplate() method or similar.

Thanks
Scott


On 6 July 2013 19:25, Bob Schellink <sa...@gmail.com> wrote:

>  Hi,
>
> You probably want to override the LinkDecorator#renderActionLinks method
> to customize your button style:
>
>
> http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html
>
> There is a demo in the javadoc above as well.
>
> regards
>
> Bob
>
>
>
>
> On 2013/07/05 23:37, Kristian Lind wrote:
>
> Hi, I am using a table to show a list of items.
>
>  The item in the list is a order request.
>
>  *orderRequestItemsTable = new Table("orderRequestItemsTable");*
> *orderRequestItemsTable.setClass(Table.CLASS_ISI);*
> *orderRequestItemsTable.setPageSize(Constants.MAX_PAGE_SIZE);*
> *orderRequestItemsTable.setSortable(false);*
> *orderRequestItemsTable.addStyleClass("dash_table");*
> *.....*
> *orderRequestItemsTable.addColumn(createTableColumn("receivedDate",
> "Received Time Stamp", "20%", "left", null));
> *
> *
> *
>  *final PageLink linkToOrder = new PageLink("", "View ", viewer);*
> *linkToOrder.addStyleClass("btn_small btn-primary");*
> *
> *
> *orderRequestItemsTable.addColumn(createTableColumn("Order", "Order",
> "10%", "left",*
> *         new LinkDecorator(orderRequestItemsTable, new
> AbstractLink[]{linkToOrder}, "order.id", "order")));*
> *       *
> *addControl(orderRequestItemsTable);*
>
>
>  The order request object has a boolean variable, and if the value is
> true i want to show a blue button, else a green button.
> In the code above only a blue button is shown... *linkToOrder.addStyleClass("btn_small
> btn-primary");*
>
>  Thanks....
>
>
>  --
> Best regards
>
> Kris
>
>
>

Re: Table problem

Posted by Bob Schellink <sa...@gmail.com>.
Hi,

You probably want to override the LinkDecorator#renderActionLinks method to customize your button style:

http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html

There is a demo in the javadoc above as well.

regards

Bob



On 2013/07/05 23:37, Kristian Lind wrote:
> Hi, I am using a table to show a list of items.
>
> The item in the list is a order request.
>
> *orderRequestItemsTable = new Table("orderRequestItemsTable");*
> *orderRequestItemsTable.setClass(Table.CLASS_ISI);*
> *orderRequestItemsTable.setPageSize(Constants.MAX_PAGE_SIZE);*
> *orderRequestItemsTable.setSortable(false);*
> *orderRequestItemsTable.addStyleClass("dash_table");*
> *.....*
> *orderRequestItemsTable.addColumn(createTableColumn("receivedDate", "Received Time Stamp", "20%", 
> "left", null));
> *
> *
> *
> *final PageLink linkToOrder = new PageLink("", "View ", viewer);*
> *linkToOrder.addStyleClass("btn_small btn-primary");*
> *
> *
> *orderRequestItemsTable.addColumn(createTableColumn("Order", "Order", "10%", "left",*
> *         new LinkDecorator(orderRequestItemsTable, new AbstractLink[]{linkToOrder}, "order.id 
> <http://order.id>", "order")));*
> **
> *addControl(orderRequestItemsTable);*
>
>
> The order request object has a boolean variable, and if the value is true i want to show a blue 
> button, else a green button.
> In the code above only a blue button is shown... *linkToOrder.addStyleClass("btn_small btn-primary");*
>
> Thanks....
>
>
> -- 
> Best regards
>
> Kris