Same can be said for ajax update behaviour. See for example: TextField password = new TextField("password"); AjaxFormComponentUpdatingBehavior ajaxBehaviour = new AjaxFormComponentUpdatingBehavior("onblur") { protected void onUpdate(AjaxRequestTarget target) { System.out.println("ajaxUpdated"); } }; password.add(ajaxBehaviour);
The output: ----------------- getPassword setPassword <--------------- here ajaxUpdated Should I avoid directly using persistent objects for models? What do you suggest? I could serialize an (hibernate)detached object as a form field and then re-attach it on form submission. Or I could load and (hibernate)detach the object on every request (same as I'm doing now, but detaching from session immediately after loading). Or I could use a plain dto. Cheers, Carlos On 4/5/07, Carlos Pita <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm a bit concerned about onSelectionChanged event effectively binding > my model. Suppose my model is a LoadableDetachableModel that is loaded > from the repository every time. Normally (upon form submission) > nothing will be bound after successfully passing validation; then > additional logic will run inside a transactional service and a > rollback thrown if something goes wrong (take into account that I'm > using session-in-view). But if a property of my model object is bound > outside this controlled scenario, the change will be persisted upon > session correct finalization, even if the object is invalid. I > observed that during onSelectionChanged execution the changed property > is effectively bound, so how should I deal with this? > Here is an example with a simple User that has a sex property allowing > the usual two values, note how setSex is called during execution of > onSelectionChanged: > > > The ouput for onSelectionChanged > -------------------------------------------------- > > loadSexModel > getSex > setSex <------- here > getSex > selectionChanged > getSex > > The user domain entity. > ---------------------------------- > > public class User implements Serializable { > [...] > private String sex; > > [...] > public String getSex() { > System.out.println("getSex"); > return sex; > } > > public void setSex(String sex) { > System.out.println("setSex"); > this.sex = sex; > } > } > > The sex choice. > ---------------------- > > DropDownChoice sex = new DropDownChoice("sex", getSexModel()) { > protected void onSelectionChanged(Object newSelection) { > System.out.println("selectionChanged"); > } > protected boolean wantOnSelectionChangedNotifications() { > return true; > } > }; > > The sex model. > --------------------- > > private IModel getSexModel() { > return new LoadableDetachableModel() { > protected Object load() { > System.out.println("loadSexModel"); > return Arrays.asList("Masculine", "Feminine"); > } > }; > } > > > Cheers, > Carlos > ------------------------------------------------------------------------- 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