Reputation: 167
I have a simple form in wicket, there is an field with template name and few checkboxes, with overriden onSelectionChange methods. When I put some text in textfield from page parameters
@Override
protected void onInitialize() {
super.onInitialize();
if (PageParameters.get("templateName").toString() != null) {
OfferTemplate offerTemplate = huskyService.getTemplate(PageParameters.get("templateName").toString());
offerTemplateFormModel.setTemplateName(offerTemplate.getTemplateName());
and I mark checkbox
add(new CheckBox("htmlCheckbox", new Model<Boolean>(Boolean.TRUE)) {
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected void onSelectionChanged(Boolean newSelection) {
super.onSelectionChanged(newSelection);
isHtmlVisible = !isHtmlVisible;
htmlTemplate.setRequired(isHtmlVisible);
offerTemplateFormModel.setHtmlCheckbox(isHtmlVisible);
htmlDiv.setVisible(isHtmlVisible);
}
});
it automatically add for words in my input field. for example it was "hey" then after click it will be "hey;hey" and etc. Maybe someone could help?
Upvotes: 0
Views: 180
Reputation: 5681
I assume your input's name is "templateName"? In that case that parameter will be sent twice when wantOnSelectionChangedNotifications
triggers a request.
Please give your input a different name than your page parameter.
Upvotes: 1
Reputation: 17503
It seems offerTemplateFormModel.setTemplateName(...)
is called again.
This is strange because onInitialize()
is called only once for the lifetime of a Page/Component. If you were using onConfigure()
then it would be normal behavior to observe.
If the page is stateless then a new instance is created for each request and then most probably the value in the request parameters accumulates the old values.
Upvotes: 0