malformedXML:索引或大小为负数或大于允许的数量

时间:2014-07-21 16:28:51

标签: ajax twitter-bootstrap jsf

我使用JSF 2.0和Twitter Bootstrap。

我试图在ajax请求后更改字段中的值。但是,当我更改值并且inputText丢失焦点时,我收到malformedXML错误。 xhtml文件如下所示:

<h:inputText value="#{product.count}>
    <f:ajax listener="#{orderBean.changeTotal} render="outputTotal" />
    <f:attribute name="productId" value="#{product.id}" />
</h:inputText>

.....

<h:outputText id="outputTotal" value="#{product.total}" />

.....

OrderBean有一个代码:

public void changeTotal(AjaxBehaviorEvent event) {

    Integer id = (Integer) event.getComponent().getAttributes().get("productId");
        for (FoProduct pio : fo_orderList) {

            if (pio.getId() == id) {

                pio.setTotal(pio.getCount() * pio.getPrice());

            }

        }
}

结果:总值已更改,JSF显示消息“mallformedXML:索引或大小为负数或大于允许的数量”

P.S。:Hector William的更多xhtml:

<ui:repeat value="#{orderBean.fo_orderList}" var="product">
<h:form>
<div class="col-md-3">
    <table class="table table-bordered table-hover table-condensed table-striped">
        <tr>
            <td>
                Count:
            </td>
            <td>
                <div class="input-group input-group-sm">
                    <h:inputText class="input-sm" value="#{product.count}" >
                      <f:ajax listener="#{orderBean.changeTotal}" render="outputTotal"/>
                        <f:attribute name="productId" value="#{product.id}" />
                    </h:inputText>
                </div>
             </td>
        </tr>
        <tr>
            <td>
                <h:outputLabel value="Price:" />
            </td>
            <td>
                <div class="input-group input-group-sm">
                    <h:outputText value="#{product.price}" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
               <h:outputLabel value="Total:" />
            </td>
            <td>
                <div class="input-group input-group-sm">
                    <h:outputText id="outputTotal" value="#{product.total}" />
                </div>
            </td>
        </tr>
     </table>
</h:form>
</ui:repeat>

0 个答案:

没有答案