jsf valuechangelistener未在输入类型编号中产生onchange事件

时间:2019-02-13 14:02:35

标签: jsf primefaces

我仅在一个小型项目中对其进行了测试。它起作用了,但是当我在实际项目中尝试它时,它就停止了工作。有人可以帮我吗?

在我的迷你项目中,它看起来像这样的xhtml文件:

<h:form>
    <table>
        <c:forEach items="#{inputBean.ingredList}" var="ingredamount" begin="1" end="#{inputBean.ingredList.size()}" varStatus="loop">
            <h:outputText value="&lt;/tr&gt;&lt;tr&gt;" escape="false" rendered="${loop.count.equals(1) or ((loop.count -1) % 2).equals(0)}" />
                <td>
                    <h:outputLabel class="lbl_ingredients" for="ingredient_amount_div_${loop.count}" value="#{inputBean.inputName}"/>
                    <h:inputText class="tbd_ingredients" id="ingredient_amount_div_${loop.count}" pt:type="number" pt:min="0" pt:max="50" 
                                 pt:value="#{ingredamount}" valueChangeListener="#{inputBean.resumeIngredients}">
                        <p:ajax event="change"  update="@form" process="@this"/>
                    </h:inputText>
                </td>
            <h:outputText value="&lt;/tr&gt;&lt;tr&gt;" escape="false" rendered="${(loop.count % 2).equals(0)}" />
        </c:forEach>
    </table>
<h:outputText value="#{inputBean.spinnerOldValue} -- #{inputBean.spinnerNewValue}" />

在我的Bean中,它看起来像这样:

public void resumeIngredients(javax.faces.event.ValueChangeEvent ev){
System.out.println("Ausgabe:"+ev.getOldValue() +"--" +ev.getNewValue());
this.spinnerOldValue = Integer.valueOf((ev.getOldValue()).toString());
this.spinnerNewValue = Integer.valueOf((ev.getNewValue()).toString());

}

在firefox中,您可以看到产生了onchange事件:

<td>
    <label for="j_idt5:ingredient_amount_div_1" class="lbl_ingredients">Inputspinner: </label>
    <input id="j_idt5:ingredient_amount_div_1" name="j_idt5:ingredient_amount_div_1" class="tbd_ingredients" onchange="PrimeFaces.ab({s:this,e:'change',p:'j_idt5:ingredient_amount_div_1',u:'j_idt5'});" min="0" max="50" type="number" value="0" />
</td>

在我的实际项目中,它看起来像在xhtml文件中:

<section id="menue_card" class="display_on">
    <c:forEach items="#{pizzaServiceController.cat_dishList}" var="categoryDishes" >
    <c:forEach items="#{categoryDishes.dishes}" var="dish" >
            <div class="dishes_and_ingredients">
            </div>

        <h:form id="frmMenuDown#{dish.dishId}">
            <div class="crown_pizza_ingredients" id="extra_ingredients_#{dish.dishId}">
                <div class="ingredient_wrapper">
                    <table>
                        <c:forEach items="#{dish.orderpositions.orderpositionsIngredientsCollection}" var="OrderPosIngred" >
                            <h:outputText value="&lt;/tr&gt;&lt;tr&gt;" escape="false" rendered="#{OrderPosIngred.ingredientId.ingredientId.equals(1) or ((OrderPosIngred.ingredientId.ingredientId -1) % 2).equals(0)}" />
                                <td class="ingred_tds">
                                    <div id="ingred_price_#{OrderPosIngred.ingredientId.ingredientId}" class="ingredien_name_amount">
                                        <div class="ingred_name_amount_wrapper">
                                            <h:outputLabel class="lbl_ingredients" for="ingredient_amount_div_#{OrderPosIngred.ingredientId.ingredientId}_#{dish.dishId}" value="#{OrderPosIngred.ingredientId.ingredientname}"/>
                                            <h:inputText class="tbd_ingredients" id="ingredient_amount_div_#{OrderPosIngred.ingredientId.ingredientId}_#{dish.dishId}" pt:type="number" pt:min="0" pt:max="50" 
                                                             pt:value="#{OrderPosIngred.ingredientsamount}" valueChangeListener="#{pizzaServiceController.resumeIngredients}">
                                                <p:ajax  update="@form" process="@this"/>
                                            </h:inputText>
                                            <h:outputText id="ingred_price#{OrderPosIngred.ingredientId.ingredientId}" value="#{OrderPosIngred.ingredientId.ingredientprice}">
                                                <f:convertNumber pattern="#0.00 €" />
                                            </h:outputText>
                                        </div>
                                    </div>
                                </td>
                            <h:outputText value="&lt;/tr&gt;&lt;tr&gt;" escape="false" rendered="#{(OrderPosIngred.ingredientId.ingredientId % 2).equals(0)}" />
                        </c:forEach>
                    </table>
                </div>
            </div>
            <h:commandLink class="res_link" action="#{pizzaServiceController.addOrderdetail(dish.dishId, pizzaServiceController.allIngredients.size())}" >
                <div id="dish_end_price_#{dish.dishId}" class="dish_endprice_div" >
                    <h:outputText value="#{dish.orderpositions.dbltotalprice}">
                        <f:convertNumber pattern="#0.00 € &#124; +" />
                    </h:outputText>
                </div>
            </h:commandLink>
        </h:form>
    </div>
</c:forEach>
</c:forEach>
</section>

在我的bean中,实际项目看起来像这样:

public void resumeIngredients(javax.faces.event.ValueChangeEvent ev){
    System.out.println("Ausgabe:"+ev.getOldValue() +"--" +ev.getNewValue());
}

在firefox中,如您所见,没有onchange事件:

<label for="frmMenuDown1:ingredient_amount_div_1_1" class="lbl_ingredients">Ananas</label>
<input id="frmMenuDown1:ingredient_amount_div_1_1" name="frmMenuDown1:ingredient_amount_div_1_1" class="tbd_ingredients" min="0" max="50" type="number" />

0 个答案:

没有答案