Richfaces inplaceInput在数据表中不更新支持bean中的值

时间:2013-10-01 10:11:40

标签: java richfaces jsf-1.2

我尝试在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和RichFaces 3.3.X.描述的解决方案here引用了更新的版本。如何将编辑后的值保存在辅助bean中?

1 个答案:

答案 0 :(得分:0)

我在下面的代码中使用了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触发器赋予新值。