Correction:

replace

form.copyFrom(naturalPerson);

with

setValueObject(naturalPerson);

Hth,

Gilberto


2010/11/25 Gilberto <[email protected]>

> Hi, John!
>
> I think it isn't different from normal Form control.
> This one is my:
> <quote>
>     /**
>      * When page is first displayed on the GET request.
>      *
>      * @see Page#onGet()
>      */
>     @Override
>     public void onGet() {
>         if (id != null) {
>             NaturalPerson naturalPerson = naturalPersonService.find(id);
>
>             if (naturalPerson != null) {
>                 // Copy naturalPerson data to form. The idField value will
> be set by
>                 // this call
>                 form.copyFrom(naturalPerson);
>             }
>         }
>
>         if (referrer != null) {
>             // Set referrerField HiddenField to bound referrer field
>             referrerField.setValue(referrer);
>         }
>     }
> </quote>
>
> Hth,
>
> Gilberto
>
> 2010/11/25 johnfilo <[email protected]>
>
>
>> Hiya
>>
>> New to Click and Hibernate, let that be known.
>>
>> Been trying to use the HibernateForm from click-extras but not having any
>> luck in figuring out how to pass an object into the form for editing?
>>
>> Does anyone care to share an example?
>>
>> My object is called User. It has the following properties:
>>
>> id (db identity column)
>> username
>> password
>> email
>>
>> I have the form and page created no problems, and can add a new object to
>> the DB, but can't figure out how to pass an object into the form to
>> edit...
>>
>> From the doco here
>>
>> http://click.apache.org/docs/extras-api/org/apache/click/extras/hibernate/HibernateForm.html
>> it has this to say:
>>
>> "To edit an existing user object, the object is passed to the page as a
>> request parameter"
>>
>> Now I have tried everything I can think of......but still nothing.
>>
>> Please please enlighten me :) hahaha
>>
>> Cheers
>> John
>> --
>> View this message in context:
>> http://click.1134972.n2.nabble.com/HibernateForm-How-do-I-pass-an-object-into-the-form-to-edit-tp5773903p5773903.html
>> Sent from the click-user mailing list archive at Nabble.com.
>>
>
>

Reply via email to