Reputation: 7
I am fairly new to wicket and have just come across setRequired.
I have 5 textfields
final TextField<String> mfnField = new TextField<>("mfn",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getMfn()));
form.add(mfnField);
mfnField.setOutputMarkupId(true);
form.add(new FdsInfoButton("mfn.infoButton", new ResourceModel("mfn.infoButton")));
form.add(new FormComponentFeedbackPanel("mfnFeedbackPanel", mfnField));
final TextField<String> pbField = new TextField<>("pid",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getPBId()));
form.add(pbField);
pbField.setOutputMarkupId(true);
form.add(new FormComponentFeedbackPanel("pidFeedbackPanel", pbField));
final TextField<String> gpidField = new TextField<>("gpid",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getGpid()));
form.add(gpidField);
gpidField.setOutputMarkupId(true);
form.add(new FormComponentFeedbackPanel("gpidFeedbackPanel", gpidField));
final TextField<String> tidField = new TextField<>("tid",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getTransaction_id()));
form.add(tidField);
form.add(new FdsInfoButton("tid.infoButton", new ResourceModel("tid.infoButton")));
form.add(new FormComponentFeedbackPanel("tidFeedbackPanel", tidField));
final TextField<String> ibanField = new TextField<>("iban",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getIban()));
form.add(ibanField);
ibanField.setOutputMarkupId(true);
form.add(new FormComponentFeedbackPanel("ibanFeedbackPanel", ibanField));
I have a fromfield and a tofield:
final DateTimePicker fromInput = new DateTimePicker("from",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getFromDate()),
DateTimePicker.START_OF_DAY);
form.add(fromInput);
form.add(new FormComponentFeedbackPanel("fromFeedbackPanel", fromInput));
final DateTimePicker toInput = new DateTimePicker("to",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getToDate()),
DateTimePicker.END_OF_DAY);
form.add(toInput);
form.add(new FormComponentFeedbackPanel("toFeedbackPanel", toInput));
Out of the 5 textfields:
My question is how do I set the true and false.
Or is there something else I can use other than setRequired?
Upvotes: 0
Views: 173
Reputation: 7
I found the solution: I had to use isRequired and not setRequired
final DateTimePicker fromInput = new DateTimePicker("from",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getFromDate()),
DateTimePicker.START_OF_DAY) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isRequired() {
return Strings.isBlank(tidField.getConvertedInput());
}
};
form.add(fromInput);
form.add(new FormComponentFeedbackPanel("fromFeedbackPanel", fromInput));
final DateTimePicker toInput = new DateTimePicker("to",
model(criteriaModel, on(RechercheServiceFunctionCriteria.class).getToDate()),
DateTimePicker.END_OF_DAY) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isRequired() {
return Strings.isBlank(tidField.getConvertedInput());
}
};
form.add(toInput);
Upvotes: 1