Hi Troy,

There is no need to set the same model on both password fields. The confirmation field can be initialized with its own (dummy) model like so:

PasswordTextField p2 = new PasswordTextField("repeatPassword", new 
Model()).setResetPassword(false);

This is the same with or without a CPM.

> in a form that gets reused (repetitively in the same page).

Don't you ever re-use a component! Sharing models/behaviors is fine, sharing components is not.

Regarding your other questions:

Q1.  Is the setChainedModel() call the best solution for this case?

No, just don't share components.

Q2.  It's a good thing to pass models, right?  LDM's don't support setObject().

Yes. Actually, you could override setObject of a LDM but I can not really recommend it as LDM is not set up for using the set object.

Q3.  In general (not this case), for reusing forms with CPM(EntityM) should I
       replace the CPM or only the EntityM ?

See answer to Q1.

Regards,
   Erik.


Troy Cauble wrote:
I have the following password confirmation pattern borrowed from WIA

                PasswordTextField p1 = new
PasswordTextField("password").setResetPassword(false);
                docForm.add(p1);
                PasswordTextField p2 = new
PasswordTextField("repeatPassword").setResetPassword(false);
      -->      p2.setModel(p1.getModel());
                docForm.add(p2);
                docForm.add(new EqualPasswordInputValidator(p1, p2));

in a form that gets reused (repetitively in the same page).  This used
to work fine
with a CPM and calling docForm.setModelObject().

I rewrote to pass models instead of objects, changing
    docForm.setModelObject() to
    docForm.setModel(new CPM(new EntityModel(...)))

and got
    "No get method defined for class: ... expression: repeatPassword"
But the other fields work fine, if I comment out the repeatPasswordField.
(My underlying data object has never had a repeatPassword field.)

It works if I call
     cpm.setChainedModel(new EntityModel(....));

instead, but that seems a little non-obvious.  I imagine redoing the
p2.setModel(p1.getModel() would work too.

Q1.  Is the setChainedModel() call the best solution for this case?
Q2.  It's a good thing to pass models, right?  LDM's don't support setObject().
Q3.  In general (not this case), for reusing forms with CPM(EntityM) should I
        replace the CPM or only the EntityM ?

Thanks,
-troy




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to