简体   繁体   English

数据表中的Richfaces inplaceInput不更新后备bean中的值

[英]Richfaces inplaceInput within a datatable not updating values in backing bean

I'm trying to implement editable rows using rich:inplaceInput within a rich:dataTable. 我正在尝试使用rich:dataTable中的rich:inplaceInput实现可编辑的行。 The issue here is that the edited value is not reflected in the backing bean. 这里的问题是,编辑后的值未反映在支持bean中。

<rich:column width="200px">
    <f:facet name="header">
        <h:outputText value="Roles" />
    </f:facet>

    <rich:inplaceInput id="roleText" value="#{role}" inputWidth="60px" controlsHorizontalPosition="right" 
                        showControls="true" editEvent="none">
        <f:facet name="controls">
            <h:panelGroup>
                <h:commandButton id="saveEdit" value="Save"
                                    action="#{manageRolesBean.editRoleAction}"
                                    image="/images/indicator_accept.gif" alt="Save" />

                <h:commandButton id="cancelEdit" value="Cancel"
                                    onclick="#{rich:component('rolesForm:roleText')}.cancel(); return false;"
                                    image="/images/indicator_reject.gif" alt="Cancel" />
            </h:panelGroup>
        </f:facet>
    </rich:inplaceInput>
</rich:column>

Clicking the Save button, gives an empty string in the backing bean. 单击“保存”按钮,将在支持bean中提供一个空字符串。 I've tried using a4j:actionParam to read the value from client side, but that doesn't work either: 我试过使用a4j:actionParam从客户端读取值,但这也不起作用:

<a4j:actionparam name="editedValue" value="#{rich:findComponent('roleText').value}" assignTo="#{manageRolesBean.role.name}" />

I'm limited to JSF 1.2 and RichFaces 3.3.X. 我仅限于JSF 1.2和RichFaces3.3.X。 The solution described here references a newer version. 此处描述的解决方案引用了较新的版本。 How do I save the edited value in the backing bean? 如何将编辑后的值保存在备用bean中?

I used Seam component as backing bean and value change listener in code below. 我在以下代码中将Seam组件用作后备bean和值更改侦听器。 Hope this helps. 希望这可以帮助。

<h:form>   
...
    <rich:column ...>        
        <rich:inplaceInput id="someString" value="#{someSeamComponent.someString}"
                           valueChangeListener="#{someSeamComponent.process}">
            <a:support event="onviewactivated"/>
        </rich:inplaceInput>
    </rich:column>
...
</h:form>

import org.jboss.seam.annotations.Name;
import javax.faces.event.ValueChangeEvent;

@Name("someSeamComponent")
public class SomeSeamComponent {
    private String someString;

    // getters and setters

    public void process(ValueChangeEvent event) {
        // event.getSource().getId() -> to distinguish the source. you may construct id using rowKeyVar or smth
        Object newVal = event.getNewValue();
    }
}

Hint: setter with new value for someString triggers as well. 提示:setter也具有someString触发器的新值。

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

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