On 6/23/07, Erik Dreyer <[EMAIL PROTECTED]> wrote:
Hi,
I'm loving Wicket, but still have a bit to learn. I didn't find any
answers when searching for an answer to my questions, so here they are.
BTW, I'm using Wicket 1.3 as built from SVN (up to date as of 6/23).
I have a panel that I'd like to include in multiple _different_ forms.
The panel defines some form elements that I'd like to be processed by the
enclosing form.
My use case is basically this: The panel contains contact info (name,
address, etc). I'd like to include this panel in both a registration form
and later, in a user profile where the user can edit their contact info.
1) What is the best way to define this Panel? My constructor currently
looks something like the following. Is this the correct way of solving
this? An issue I have with this is that this panel makes some assumptions
about the form's model object.
public ContactInfoPanel(String id, Form form) {
super(id, form.getModel());
BoundCompoundPropertyModel userModel =
(BoundCompoundPropertyModel)form.getModel();
Component firstNameField = userModel.bind(new
RequiredTextField("firstName"), "path.to.firstName");
add(firstNameField);
}
that works, although i usually like to pass the model in direclty. generics
are just for clarity
class edituserpanel extends panel {
public edituserpanel(string id, imodel<user> usermodel) {
super(id, new compoundpropertymodel(usermodel));
add(new textfield("address.street");
....
the advantage is that the model can come from anywhere - eg it doesnt have
to be the root form model.
2) Supposing I wanted to add inter-field validation for fields contributed
by this panel, what is the best way to do that?
you can do this in a few different ways.
1) there are form-level validators. see iformvalidator and its
implementations for examples.
2) you can let your panel extend formcomponentpanel and override its
validate() or add an anonymous validator that references child
formcomponents. inside this method you should use
childcomp.getconvertedinput() to retrieve the value that should be
validated.
-igor
Any help would be greatly appreciated.
Thanks,
Erik
-------------------------------------------------------------------------
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
-------------------------------------------------------------------------
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