Seam:在丰富的:dataTable 行中更新 h:inputText 中的数据时遇到问题

问题描述 投票:0回答:1

我正在尝试构建一个可编辑表格来输入购买订单详细信息的值。我有一个绑定到列表的 rich:datatable,并且通过向列表添加元素来动态地将行添加到表中。该实体有两个必须手动输入的字段,因此我使用 h:inputTexts 来执行此操作,但在这些字段中输入的值不会保存到列表中的对象中。我也尝试使用 rich:inplaceInput 执行此操作(遵循 Exadel Richfaces livedemo 上的确切说明),但无济于事。这是我的代码:

    <rich:panel>
 <f:facet name="header">#{messages.DetalleOrdenCompra}</f:facet>
 <h:outputLabel value="#{messages.Codigo}" for="txtCodigo" /> #{'   '}     
 <h:inputText id="txtCodigo">
  <rich:suggestionbox id="suggestionBox" for="txtCodigo"
   var="consumible" fetchValue="#{consumible.conNombre}"
   suggestionAction="#{ordenCompraHome.autoComplete}" minChars="1"
   reRender="tablaDetOrdComp" ignoreDupResponses="true"
   bypassUpdates="false">
   <h:column>
    <f:facet name="header">#{messages.Codigo}</f:facet>
    <h:outputText value="#{consumible.conNumber}" />
   </h:column>
   <h:column>
    <f:facet name="header">#{messages.Descripcion}</f:facet>
    <h:outputText value="#{consumible.conNombre}" />
   </h:column>
   <a:support event="onselect" immediate="true"
    ignoreDupResponses="true" bypassUpdates="false">
    <f:setPropertyActionListener value="#{consumible}"
     target="#{ordenCompraHome.conActual}" />
   </a:support>
  </rich:suggestionbox>
 </h:inputText>
 #{'   '}
 <!-- Add elements to the list -->
 <a:commandButton type="button" value="#{messages.Agregar}"
  action="#{ordenCompraHome.anadirSeleccionadoADetalle()}"
  reRender="tablaDetOrdComp" immediate="true" />    

 <!-- Hitting this button after entering any values in the table below shows that the values are never updated -->
 <a:commandButton type="button" value="Refrescar tabla"
  reRender="tablaDetOrdComp" immediate="true" />
 <br />
 <br />
 <rich:dataTable value="#{ordenCompraHome.detalleOrdenCompra}"
  var="detOrdComp" id="tablaDetOrdComp" rowKeyVar="row">
  <rich:column width="5%">
   <f:facet name="header">
    <h:outputText value="#"></h:outputText>
   </f:facet>
   <h:outputText value="#{row+1}"></h:outputText>
  </rich:column>

  <!-- ... more columns, just data output -->

  <!-- The two following columns are user inputs -- no updates in the underlying list when entering any value, both values are always null -->
  <rich:column width="10%">
   <f:facet name="header">
    <h:outputText value="#{messages.Cantidad}"></h:outputText>
   </f:facet>
   <s:decorate template="layout/edit-nolabel.xhtml">
   <h:inputText value="#{detOrdComp.ordCantidad}" id="txtCantidad" required="true">
    <!-- tried with both events, onblur and onviewactivated, first each on on its own, then both together, no results -->       
    <a:support event="onblur" reRender="columnaMonto" immediate="true"
     bypassUpdates="false" ajaxSingle="true" />
    <a:support event="onviewactivated" reRender="columnaMonto" immediate="true"
     bypassUpdates="false" ajaxSingle="true" />
   </h:inputText>
   </s:decorate>      
  </rich:column>

  <rich:column width="10%">
   <f:facet name="header">
    <h:outputText value="#{messages.CostoUnitario}"></h:outputText>
   </f:facet>
   <s:decorate template="layout/edit-nolabel.xhtml">
    <h:inputText value="#{detOrdComp.ordCostoUnitario}"
     id="txtCostoUnitario" required="true">
     <a:support event="onblur" reRender="columnaMonto"
      immediate="true" bypassUpdates="false" ajaxSingle="true" />
     <a:support event="onviewactivated" reRender="columnaMonto" immediate="true"
      bypassUpdates="false" ajaxSingle="true" />
    </h:inputText>
   </s:decorate>
  </rich:column>

  <!-- This column is the result of a multiplication between txtCantidad and txtCostoUnitario -- I don't get anything here since both factors are null (null values have been properly handled so 0.0 is displayed when any of the factors is null) --> 

  <rich:column id="columnaMonto" width="10%">
   <f:facet name="header">
    <h:outputText value="#{messages.Monto}"></h:outputText>
   </f:facet>
   <h:outputText value="#{detOrdComp.ordSubparcial}"></h:outputText>
  </rich:column>
 </rich:dataTable>

豆:

// Underlying list. I used just @DataModel, then @DataModel(scope = ScopeType.PAGE), no results
 @DataModel(scope = ScopeType.PAGE)
 public List<OrdenCompraDetalle> getDetalleOrdenCompra() {
   return detalleOrdenCompra;
 }

我之前使用过类似的东西(来自 Livedemo),而不是 s:decorates,但它也不起作用

<rich:dataTable value="#{dataTableScrollerBean.allCars}" var="car" width="350px" columnClasses=",columns,columns,columns" rows="15" id="table" rowKeyVar="row">
<rich:column>
    <f:facet name="header">
        <h:outputText value="Price" />
    </f:facet>
    <rich:inplaceInput layout="block" value="#{car.price}"          
        id="inplace" required="true" selectOnEdit="true" editEvent="ondblclick">                        
            <a4j:support event="onviewactivated" reRender="table, messages"/>
    </rich:inplaceInput>
</rich:column>

我在这里缺少什么?任何帮助,将不胜感激。预先感谢。

jsf input datatable richfaces seam
1个回答
1
投票

我认为你的问题是

ajaxSingle="true"
属性。该属性意味着,即使表单中的所有输入元素都已提交,也只会处理触发提交的输入。

如果这是问题所在,您可以尝试以下任一方法(我假设

a
前缀是常见的
a4j
前缀?):

  • h:inputText
    的id添加到
    processed
    属性到
    <a:support>
    。这将强制处理特定行的输入。例如(未测试):

     <h:inputText value="#{detOrdComp.ordCostoUnitario}"
      id="txtCostoUnitario" required="true">
      <a:support event="onblur" reRender="columnaMonto"
       immediate="true" bypassUpdates="false" ajaxSingle="true" processed="txtCostoUnitario" />
      <a:support event="onviewactivated" reRender="columnaMonto" immediate="true"
       bypassUpdates="false" ajaxSingle="true" processed="txtCostoUnitario"/>
     </h:inputText>
    
  • 删除

    ajaxSingle
    并将
    <h:inputText>
    包围在
    a4j:region
    中(类似于处理过的 ajaxSingle,这里处理最近/封闭区域中的所有输入):

     <a4j:region>
       <h:inputText value="#{detOrdComp.ordCostoUnitario}" id="txtCostoUnitario" 
               required="true">
           <a:support event="onblur" reRender="columnaMonto"
                  immediate="true" bypassUpdates="false" />
           <a:support event="onviewactivated" reRender="columnaMonto" 
               immediate="true" bypassUpdates="false" />
       </h:inputText>
     </a4j:region>
    
  • 删除

    ajaxSingle
    。这将导致表单中的所有元素都被处理。需要更多时间。

© www.soinside.com 2019 - 2024. All rights reserved.