0

如何渲染另一个?a4j:commandLink_ 在中,当我单击部门编辑时,无法渲染部门。我也尝试使用它不起作用并且没有显示任何错误。我不知道为什么。dataTableUI Componenth:formtableForma4j:commandLinkdatatableajaxentryFormajax:region

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

2 回答 2

0

您应该传递要使用 ajax 呈现的控件的完整 ID。一个基本的例子:

<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>
于 2012-09-24T13:41:20.237 回答
0

尝试使用属性 render="@all"。请使用 firebug 验证表单的渲染 ID 是否仅为“entryForm”,或者是否添加了一些 JSF 前缀。这可能是 render="entryForm" 不起作用的原因。

于 2012-09-24T11:04:19.870 回答