简体   繁体   English

编辑后的值未反映在托管Bean中

[英]Edited value not reflected in managed bean

I am trying to edit values (say Name) populated in jsf data table. 我正在尝试编辑jsf数据表中填充的值(例如Name)。 The snippet of jsf edit value form is as below. jsf编辑值形式的代码段如下。

<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. 但是,单击“ save按钮后,旧值将返回到托管Bean,而不是已编辑的值。

I have tried adding the binding attribute as below. 我尝试添加如下所示的binding attribute 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: 添加绑定属性后,更改setter方法,如下所示:

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! 感谢您的建议!

The problem mentioned in the question is solved when the additional <a4j:region> tag around <a4j:commandButton> is removed from the jsf from. 从jsf中删除<a4j:commandButton>周围的其他<a4j:region>标记时,该问题中提到的问题已解决。

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. 感谢BalusC的见解和建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM