click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Malcolm Edgar <malcolm.ed...@gmail.com>
Subject Re: svn commit: r789435 - in /incubator/click/trunk/click/examples/src/org/apache/click/examples/page: EditCustomer.java introduction/AdvancedTable.java
Date Mon, 29 Jun 2009 23:45:28 GMT
I think this would be best implemented using a stateful page, its
certainly a lot simpler to explain and is a good topic for the
introduction section.

regards Malcolm Edgar

On Tue, Jun 30, 2009 at 6:19 AM, <sabob@apache.org> wrote:
> Author: sabob
> Date: Mon Jun 29 20:19:22 2009
> New Revision: 789435
>
> URL: http://svn.apache.org/viewvc?rev=789435&view=rev
> Log:
> preserve advanced table sort and page state between edits
>
> Modified:
>    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.java
>    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java
>
> Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.java
> URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.java?rev=789435&r1=789434&r2=789435&view=diff
> ==============================================================================
> --- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.java
(original)
> +++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.java
Mon Jun 29 20:19:22 2009
> @@ -18,14 +18,18 @@
>  */
>  package org.apache.click.examples.page;
>
> +import java.util.HashMap;
> +import java.util.Map;
>  import javax.annotation.Resource;
>
>  import org.apache.click.Page;
> +import org.apache.click.control.ActionLink;
>  import org.apache.click.control.Checkbox;
>  import org.apache.click.control.FieldSet;
>  import org.apache.click.control.Form;
>  import org.apache.click.control.HiddenField;
>  import org.apache.click.control.Submit;
> +import org.apache.click.control.Table;
>  import org.apache.click.control.TextField;
>  import org.apache.click.examples.control.InvestmentSelect;
>  import org.apache.click.examples.domain.Customer;
> @@ -56,6 +60,11 @@
>
>     // Public variables can automatically have their value set by request parameters
>     @Bindable public Integer id;
> +    @Bindable public String actionLink;
> +    @Bindable public int page;
> +    @Bindable public String column;
> +    @Bindable public boolean ascending;
> +    @Bindable public boolean sort;
>
>     private HiddenField idField = new HiddenField("id", Integer.class);
>
> @@ -102,6 +111,13 @@
>      */
>     @Override
>     public void onGet() {
> +        // Store the Page public properties state in hidden fields
> +        form.add(new HiddenField(Table.PAGE, page));
> +        form.add(new HiddenField(Table.COLUMN, column));
> +        form.add(new HiddenField(Table.ASCENDING, ascending));
> +        form.add(new HiddenField(Table.SORT, sort));
> +        form.add(new HiddenField(ActionLink.ACTION_LINK, actionLink));
> +
>         if (id != null) {
>             Customer customer = customerService.getCustomerForID(id);
>
> @@ -125,7 +141,14 @@
>
>             String referrer = referrerField.getValue();
>             if (referrer != null) {
> -                setRedirect(referrer);
> +                // Pass the Page public properties to the referring page
> +                Map params = new HashMap();
> +                params.put(Table.PAGE, page);
> +                params.put(Table.COLUMN, column);
> +                params.put(Table.SORT, sort);
> +                params.put(Table.ASCENDING, ascending);
> +                params.put(ActionLink.ACTION_LINK, actionLink);
> +                setRedirect(referrer, params);
>             } else {
>                 setRedirect(HomePage.class);
>             }
>
> Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java
> URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java?rev=789435&r1=789434&r2=789435&view=diff
> ==============================================================================
> --- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java
(original)
> +++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java
Mon Jun 29 20:19:22 2009
> @@ -100,5 +100,13 @@
>     public void onRender() {
>         List list = customerService.getCustomers();
>         table.setRowList(list);
> +
> +        // Pass the Table paging and sorting parameters to the link's target
> +        // page: 'EditCustomer'
> +        editLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber()));
> +        editLink.setParameter(Table.COLUMN, table.getSortedColumn());
> +        editLink.setParameter(Table.SORT, Boolean.toString(table.isSorted()));
> +        editLink.setParameter(Table.ASCENDING, Boolean.toString(table.isSortedAscending()));
> +        editLink.setParameter(ActionLink.ACTION_LINK, table.getControlLink().getName());
>     }
>  }
>
>
>

Mime
View raw message