Martin,

having read the thread I didn't get why you can not modify the object
itself. OSiV shouldn't be the reason because the object should be detached
when submitting the form and it should be merged into a brand new hibernate
session.

Actually I don't see the value of always keeping in mind that the raw input
and backed object should have different values until final form submit. If
your reusable components can submit form and aren't aware about that you
can't reuse them in that sort of form. From my perspective your hack does
not seem cleaner.

What i'm doing in order to set the default value (for instance today for
date picker) is subclassing form component and initialize its model object.
It looks shorter and cleaner.


MartinM wrote:
> 
>> Typically to prefill a form you have the backing model object have
>> sensible defaults.  i.e., a form that edits a person is given a
>> person, and the person object has it's gender set to "male" as a
>> default - that is reflected in your form when it is rendered.
> 
> The problem is that it is not a NEW object. It is an old object with
> "proposed new values" which the user must SUBMIT in order to be stored
> into the object etc.
> 
>> otherwise, you could call setModelObject or perhaps setValue?
> 
> Well.. that will destroy the object state, which is a different hassle.
> 
> **
> Martin
> 
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>>
>>
>> On Tue, Jul 7, 2009 at 8:57 AM, Martin
>> Makundi<martin.maku...@koodaripalvelut.com> wrote:
>>> Hi!
>>>
>>> What is the proper way to prefill a wicket form (not poke the model
>>> before submit!!!)?
>>>
>>> I have used a hack:
>>>
>>>      Field rawInputField =
>>> FormComponent.class.getDeclaredField("rawInput");
>>>      rawInputField.setAccessible(true);
>>>      rawInputField.set(component, description);
>>>
>>> Is there a better way?
>>>
>>> **
>>> Martin
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Prefill-form-not-model--tp24373824p24386875.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to