首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Richfaces 4,a4j:命令渲染另一个h:form

Richfaces 4,a4j:命令渲染另一个h:form
EN

Stack Overflow用户
提问于 2012-09-24 15:53:37
回答 2查看 3.9K关注 0票数 0

dataTable中的a4j:commandLink如何渲染另一个h:formUI Component?在tableForm中,当我点击编辑部门datatablea4j:commandLink时,ajax无法渲染部门的entryForm。我也尝试使用ajax:region,它不工作,也没有显示任何错误。我不知道为什么。

代码语言:javascript
运行
复制
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.org/schema/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    template="/layout/adminTemplate.xhtml">
    <ui:define name="body">
        <h:form id="entryForm">
            <h:outputText value="Edit Department" styleClass="subTitle"/>
            <h:panelGrid columns="2">
                <h:outputText value="Name : " styleClass="inputLabel"/>
                <h:inputText value="#{ManageDepartmentAction.department.name}" styleClass="inputText"/>

                <h:outputText value="Description : " styleClass="inputLabel"/>
                <h:inputTextarea value="#{ManageDepartmentAction.department.description}" cols="50" rows="6"/>      
            </h:panelGrid>
            <h:commandButton id="editBtn" value="Edit"  action="#{ManageDepartmentAction.editDepartment}"/>     
        </h:form> <br/>
        <h:form id="tableForm">
            <rich:dataTable value="#{ManageDepartmentAction.departmentList}" var="dep" id="departmentTable"
                            style="width:100%" rowKeyVar="index">
                <rich:column sortBy="#{dep.id}" style="width:200px;">
                    <f:facet name="header">
                        <h:outputText value="Department ID"/>
                    </f:facet>
                    <h:outputText value="#{dep.id}" styleClass="tableContent"/>
                </rich:column>
                <rich:column sortBy="#{dep.name}">
                    <f:facet name="header">
                        <h:outputText value="Name"/>
                    </f:facet>
                    <h:outputText value="#{dep.name}" styleClass="tableContent"/>
                </rich:column>
                <rich:column sortBy="#{dep.description}">
                    <f:facet name="header">
                        <h:outputText value="Description"/>
                    </f:facet>
                    <h:outputText value="#{dep.description}" styleClass="tableContent"/>
                </rich:column>
                <rich:column style="width:100px;text-align:center;">
                    <a4j:commandLink value="Edit-1" action="#{ManageDepartmentAction.prepareEditDepartment(dep)}" render="entryForm"/>

                    <a4j:commandLink value="Edit-2" action="#{ManageDepartmentAction.prepareEditDepartment(dep)}" render=":entryForm"/>

                    <a4j:commandLink value="Edit-3" action="#{ManageDepartmentAction.prepareEditDepartment(dep)}" render="tableForm :entryForm"/>
                </rich:column>
            </rich:dataTable>
        </h:form>
    </ui:define>
</ui:composition>

@Scope(CONVERSATION)
@Name("ManageDepartmentAction")
public class ManageDepartmentAction {

    public List<Department> departmentList;

    @In("#{DepartmentService}")
    private IDepartmentService departmentService;

    @Out(value = "department", required = false)
    private Department department;

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public boolean isCreateNew() {
        return createNew;
    }

    @Begin(nested = true)
    public void init() {
        departmentList = departmentService.findAllDepartments();
    }

    public List<Department> getDepartmentList() {
        return departmentList;
    }

    public void prepareEditDepartment(Department department) {
        this.department = department;
    }

    public void editDepartment() {
        System.out.println("Edit Department Name : " + department.getName());
    }
}
EN

回答 2

Stack Overflow用户

发布于 2012-09-24 19:04:20

尝试使用属性render="@all“。请使用firebug验证表单的呈现id是否仅为"entryForm“,或者添加了一些JSF前缀。这可能是render="entryForm“无法工作的原因。

票数 0
EN

Stack Overflow用户

发布于 2012-09-24 21:41:20

你应该传递你想要用ajax呈现的控件的完整id。一个基本的例子:

代码语言:javascript
运行
复制
<h:form id="form1">
    <h:inputText id="txtSomeName" value="#{bean.name}" />
    <a4j:commandButton value="Click me" render=":form2:txtName" />
</h:form>
<h:form id="form2">
    <h:inputText id="txtName" value="#{bean.name}" />
</h:form>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12560915

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档