2011-05-18 86 views
0

对Dojo DataGrid单元进行验证的最佳方式是什么?在所有可用的回调中,我没有找到任何方法来做到这一点,甚至没有办法。Dojo DataGrid验证

(我使用道场1.6。)

回答

1

我建议创建一个按钮应用/验证在网格中的数据,呼叫Ajax和方法PUT/{表}/{ID}(-1)和json数据项。

var jsItem = JSON.stringify(jsonRestReflexion.newItem); 
// function startAjax(xmlhttp, Url, callback, method, obj, headerName, headerValue) 
ajaxhttp = startAjax(ajaxhttp    ,jsonRestReflexion.getUrlRestFul()+jsonRestReflexion.newItem.id+"?query=validateEntity" 
       , callbackFromAjax, "PUT", jsItem 
       , "Content-Type", "application/json; charset=UTF-8"); 

在服务器中执行验证,并在标题中返回错误

callbackFromAjax = function() { 
       //addDiv(portletId, this.responseText); 
$("errorDetails").innerHTML = "Errors # " + this.getResponseHeader("ConstraintViolationsSize") + "<br/>"+ this.getAllResponseHeaders(); 
showDialog(); 
      } 

然后打开一个dojo.dialog从服务器返回一个关闭按钮 或任何你喜欢的错误显示执行错误。

我使用了以下技术:

  • 排名靠前JPA 1.0和验证注释
  • 其余-球衣
  • 的Tomcat 6
  • 休眠验证4
  • springframework的3.0
  • MySQL的5
  • 道场1.6

好运

+0

我会选择这个答案,虽然它不是我最终做的。我最终抛弃了Dojo,因为它很糟糕。 – 2011-09-29 21:05:22