我在repeatview上插入输入(quickview)。当输入有错误时(例如:RequiredValidator),提交事件将停止,但错误不会显示。如何在重复视图上验证和显示错误?
AddBaseEstimatePanel.java
public class AddBaseEstimatePanel extends Panel {
private void initForm(final Form<Estimate> form, final FeedbackPanel feedbackPanel) {
...
IDataProvider<EstimateDetailModel> data = new ListDataProvider<EstimateDetailModel>(
listEstimateDetailModel);
final WebMarkupContainer mitsumoriDeitaShōsaiRowssTable = new WebMarkupContainer(
"mitsumoriDeitaShōsaiRowssTable");
final EstimateDetailListAddTable mitsumoriDeitaShōsaiRows = new EstimateDetailListAddTable(
"mitsumoriDeitaShōsaiRows", data, listEstimateDetailModel,
new ItemsNavigationStrategy(), 10, start, null) {
private static final long serialVersionUID = 3950744346751551366L;
@Override
protected void initRow() {
super.initRow();
// addNewItems(initProductEmptyRows(5));
}
@Override
protected void onCheckBoxChange(EstimateDetailModel model,
AjaxRequestTarget target) {
super.onCheckBoxChange(model, target);
if (model.isChecked()) {
deleteProductBtn.setEnabled(true);
} else {
deleteProductBtn.setEnabled(hasCheckBoxChecked());
}
checkAll = allCheckboxIsChecked();
target.add(deleteProductBtn, checkAllCheckbox);
}
@Override
protected void onKeyTeikyo(AjaxRequestTarget target) {
super.onKeyTeikyo(target);
addNewItems(initProductEmptyRows(1));
}
@Override
protected void countTotal(EstimateDetailModel model,
AjaxRequestTarget target, Component... components) {
if (model.getUnitPrice() == null || model.getQuantity() == null) {
return;
}
float _amount = model.getUnitPrice() * model.getQuantity();
countTotal -= model.getAmount();
model.setAmount(_amount);
countTotal += model.getAmount();
target.add(total);
target.add(components);
}
};
mitsumoriDeitaShōsaiRowssTable.add(mitsumoriDeitaShōsaiRows);
...
}
EstimateDetailListAddTable.java
public abstract class EstimateDetailListAddTable extends
QuickView<EstimateDetailModel> {
@Override
protected void populate(final Item<EstimateDetailModel> item) {
CheckBoxAjaxChange checkbox = new CheckBoxAjaxChange("checkbox",
new PropertyModel<Boolean>(item.getModel(), "checked")) {
private static final long serialVersionUID = 3455428602642567322L;
@Override
protected void onCheckChange(final AjaxRequestTarget target) {
if (item.getModelObject().isChecked()) {
selectedItems.add(item);
} else {
selectedItems.remove(item);
}
onCheckBoxChange(item.getModelObject(), target);
}
};
Label no = new Label("no", new PropertyModel<Integer>(item.getModel(),
"no"));
final Select2ChoiceBase<Product> codeSelect = new Select2ChoiceBase<Product>(
"code", new PropertyModel<Product>(item.getModel(), "product"),
new ProductIdProvider(products, estimateDetailModels)) {
private static final long serialVersionUID = 737457596926341699L;
@Override
protected void config() {
super.config();
getSettings()
.setFormatSelection(
"function(obj){ if(obj.id==0)return '';return obj.id; }");
}
};
final Select2ChoiceBase<Product> nameSelect = new Select2ChoiceBase<Product>(
"name", new PropertyModel<Product>(item.getModel(), "product"),
new ProductNameProvider(products, estimateDetailModels));
final NumberTextField<Float> amount = new NumberTextField<Float>(
"amount", new PropertyModel<Float>(item.getModel(), "amount")) {
private static final long serialVersionUID = -2316554599671359643L;
};
final NumberTextField<Integer> quantity = new NumberTextField<Integer>(
"quantity", new PropertyModel<Integer>(item.getModel(),
"quantity")) {
private static final long serialVersionUID = -5753172372351592833L;
@Override
public void renderHead(IHeaderResponse response) {
String script = "$('#" + getMarkupId()
+ "').number( true, 0 );";
response.render(OnDomReadyHeaderItem.forScript(script));
}
};
quantity.setOutputMarkupId(true);
final TextField<String> unit = new TextField<String>("unit",
new PropertyModel<String>(item.getModel(), "product.unit")) {
private static final long serialVersionUID = -2316554599671359643L;
@SuppressWarnings("unchecked")
@Override
public <C> IConverter<C> getConverter(Class<C> type) {
return (IConverter<C>) new UnitConverter();
}
};
final NumberTextField<Integer> price = new NumberTextField<Integer>(
"price", new PropertyModel<Integer>(item.getModel(),
"unitPrice")) {
private static final long serialVersionUID = -8646496003644699535L;
};
unit.setOutputMarkupId(true);
price.setOutputMarkupId(true);
amount.setOutputMarkupId(true);
quantity.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1563937210317123609L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
onQuantityChange(item.getModelObject(), target, amount);
}
});
price.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = -8638379626220896934L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
onPriceChange(item.getModelObject(), target, amount);
}
});
codeSelect.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 7159818718453062684L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
onCodeChange(item, target, nameSelect, quantity, unit, price,
amount);
}
});
nameSelect.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = -7575744336298650067L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
onNameChange(item, target, codeSelect, quantity, unit, price,
amount);
}
});
final TextArea<String> apply = new TextArea<String>("apply",
new PropertyModel<String>(item.getModel(), "tekiyo"));
apply.add(new AbstractDefaultAjaxBehavior() {
private static final long serialVersionUID = 3598447798201761103L;
@Override
protected void respond(AjaxRequestTarget target) {
onKeyTeikyo(target);
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
// response.render();
}
});
apply.add(StringValidator.maximumLength(40));
apply.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
// target.add(apply);
}
});
item.add(checkbox);
item.add(no);
item.add(codeSelect);
item.add(nameSelect);
item.add(quantity);
item.add(price);
item.add(unit);
item.add(amount);
item.add(apply);
// item.add(new EstimateDetailValidator(item.getModelObject()));
}
}
关于QuicketView:https://github.com/vineetsemwal/quickview
答案 0 :(得分:3)
此外,您应该将IValidator分配给FormComponent和/或IFormValidator分配给Form组件。向项目添加验证器不会做任何事情。
答案 1 :(得分:0)
刚刚在git上推送了master的更改,ReuseAllStrategy现在不应该显示重新呈现的陈旧数据,如果问题仍然存在或者新的更改破坏了其他一些事情;)在github中创建一个问题。 打算在早期答案中对你的问题发表评论,但意识到你应该有评论或投票的观点:)
(抱歉迟到的回复)