开发者

Dynamic input values not updated in backing bean

I have created a dynamic input field which changes depending on the item type.

<h:panelGrid columns="2" cellpadding="10">
    <c:forEach items="#{tabVar.items}" var="itmVar">
        <h:outputText value="#{itmVar.label}:" />
        <c:if test="#{itmVar.isString}"> 
            <p:inputText id="#{itmVar.id}" value="#{itmVar.value}" required="#{itmVar.isEditable}" disabled="#{itmVar.isEditable}" valueChangeListener="#{tabBean.processValueChange}" maxlength="100" size="75" im开发者_StackOverflow社区mediate="true" onchange="form1.submit()"/>
        </c:if>
        <c:if test="#{itmVar.isDate}"> 
            <p:calendar id="#{itmVar.id}" value="#{itmVar.value}" required="#{itmVar.isEditable}" disabled="#{itmVar.isEditable}" valueChangeListener="#{tabBean.processValueChange}" onSelectUpdate="form1.submit();"/>
        </c:if>
        <c:if test="#{itmVar.isDouble}"> 
            <p:inputText id="#{itmVar.id}" value="#{itmVar.value}" required="#{itmVar.isEditable}" disabled="#{not itmVar.isEditable}" valueChangeListener="#{tabBean.processValueChange}" maxlength="100">
                <f:validateDoubleRange minimum="#{itmVar.minDouble}" maximum="#{itmVar.maxDouble}" />
            </p:inputText>                                                
        </c:if>
        <c:if test="#{itmVar.isInteger}"> 
            <p:inputText id="#{itmVar.id}" value="#{itmVar.value}" required="#{itmVar.isEditable}" disabled="#{not itmVar.isEditable}" valueChangeListener="#{tabBean.processValueChange}" maxlength="100">
                <f:validateLongRange minimum="#{itmVar.minLong}" maximum="#{itmVar.maxLong}" />
            </p:inputText>
        </c:if>
    </c:forEach>
</h:panelGrid>

Everything renders correctly, but when I change and submit the input values, then it does not get updated in the backing bean. How is this caused and how can I solve it?


#{tabBean.processValueChange} may not right. Its not possiable to use only 1 method for valueChangeListener for all value. Can u post your full code in ManagedBean ? is that on @SessionScope ? The right method for valueChangeListener may be like this:

public void saveStatus(ValueChangeEvent event) {
        Integer newValue = (Integer) event.getNewValue();//this is for save Status
        itmVar.setStatus(newValue);
    }

If you want to save a serial of value, u have to create a serial of method :) good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜