Re: Delegate a Modelchange to the child components. Or using a ModalWindow for displaying different Models of a specific Type.
Ohkay.. i've found a solution.. but i thinks not simple.. or wicket-like i think... but its the only way to pass the new model to the known propertyModel =/ now iam doing this in UserEdit.java @Override protected void onModelChanged() { final IModelUser _model = (IModelUser) this.getDefaultModel(); visitChildren(new IVisitorComponent() { @Override public Object component(Component component) { PropertyModelUser cpm = ((PropertyModelUser)component.getDefaultModel()); PropertyModelUser newCpm = new PropertyModelUser(_model.getObject(), cpm.getPropertyExpression()); //cpm.setObject(_model.getObject()); component.setDefaultModel(newCpm); component.modelChanging(); return component; } }); } its to dirty i think.. or isn't it? Thanks for any Help in Advance! Martin U wrote: Its not easy to find the right topic, but i will try to explain my problem as best as i can. I want to display an user-detail View (User is an BusinessObject in my Application) inside a specific Modal window. So at the rendering of the Site i place an empty or dummy UserObject inside my UserEdit-Panel and later if the user choose one specific user from a Table i want to replace this dummy-Model with the clicked-User-Model. public class UserEdit extends Panel { /** * @param id * @param model */ private IModelUser model; CompoundPropertyModelUser cpm; public UserEdit(String id, IModelUser _model) { super(id, _model); this.model = _model; init(); } private void init(){ cpm = new CompoundPropertyModelUser(this.getDefaultModelObject()); this.add(new TextField(lastname, cpm.bind(lastName)) ); } } I dont know if its the right choice to use a cpm ... but i think its the proper way right? The UserEdit is the content of my ModalWindow implementation so i bore up the show method with a new Model-Parameter to delegate them to the Inside Content... (inside ModelOverlay.class) public void show(final AjaxRequestTarget target, IModelT model) { if (shown == false) { getContent().setVisible(true); getContent().setDefaultModel(model); // - my new Line ;o) target.addComponent(this); target.appendJavascript(getWindowOpenJavascript()); shown = true; } } The Model inside UserEdit is changed. But how can i archieve that the lastname-Textfield now displays the Value of getLastName() from the new, submitted Model? In my opinion i tried everything... tried to override the onModelChange-Event and tryed to set the new Model with an Visitor of every childfield... but than i lost my expression from the CPM and only pages.adminuserpage$u...@17eea10is shown inside the Textfield. Thanks for any help. Am i totally lost.. or am i on the right way and few steps before the solution? I hope you understand my problem... if not so tell me and i will try to explain it in another way or even better... Apologise my english, its not my mothers tongue! - Martin -- View this message in context: http://old.nabble.com/Delegate-a-Modelchange-to-the-child-components.-Or-using-a--ModalWindow-for-displaying-different-Models-of-a-specific-Type.-tp27604201p27606240.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
Re: Delegate a Modelchange to the child components. Or using a ModalWindow for displaying different Models of a specific Type.
Oh my God.. its so easy ... _ public class UserEdit extends Panel { /** * @param id * @param model */ public UserEdit(String id, CompoundPropertyModelUser _model) { super(id, _model); this.add(new TextField(lastname, _model.bind(lastName))); this.add(new TextField(firstname, _model.bind(firstName)) ); this.add(new TextField(department, _model.bind(department)) ); } } and in ModalWindow.show public void show(final AjaxRequestTarget target, IModelT model) { if (shown == false) { getContent().setVisible(true); getContent().setDefaultModelObject(model.getObject()); //- magic line target.addComponent(this); target.appendJavascript(getWindowOpenJavascript()); shown = true; } } Damn! MattyDE wrote: Ohkay.. i've found a solution.. but i thinks not simple.. or wicket-like i think... but its the only way to pass the new model to the known propertyModel =/ now iam doing this in UserEdit.java @Override protected void onModelChanged() { final IModelUser _model = (IModelUser) this.getDefaultModel(); visitChildren(new IVisitorComponent() { @Override public Object component(Component component) { PropertyModelUser cpm = ((PropertyModelUser)component.getDefaultModel()); PropertyModelUser newCpm = new PropertyModelUser(_model.getObject(), cpm.getPropertyExpression()); //cpm.setObject(_model.getObject()); component.setDefaultModel(newCpm); component.modelChanging(); return component; } }); } its to dirty i think.. or isn't it? Thanks for any Help in Advance! Martin U wrote: Its not easy to find the right topic, but i will try to explain my problem as best as i can. I want to display an user-detail View (User is an BusinessObject in my Application) inside a specific Modal window. So at the rendering of the Site i place an empty or dummy UserObject inside my UserEdit-Panel and later if the user choose one specific user from a Table i want to replace this dummy-Model with the clicked-User-Model. public class UserEdit extends Panel { /** * @param id * @param model */ private IModelUser model; CompoundPropertyModelUser cpm; public UserEdit(String id, IModelUser _model) { super(id, _model); this.model = _model; init(); } private void init(){ cpm = new CompoundPropertyModelUser(this.getDefaultModelObject()); this.add(new TextField(lastname, cpm.bind(lastName)) ); } } I dont know if its the right choice to use a cpm ... but i think its the proper way right? The UserEdit is the content of my ModalWindow implementation so i bore up the show method with a new Model-Parameter to delegate them to the Inside Content... (inside ModelOverlay.class) public void show(final AjaxRequestTarget target, IModelT model) { if (shown == false) { getContent().setVisible(true); getContent().setDefaultModel(model); // - my new Line ;o) target.addComponent(this); target.appendJavascript(getWindowOpenJavascript()); shown = true; } } The Model inside UserEdit is changed. But how can i archieve that the lastname-Textfield now displays the Value of getLastName() from the new, submitted Model? In my opinion i tried everything... tried to override the onModelChange-Event and tryed to set the new Model with an Visitor of every childfield... but than i lost my expression from the CPM and only pages.adminuserpage$u...@17eea10is shown inside the Textfield. Thanks for any help. Am i totally lost.. or am i on the right way and few steps before the solution? I hope you understand my problem... if not so tell me and i will try to explain it in another way or even better... Apologise my english, its not my mothers tongue! - Martin -- View this message in context: http://old.nabble.com/Delegate-a-Modelchange-to-the-child-components.-Or-using-a--ModalWindow-for-displaying-different-Models-of-a-specific-Type.-tp27604201p27607064.html Sent from the Wicket - User mailing list archive at Nabble.com.
Delegate a Modelchange to the child components. Or using a ModalWindow for displaying different Models of a specific Type.
Its not easy to find the right topic, but i will try to explain my problem as best as i can. I want to display an user-detail View (User is an BusinessObject in my Application) inside a specific Modal window. So at the rendering of the Site i place an empty or dummy UserObject inside my UserEdit-Panel and later if the user choose one specific user from a Table i want to replace this dummy-Model with the clicked-User-Model. public class UserEdit extends Panel { /** * @param id * @param model */ private IModelUser model; CompoundPropertyModelUser cpm; public UserEdit(String id, IModelUser _model) { super(id, _model); this.model = _model; init(); } private void init(){ cpm = new CompoundPropertyModelUser(this.getDefaultModelObject()); this.add(new TextField(lastname, cpm.bind(lastName)) ); } } I dont know if its the right choice to use a cpm ... but i think its the proper way right? The UserEdit is the content of my ModalWindow implementation so i bore up the show method with a new Model-Parameter to delegate them to the Inside Content... (inside ModelOverlay.class) public void show(final AjaxRequestTarget target, IModelT model) { if (shown == false) { getContent().setVisible(true); getContent().setDefaultModel(model); // - my new Line ;o) target.addComponent(this); target.appendJavascript(getWindowOpenJavascript()); shown = true; } } The Model inside UserEdit is changed. But how can i archieve that the lastname-Textfield now displays the Value of getLastName() from the new, submitted Model? In my opinion i tried everything... tried to override the onModelChange-Event and tryed to set the new Model with an Visitor of every childfield... but than i lost my expression from the CPM and only pages.adminuserpage$u...@17eea10is shown inside the Textfield. Thanks for any help. Am i totally lost.. or am i on the right way and few steps before the solution? I hope you understand my problem... if not so tell me and i will try to explain it in another way or even better... Apologise my english, its not my mothers tongue! - Martin