You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Carl Pelletier <ca...@2be.ca> on 2006/04/28 16:53:13 UTC
HOW TO validate the first choice of IPropertySelectionModel
Hi everyone. I'm new to Tapestry 4 (never use Tapestry before) and I would like
to say that I love it!
But now, I'm trying to do a simple thing: I would like to display a combo box on
my page with 3 values: "choice", "man", "women" and validate the value selected.
The dropdown is required so if the user choose "choice" the validator must
reject it.
I trying to do it with a StringPropertySelectionModel and would like to avoid of
doing a custom validator or a custom been.
The default value of the combo box is "choice" so when the user submit the form,
the validator must return a error.
What I am missing? I search the mailling list and found nothing like this. Sorry
If I mist something. sorry for the bad english to. I'm french.
Here are the IPropertySelectionModel example:
--------------------------
public static final IPropertySelectionModel SEXE_MODEL = new
StringPropertySelectionModel(
new String[] { "Choisir", "Homme", "Femme" });
-------------------------
Here are the method called on the submit of the form:
------------------------
public String onOK() {
ValidationDelegate delegate = this.getDelegate();
if (delegate.getHasErrors()) {
return null;
}
getContactCRUDService().save(getContact(), getInternalId() == null);
return "contactList";
}
------------------------
Here are the combo box in the HTML page.
------------------------
<select jwcid="sexe@PropertySelection"
model="ognl:@com.rezopdr.utils.models.SelectModels@SEXE_MODEL"
value="ognl:Contact.Birth.sexe">
<option value="Choisir" selected="selected">Choisir</option>
<option value="">---------------</option>
<option value="Homme" >Homme</option>
<option value="Femme">Femme</option>
</select>
------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org