p:dataTable中的数据太多会导致行/单元格编辑错误提交 [英] Too much data in p:dataTable results in broken row/cell edit submits

查看:220
本文介绍了p:dataTable中的数据太多会导致行/单元格编辑错误提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用数据表来允许用户输入和编辑大量数据,但是发现一旦达到了大量(但不确定)的列和行数量,表单就无法提交,所有这些都是直到执行页面刷新才会切断与服务器的通信形式(不相关的按钮,ajax等)。



这是我的电脑/浏览器的限制,还是在数据表中可以显示最多可编辑数据的硬编码限制吗?这可能是因为表单中输入字段数量的最大限制?



对于我的数据表,唯一的解决方案是使用paginator?



以下是一个例子,如果行/列数太多,将会失败(对我来说)。

 < h:form> 
< p:dataTable var =_ varvalue =#{bean.values}editable =true>

< p:column headerText =Value>
< p:cellEditor>
< f:facet name =output>< h:outputText value =#{_ var.value}/>< / f:facet>
< f:facet name =input>< p:inputText value =#{_ var.value}/>< / f:facet>
< / p:cellEditor>
< / p:column>

<! - 复制并粘贴此^列15次 - >

< p:column>
< p:rowEditor />
< / p:column>
< / p:dataTable>
< / h:form>




解决方案

发现了解决方案



显然,每个输入都作为GET / POST参数发送,并且服务器上的默认限制为512,以防止DoS攻击。



不幸的是,Primefaces似乎没有显示此错误,很难找到。

编辑:如果日志记录设置为正确的级别,则显示错误。 F12开发工具调试日志中也显示错误。



简而言之,你必须去你的服务器 standalone.xml 并添加:

 < property name =org.apache.tomcat.util.http.Parameters.MAX_COUNT value =10000/> 

< system-properties> / p>

编辑



我拒绝放弃一个更好的解决方案,参数,并重新审视此问题。



似乎PrimeFaces 5.2添加在< p:ajax partialSubmitFilter => 属性,它允许过滤你想要的输入。这对我来说并不奏效,因为我无法使用这一点将提交的数据缩小到行。



相反,我决定覆盖 PrimeFaces.ajax.Request.send 函数,如下所示:

  var pfsend = PrimeFaces .ajax.Request.send; 
PrimeFaces.ajax.Request.send = function(cfg){
if(cfg.event ==='rowEdit'|| cfg.event ==='rowEditCancel'){
/ /这是一个数据行的操作。仅为该行筛选
cfg.partialSubmitFilter ='[data-ri ='+ cfg.ext.params [0] .value +']:input';
}
pfsend(cfg); //运行原来的函数
};

以这种方式,cfg的第一个参数的值(正在编辑的行)用作查找属性 data-ri 设置为该值(该行)的元素的值。



请注意,这个 要求您使用原点5.2,但对于旧版本,可以通过覆盖整个程序包来实现相同的操作,并将相似的行在相同功能的正确位置进行操作(请记住,cfg.partialSubmitFilter不会存在)。


I've been using datatables to allow users to enter and edit large amounts of data, but have found that once a large (but uncertain) amount of columns and rows are reached, the form becomes unable to be submitted, and all forms of communication with the server are cut off (unrelated buttons, ajax, etc) until a page refresh is performed.

Is this a limitation of my computer/browser, or is there a hard-coded limit on the maximum quantity of editable data able to be displayed in a datatable? Could this be because of a maximum limit to the number of input fields in a form?

Is the only solution to use paginator for my datatables?

The following is an example that will fail (for me) to be editable if there are too many rows/columns.

<h:form>
  <p:dataTable var="_var" value="#{bean.values}" editable="true">

    <p:column headerText="Value">
      <p:cellEditor>
        <f:facet name="output"><h:outputText value="#{_var.value}" /></f:facet>
        <f:facet name="input"><p:inputText value="#{_var.value}" /></f:facet>
      </p:cellEditor>
    </p:column>

    <!-- Copy and paste this^ column 15 times -->

    <p:column>
      <p:rowEditor />
    </p:column>
  </p:dataTable>
</h:form>

解决方案

Okay, I found a solution.

Apparently each input is sent as a GET/POST parameter, and there is a default limit of 512 on servers to prevent DoS attacks.

Unfortunately, Primefaces does not seem to display this error, making it very hard to find.
EDIT: It displays the error, if the logging is set to the correct level. The error is also displayed in the F12 developer tools debugging log.

In short, you must go to your servers standalone.xml and add:

  <property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="10000"/>

Under <system-properties>

EDIT

I refused to give up on a better solution than sending thousands of parameters, and revisited this problem.

It seems that PrimeFaces 5.2 added in the <p:ajax partialSubmitFilter=""> attribute, which allows filtering the inputs that you want. This didn't work for me, as I couldn't narrow down the submitted data to the row using just this.

Instead, I decided to override the PrimeFaces.ajax.Request.send function, like so:

var pfsend = PrimeFaces.ajax.Request.send;
PrimeFaces.ajax.Request.send = function(cfg) {
    if (cfg.event === 'rowEdit' || cfg.event === 'rowEditCancel') {
        // This is an operation on a datatable row. Filter for only that row
        cfg.partialSubmitFilter = '[data-ri=' + cfg.ext.params[0].value + '] :input';
    }
    pfsend(cfg); // Run the original function
};

In this way, the value of the first parameter of the cfg (which is the row being edited) is used as the value for finding an element with the attribute data-ri set to that value (the row).

Note that this does require you to have primefaces 5.2, but for older versions, the same can be achieved by overriding the entire package, and tactically placing similar lines in the right place of the same function (mind that cfg.partialSubmitFilter will not exist).

这篇关于p:dataTable中的数据太多会导致行/单元格编辑错误提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆