2014-12-04 6 views
1

'포함 된 페이지 1로 이동'(page2.xhtml)을 클릭하면 centerPanel (index.xhtml)이 비어 있고 doNav 메소드가 다음과 같이 호출되지 않습니다.ui : 구성 요소 내부에서 primefaces 패널 업데이트

index.xhtml

<p:layout fullPage="true"> 

       <p:layoutUnit position="west" size="245"> 
        <h:form> 
         <p:menu> 
          <p:submenu label="Resources"> 
           <p:menuitem value="Page 1" actionListener="#{navBean.doNav}" update=":centerPanel"> 
            <f:param name="page" value="page1" /> 
           </p:menuitem> 
           <p:menuitem value="Page 2" actionListener="#{navBean.doNav}" update=":centerPanel"> 
            <f:param name="page" value="page2" /> 
           </p:menuitem> 
          </p:submenu> 
         </p:menu> 
        </h:form> 
       </p:layoutUnit> 


       <p:layoutUnit position="center"> 
        <p:panel id="centerPanel"> 
         <c:if test="#{navBean.page != null}"> 
          <ui:include src="#{navBean.page}.xhtml" /> 
         </c:if> 
        </p:panel> 
       </p:layoutUnit> 


      </p:layout> 

page1.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> 

     Page 1 

    </ui:composition> 

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
       xmlns:ui="http://xmlns.jcp.org/jsf/facelets" 
       xmlns:p="http://primefaces.org/ui" 
       xmlns:f="http://xmlns.jcp.org/jsf/core"> 

page2.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
       xmlns:ui="http://xmlns.jcp.org/jsf/facelets" 
       xmlns:p="http://primefaces.org/ui" 
       xmlns:f="http://xmlns.jcp.org/jsf/core"> 

    <h3>Page 2</h3> 

    <p:commandButton value="Go to page 1 from included" actionListener="#{navBean.doNav}" update=":centerPanel"> 
     <f:param name="page" value="page1" /> 
    </p:commandButton> 

</ui:composition> 

NavBean

@ManagedBean(name = "navBean") 
public class NavBean { 

    private String page = null; 

    public void doNav() { 
     this.page = FacesContext.getCurrentInstance().getExternalContext() 
       .getRequestParameterMap().get("page"); 
    } 

    public String getPage() { 
     return page; 
    } 

    public void setPage(String page) { 
     this.page = page; 
    } 

} 

내가이 작업을 수행 할 수 있습니다 어쨌든 있나요?

답변

1

범위를 지정하지 않아 NavBean이 @NoneScoped입니다. @NoneScoped은 표현식에서 참조 할 때마다 NavBean이 만들어 지므로 페이지 변수를 사용할 때 설정되지 않았습니다. NavBean의 범위를 적어도 @ViewScoped으로 지정해야합니다. 뿐만 아니라 이러한 질문을 읽어 :

+0

오 잘, 감사합니다! –

관련 문제