我对wicket很陌生,刚遇到setRequired。
我有5个文本字段
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));
我有一个fromfield和一个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));
在5个文本字段中:
我的问题是如何设置对与错。
或者除了setRequired之外,还有其他我可以使用的东西吗?
答案 0 :(得分:1)
我找到了解决方案: 我不得不使用isRequired而不是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);