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 IModel<User> model;
CompoundPropertyModel<User> cpm;
public UserEdit(String id, IModel<User> _model) {
super(id, _model);
this.model = _model;
init();
}
private void init(){
cpm = new CompoundPropertyModel<User>(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, IModel<T> 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