Search code examples
jsfrichfacesmanaged-beanajax4jsf

Edited value not reflected in managed bean


I am trying to edit values (say Name) populated in jsf data table. The snippet of jsf edit value form is as below.

<h:column>
<f:facet name="header">
<h:outputLabel value="Name"></h:outputLabel>
</f:facet>
<h:inputText 
value="#{maintenancedisplay.carrierMaintenanceResult.name}" > 
</h:inputText>
</h:column>

<a4j:region>
<a4j:commandButton value="Save"
onclick="#{rich:component('ajexLoad')}.show();"
oncomplete="#{rich:component('ajexLoad')}.hide();"
title="Save Details"
action="#{maintenancedisplay.saveChanges}"
reRender="growlGrp,modelpanelGroup1" immediate="true">
</a4j:commandButton>
</a4j:region>

But on click of save button, the old value is going back to the managed bean not the edited value.

I have tried adding the binding attribute as below. But still it is not working.

<h:column>
<f:facet name="header">
<h:outputLabel value="name"></h:outputLabel>
</f:facet>
<h:inputText 
value="#{maintenancedisplay.carrierMaintenanceResult.name}" binding="#{maintenancedisplay.name}"> 
</h:inputText>
</h:column>

After adding the binding attribute, changed the setter method as follows:

public void setname(HtmlInputText  name) {
        this.name = name;
        System.out.println("name:" + name.getValue());
    }

In the console log, I am getting old value not the updated value.

Please point me the mistake i'm doing here.

Thanks for suggestions!


Solution

  • The problem mentioned in the question is solved when the additional <a4j:region> tag around <a4j:commandButton> is removed from the jsf from.

    The updated snippet is

    <a4j:commandButton value="Save"
    onclick="#{rich:component('ajexLoad')}.show();"
    oncomplete="#{rich:component('ajexLoad')}.hide();"
    title="Save Details"
    action="#{maintenancedisplay.saveChanges}"
    reRender="growlGrp,modelpanelGroup1" >
    </a4j:commandButton>
    

    Thanks BalusC for insights and suggestions.