AjaxFormLoop 在提交后不填充新创建的表单元素的值
有人可以指出在表单提交期间代码中的何时/何处,ajaxformloop 复制了新添加的行结果 我指的是以下示例代码 - http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1
我有一个类似的代码,以下是我的 ValueEncoder
@Log
public ValueEncoder<Promotion> getPromotionEncoder() {
return new ValueEncoder<Promotion>() {
@Log
public String toClient(Promotion promo) {
log.debug("toClient id="+promo.getId());
if (promo.getId() == 0)
{
return NEW_PROMOTION;
}
return new Long(promo.getId()).toString();
}
@Log
public Promotion toValue(String id) {
log.debug("toValue id="+id);
Promotion promotion = null;
if (id.equals(NEW_PROMOTION))
{
promotion = new Promotion();
newPromotions.add(promotion);
}
else
{
promotion = crudService.findUniqueWithNamedQuery(Promotion.BY_ID,
QueryParameters.with("id", new Long(id).longValue()).parameters());
}
return promotion == null? new Promotion(): promotion;
}
};
}
当表单提交后调用 onSuccess()
方法时,我无法访问我存储的新创建的行的值在上面的 toValue()
方法中的 newPromotions
中。
感谢对此的任何帮助。
Can someone please point out when/where in the code during the form submission, ajaxformloop copies the newly added row results
I'm referring to the following example code -
http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1
I've a similar code, following is my ValueEncoder
@Log
public ValueEncoder<Promotion> getPromotionEncoder() {
return new ValueEncoder<Promotion>() {
@Log
public String toClient(Promotion promo) {
log.debug("toClient id="+promo.getId());
if (promo.getId() == 0)
{
return NEW_PROMOTION;
}
return new Long(promo.getId()).toString();
}
@Log
public Promotion toValue(String id) {
log.debug("toValue id="+id);
Promotion promotion = null;
if (id.equals(NEW_PROMOTION))
{
promotion = new Promotion();
newPromotions.add(promotion);
}
else
{
promotion = crudService.findUniqueWithNamedQuery(Promotion.BY_ID,
QueryParameters.with("id", new Long(id).longValue()).parameters());
}
return promotion == null? new Promotion(): promotion;
}
};
}
When onSuccess()
method is called after the form submission, I can't access the values of the newly created rows which I store in newPromotions
in the toValue()
method above.
Appreciate any help on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在 toClient 中的比较是错误的:
当你实例化一个新的促销时,它的 ID 很可能不是零,而是 NULL。
Jumpstart ValueEncoder 是这样做的:
因此你的 toValue 方法也会失败:)
Your comparison in toClient is wrong:
when you instantiate a new Promotion, it's ID is most likely not zero, but NULL.
The Jumpstart ValueEncoder is doing it like this:
Therefore your toValue method fails too :)