gpt4 book ai didi

javascript - 如何在某些情况下禁用 wicket 的 setRequired

转载 作者:行者123 更新时间:2023-12-02 10:28:36 29 4
gpt4 key购买 nike

我对 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 个文本字段中:

  • 如果在前四个中输入了任何内容,那么我还需要输入 fromfield 和 tofield,因此对于此 setRequired 应该为 true
  • 但如果 tidField 中输入了任何内容,无论其他文本字段是空还是已填充,setRequired 对于 frominput 和 toinput 都应该为 false。

我的问题是如何设置 true 和 false。

或者除了 setRequired 之外我还可以使用其他东西吗?

最佳答案

我找到了解决办法:我必须使用 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);

关于javascript - 如何在某些情况下禁用 wicket 的 setRequired,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53743267/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com