G'day

In part the question was based on a misunderstanding which I have now overcome. 
I thought that all the columns of the database table had to be present in the 
form as form fields. But that is not the case. So any column whose value I know 
ahead of time I don't present on the form - I just give them values in the code 
after the user submits the form. I also came to the same conclusion about the 
database keys. 

So that reduces the question to form fields that I want to pre-fill with a 
(context-dependent) default value but whose value I allow the user to change. I 
can pre-fill the fields using a Property model as described in the initial 
post, but such values are null after the GetModelObject(). Is this a 
misunderstanding about models - that the GetModelObject won't get the values of 
form fields that are linked with a model other than the model the form is 
linked with. Seems reasonable, except that if the pre-filled fields are linked 
with a static model instead of the (dynamic) PropertyModel the form values are 
retrieved correctly by GetModelObject().



Ian Blavins





On 18/07/2012, at 4:22 AM, Eric Jablow [via Apache Wicket] wrote:

> On Sat, Jul 14, 2012 at 3:03 AM, Ian <[hidden email]> wrote: 
> 
> > G'day 
> > 
> > Short form: how do I pre-fill a form field with the dynamic value of the 
> > next free database key 
> > 
> > Is your customer demanding that the database ids end up without 
> any gaps? If so, try to work hard to dissuade your customer. Database 
> ids should have no other business meeting. They should be opaque. 
> One good way to distinguish between a object that has not yet been 
> persisted and one that has is whether its id variable is null or not. 
> 
> So, suppose you have a Form<Person>.  In your onSubmit method, you 
> call personService.create(getModelObject()), where personService 
> calls DAOs, or maybe is a DAO. It modifies the Person object in place, 
> setting the id when it is done. It then redirects the user to the 
> appropriate 
> page. If there is a constraint violation or other database problem, 
> the object should be unchanged and the system should remain on 
> the form page. 
> 
> You can reuse the form page if you want to edit an existing person. You 
> just don't give the user any way to edit the id, and you call an update 
> method instead. 
> 
> Respectfully, 
> Eric Jablow 
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://apache-wicket.1842946.n4.nabble.com/Next-database-key-pre-filled-in-form-and-associated-with-PropertyModel-returns-null-tp4650518p4650576.html
> To unsubscribe from Next database key pre-filled in form and associated with 
> PropertyModel returns null, click here.
> NAML



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Next-database-key-pre-filled-in-form-and-associated-with-PropertyModel-returns-null-tp4650518p4650581.html
Sent from the Users forum 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