Both methods have the same effect. The attachement of models is hidden in the models, not in the components. Detachement is done by components after rendering. Preferably is getModelObject, but just because it is shorter and it hides getting the model.
What happens in that request is that first the model object will be fetched from the database (the first time model.getObject is called somewhere). When all validation succeeds, that object is then updated with the form values etc. If you access that in the onSubmit method, you'll still have that same - now udpated - object, provided you didn't manually detach your model yourself somehow. So, just get that object, save it, and you're done. Eelco On 7/31/06, Nick Heudecker <[EMAIL PROTECTED]> wrote: > So something like this? > > public void onSubmit() { > Foo f = (Foo) getModelObject(); > ... > } > > or like: > > public void onSubmit() { > Foo f = (Foo) getModel().getObject(null); > ... > } > > Because the first one refreshes the object from the database. > > > > On 7/31/06, Eelco Hillenius <[EMAIL PROTECTED] > wrote: > > > After successful validation, you should update the database with the > object that is in your detachable model. They should be in sync then. > If for some reason, you need to read in the value fresh in the same > request, just call detach on that model to ensure next time it is read > it will first re-load the actual model. > > Eelco > > > On 7/31/06, Nick Heudecker <[EMAIL PROTECTED]> wrote: > > But that's not the behavior I'm seeing. On successful validation, the > model > > object is refreshed from the database after the form updates the model > > object, clobbering the user-entered data. > > > > > > On 7/31/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > > > Yeah, those models are typically perfect for doing database stuff. The > > > only thing is that if all validations pass, you should update the > > > database. But that's usually exactly what you want, right? If > > > validation fails, the model is indeed reloaded from the database, but > > > that's not something that is in the user's way as for components for > > > which the validation failed, the input values of last request will be > > > displayed instead of the current model values. > > > > > > Eelco > > > > > > > > > On 7/31/06, Nick Heudecker < [EMAIL PROTECTED]> wrote: > > > > Is it possible to use a LoadableDetachableModel with a Form? The > > problem > > > > I'm running into is the following: > > > > > > > > 1) Create the Form with: new Form("form", new > CompoundPropertyModel(new > > > > MyDetachableModel(fooId, fooService))); > > > > 2) Present the page to the user for editing. The user edits the > fields > > and > > > > submits the form. > > > > 3) The model object is reloaded from the database/cache, wiping out > what > > the > > > > user entered. > > > > > > > > Is there any way around clobbering the user input? It doesn't look > like > > it > > > > since the LoadableDetachableModel is doing exactly what it's supposed > > to, > > > > but I want to make sure I'm not missing something. > > > > > > > > > > > ------------------------------------------------------------------------- > > > > Take Surveys. Earn Cash. Influence the Future of IT > > > > Join SourceForge.net's Techsay panel and you'll get the chance to > share > > your > > > > opinions on IT & business topics through brief surveys -- and earn > cash > > > > > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > > > > > > _______________________________________________ > > > > Wicket-user mailing list > > > > Wicket-user@lists.sourceforge.net > > > > > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > Take Surveys. Earn Cash. Influence the Future of IT > > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your > > > opinions on IT & business topics through brief surveys -- and earn cash > > > > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > _______________________________________________ > > > Wicket-user mailing list > > > Wicket-user@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > > opinions on IT & business topics through brief surveys -- and earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > > _______________________________________________ > > Wicket-user mailing list > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user