2012-09-24 3 views
0

a4j:commandLinkdataTableUI Component 중 하나를 h:form으로 렌더링합니까? tableFormdatatable 부서의 a4j:commandLink을 클릭하면 ajax이 부서의 entryForm을 렌더링 할 수 없습니다. 또한 ajax:region을 사용해도 작동하지 않으며 오류가 표시되지 않습니다. 이유를 모르겠습니다.Richfaces 4, a4j : 다른 h : 형식을 렌더링하는 명령

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

답변

0

render = "@ all"속성을 사용해보세요. 폼의 렌더링 된 ID가 "entryForm"인지 아니면 일부 JSF 접두사가 추가되었는지 여부를 확인하십시오. render = "entryForm"이 작동하지 않는 원인 일 수 있습니다.

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> 
+0

': form2'처럼 전체'h : form'을 렌더링하고 싶습니다. ''또는''는'DataTable'에 있어야합니다. – CycDemo