hi all,

i got some sort of crud page consisting of a listview and a detailview for my 
objects. depending on a stateflag either the listview is shown or the 
detailview.
the detailview contains an addresspanel (textfields for my properties, which 
use 
  propertymodels to get the fieldvalues).

in my crudpage i got two methods for changing to editing state and cycling back 
to listview:

        @Override
        public void onEditAction(User selected) {
                User object = userDao.load(selected.getId());
                addressPanel.detachModels();
                setModelObject(object);
        }

        @Override
        public void onCancelAction() {
                setModelObject(null);
        }

the addresspanel is created in the constructor of my crudpage with the model of 
the page:


        public UserPage() {
                super(20, CrudPanel.ACTION_ALL);
                setModel(new CompoundPropertyModel(new User()));

                addTextField("username", "labelUsername", "Label.Username");
                
                PasswordTextField tf = new PasswordTextField("password");
                tf.setLabel(new ResourceModel("Label.Password"));
                tf.setRequired(false);
                tf.setResetPassword(false);
                detailsForm.add(tf);
                detailsForm.add(new SimpleFormComponentLabel("labelPassword", 
tf));
                
                
                addressPanel = new AddressPanel("addressPanel", "address.",  
getModel());
                detailsForm.add(addressPanel);
                
        }

the problem is:
for the first time i swith to editing mode for a user, all fields are populated 
like they should. if i cycle back by cancelling and choose another user for 
editing, the textfields in the addresspanel still contain old values.
i found out, that the textfields call their getObject() method just only once 
and not each time i switch from list to edit mode.

is there a way to inform my addresspanel to refresh its childs?

ty in advance,
harald



----addresspanel----

public class AddressPanel extends Panel {
        private static final long serialVersionUID = 1L;
        
        private String propertyPrefix = "";

        public AddressPanel(String id, String propertyPrefix, Address address) {
                this(id, propertyPrefix, new Model(address));
        }
        
        public AddressPanel(String id, String propertyPrefix, IModel model) {
                super(id, model);
                if (null != propertyPrefix)
                        this.propertyPrefix = propertyPrefix;
                addTextField("company", "labelCompany", "Label.Company");
                ...
        }

        private TextField addTextField(String name, String labelName, String 
labelKey) {
                TextField tf = new TextField(name, new 
PropertyModel(getModel(), 
this.propertyPrefix + name) {
                        public Object getObject() {
                                Object o = super.getObject();
                                System.out.println("OBJ " + o);
                                return o;
                        }
                });
                tf.setLabel(new ResourceModel(labelKey));
                add(tf);
                add(new SimpleFormComponentLabel(labelName, tf));
                return tf;
        }
        


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to