繁体   English   中英

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

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

我正在尝试使用rich:dataTable中的rich:inplaceInput实现可编辑的行。 这里的问题是,编辑后的值未反映在支持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>

单击“保存”按钮,将在支持bean中提供一个空字符串。 我试过使用a4j:actionParam从客户端读取值,但这也不起作用:

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

我仅限于JSF 1.2和RichFaces3.3.X。 此处描述的解决方案引用了较新的版本。 如何将编辑后的值保存在备用bean中?

我在以下代码中将Seam组件用作后备bean和值更改侦听器。 希望这可以帮助。

<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();
    }
}

提示:setter也具有someString触发器的新值。

暂无
暂无

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

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