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: r902012 - /incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.java
Date Sun, 24 Jan 2010 11:32:05 GMT
+1 - good change, this is an awful pattern.

On Fri, Jan 22, 2010 at 6:01 PM,  <sabob@apache.org> wrote:
> Author: sabob
> Date: Fri Jan 22 07:01:14 2010
> New Revision: 902012
>
> URL: http://svn.apache.org/viewvc?rev=902012&view=rev
> Log:
> removed the confusing pattern of binding a HiddenField to both a Page and adding it to
a Form
>
> Modified:
>    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/EditCustomer.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=902012&r1=902011&r2=902012&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
Fri Jan 22 07:01:14 2010
> @@ -41,28 +41,28 @@
>  * Provides an edit Customer Form example. The Customer business object
>  * is initially passed to this Page as a request attribute.
>  * <p/>
> - * Note the public visibility "referrer" HiddenField and the "id" field
> - * have their value automatically set with any identically named request
> - * parameters after the page is created.
> - *
> - * @author Malcolm Edgar
> + * Note the bindable "id" and "referrer" fields have their values automatically
> + * set with any identically named request parameters after the page is created.
> + * These fields will be used to populate the similarly named HiddenFields
> + * on GET requests. See the onGet method below.
>  */
>  @Component
>  public class EditCustomer extends BorderPage {
>
> -    // Public controls are automatically added to the page
> -    @Bindable protected Form form = new Form("form");
> -    @Bindable protected HiddenField referrerField = new HiddenField("referrer", String.class);
> +    private Form form = new Form("form");
> +    private HiddenField referrerField = new HiddenField("referrer", String.class);
> +    private HiddenField idField = new HiddenField("id", Integer.class);
>
> -    // Public variables can automatically have their value set by request parameters
> +    // Bindable variables can automatically have their value set by request parameters
>     @Bindable protected Integer id;
> -
> -    private HiddenField idField = new HiddenField("id", Integer.class);
> +    @Bindable protected String referrer;
>
>     @Resource(name="customerService")
>     private CustomerService customerService;
>
>     public EditCustomer() {
> +        addControl(form);
> +
>         form.add(referrerField);
>
>         form.add(idField);
> @@ -106,9 +106,16 @@
>             Customer customer = customerService.getCustomerForID(id);
>
>             if (customer != null) {
> +                // Copy customer data to form. The idField value will be set
by
> +                // this call
>                 form.copyFrom(customer);
>             }
>         }
> +
> +        if (referrer != null) {
> +            // Set HiddenField to bound referrer field
> +            referrerField.setValue(referrer);
> +        }
>     }
>
>     public boolean onOkClick() {
>
>
>

Mime
View raw message