I'm not sure there is a very clean solution. When switching to edit mode, you could set the User's Job to a new Job instance if it is null. You don't have to reattach/reassign any form components if you simply update the AbstractEntityModel's object. I.e. you either do model.getModelObject().setJob(new Job()) or you do model.setModelObject(<user with non-null job>)
You will of course have to revert the job property back to null before saving if all its properties are empty. I would implement a Job#isEmpty() method to help me decide if I need to set user.job to null before saving to the db. Note you may also have to delete an existing Job record if the user goes ahead and updates it's name to null. Marios On Tue, Feb 11, 2014 at 4:22 PM, ChambreNoire <[email protected]> wrote: > I forgot to mention, the reason I don't systematically make a new Job > instance is that when saving the form hibernate creates a new Job instance > which is effectively empty if no Job details have been input. > > Chambre > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664369.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
