Multiple ajax calls clear previously submitted values ​​in a managed bean

I am having problems with multiple ajax calls on the same page. The first ajax call in the blur event populates the drop-down list. Then, when the button is pressed, the page should display "otherElement" based on the values ​​in the form. The problem is that the term "term" is in the last ajax call, and also causes the terms "CompanyCode" and "fileNumber" to be null in FormBean. When I statically populate the terms, it works.

<h:form id="createRequest">

            <h:selectOneMenu id="CompanyCode" required="true"
                value="#{FormBean.CompanyCode}"> 
                <f:selectItems value="#{utility.Companies}" />
            </h:selectOneMenu>
            <br/>

            <h:inputText id="fileNumber" styleClass="field"
                value="#{FormBean.fileNumber}"
                required="true">
                <f:ajax event="blur" execute="CompanyCode fileNumber"
                    render="term" />
            </h:inputText>
            <br />

            <h:selectOneMenu id="term" required="true"
                value="#{FormBean.term}">
                <f:selectItems value="#{FormBean.terms}" />
            </h:selectOneMenu>

            <br />

            <h:commandButton class="button" style="button"
                value="#{resources['btn.common.submitRequest']}">
                <f:ajax event="click"
                    execute="CompanyCode fileNumber term"
                    render="otherElement" />
            </h:commandButton>

        </h:form>

Any ideas? Thanks

+3
source share
1 answer

bean - , HTTP- (ajax ). /, ajax, . bean .

@ManagedBean
@ViewScoped
public class FormBean implements Serializable {
    // ...
}

, bean , void null .

. :

+2

All Articles