To all,
I have some problem with wicket, I'm newbie.
Condition
- A form with a CompoundPropertyModel
- 2 RequiredTextField
- 1 FileUploadField
- 1 TextArea with a CustomValidator
when I input string value with comma (,) in either or both requiredTextField with an invalid value of textArea field, the value of requiredTextField will always replace all comma with ;
(Note : other thing work fine, CustomValidator work right, just this replaceAll-like behavior!)
but if form pass my CustomValidator, nothing wrong.
Below are some important part of codes.
### My Form ###
public SubscriberGroupForm(String id, SubscriberGroup model) {
super(id, new CompoundPropertyModel(model));
setMultiPart(true);
setMaxSize(Bytes.megabytes(10));
add(new RequiredTextField("name"));
add(new RequiredTextField("description"));
countLabel = new Label("count", new PropertyModel(model, "count"));
countLabel.setVisible(false);
add(countLabel);
fileUploadField = new FileUploadField("file");
add(fileUploadField);
add(new TextArea("numbers").add(NumberValidator.getInstance())); // <--- My CustomValidator.
add(new Button("submitButton"));
final FeedbackPanel simpleFeedback = new FeedbackPanel("simpleFeedback");
add(simpleFeedback);
}
super(id, new CompoundPropertyModel(model));
setMultiPart(true);
setMaxSize(Bytes.megabytes(10));
add(new RequiredTextField("name"));
add(new RequiredTextField("description"));
countLabel = new Label("count", new PropertyModel(model, "count"));
countLabel.setVisible(false);
add(countLabel);
fileUploadField = new FileUploadField("file");
add(fileUploadField);
add(new TextArea("numbers").add(NumberValidator.getInstance())); // <--- My CustomValidator.
add(new Button("submitButton"));
final FeedbackPanel simpleFeedback = new FeedbackPanel("simpleFeedback");
add(simpleFeedback);
}
### My CustomValidator ###
public void onValidate(wicket.markup.html.form.FormComponent formComponent, String value) {
if(value == null) {
return;
} else {
if(value == null) {
return;
} else {
for(StringTokenizer tokenizer = new StringTokenizer(value, ","); tokenizer.hasMoreTokens(); ) {
String number = tokenizer.nextToken();
String number = tokenizer.nextToken();
if(!ValidatorUtil.isValidNumber(number)) {
error(formComponent);
break;
}
}
break;
}
}
}
}
}
### My Model ###
public class SubscriberGroup implements Serializable {
private String name;
private String description;
private String file;
private String numbers;
private int count;
private Date expireDate;
private String name;
private String description;
private String file;
private String numbers;
private int count;
private Date expireDate;
// just many setter & getter methods here ..
// ...
}
}
and some other question, can't file (or file's name) be populate into my model when submitted? like other textField (now I just write it to somewhere and custom set it's location to my model with model.setFile(myFilePath)).
BR,
black
Yahoo! FareChase - Search multiple travel sites in one click.
