2013-03-15 69 views
0

將不會調用操作如果我放置在包含文件中,操作將不會回調bean。<h:commandLink>如果包含<ui:include>

主文件:

<h:form id="ifLogin"> 
    <h:panelGrid 
     rendered="#{userSession.isLogin}" 
     columns="2" columnClasses="columnAlignLeft, columnAlignRight" 
     border="0" cellpadding="0"> 

     <ui:include src="\test.xhtml" />   

    ... 

    </h:panelGrid> 
</h:form> 

包含文件(test.xhtml)

<!DOCTYPE html 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:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich"> 

    <h:panelGrid border="0" columns="4"> 
     <h:graphicImage value="#{msg.urlImageHome}" 
      style="height:26px;width:26px;" /> 
     <f:subview>    
      <h:commandLink value="#{msg.home}" style="font-size: small;" immediate="true" 
       action="#{pageNavigationBean.updateCeaAppName}"> 
       <f:param name="requestName" value="CEA_MAIN_PAGE" /> 
       <f:param name="ceaAppName" value="" />  
      </h:commandLink>  
     </f:subview> 
    </h:panelGrid> 
</ui:composition> 

解決方法是取出包括文件,直接放置代碼以如下主文件:

主文件(不含使用)

<h:form id="ifLogin"> 
    <h:panelGrid 
     rendered="#{userSession.isLogin}" 
     columns="2" columnClasses="columnAlignLeft, columnAlignRight" 
     border="0" cellpadding="0"> 


     <h:panelGrid border="0" columns="4"> 
      <h:graphicImage value="#{msg.urlImageHome}" 
       style="height:26px;width:26px;" /> 
      <f:subview>    
       <h:commandLink value="#{msg.home}" style="font-size: small;" immediate="true" 
        action="#{pageNavigationBean.updateCeaAppName}"> 
        <f:param name="requestName" value="CEA_MAIN_PAGE" /> 
        <f:param name="ceaAppName" value="" />  
       </h:commandLink>  
      </f:subview> 
     </h:panelGrid>   

    ... 

    </h:panelGrid> 
</h:form> 

我用richface 4.3.1奇怪的是,當我從本地GAE運行時,這個問題不會發生。如果使用包括隨後的行動將不會觸發在線部署後到GAE,問題occour(即

的是,在JSF的錯誤嗎?或者richface實施或GAE?任何幫助嗎?

+0

有未轉義的xml字符。不確定爲什麼行爲與ui不同:include和inlining。反正嘗試轉義>>>與> > > – Andrey 2013-03-17 03:37:03

回答

1

問題確定

它不會造成使用<ui:include>

問題就出來了,當包含文件是動態的,從後豆產生,例如:

<ui:include src="#{pageNavigationBean.appDropDownMenuUrl}" /> 

如果明確提及網址,它的工作,例如:

<ui:include src="\test.xhtml" /> 

那麼,如果從我的本地GAE運行,兩種方式都可以工作,但在部署在線時,我需要使用顯式位置,而不是從bean生成。可能是由於在客戶端保存狀態的GAE問題(javax.faces.STATE_SAVING_METHOD)。

0

我不能重現該問題具有完全相同的包括代碼(test.xhtml),但這裏有一些建議:

  1. 脫出「>」字符(替代由&gt;&gt;&gt;>>>
  2. 指定f:subviewid屬性(它是根據需要TLD )
  3. 將反斜槓('\')更改爲斜槓('/')。所以,包容是<ui:include src="/test.xhtml" />
+0

對不起>>>,我只是加入調試。包含文件顯示問題是如果我使用include,commandLink被點擊時動作bean不會被調用。 – songjing 2013-03-17 22:45:20

+0

@songjing嘗試修復第2和第3點。正如我所提到的那樣 - 當包含test.xhtml(使用正斜槓)時,您的test.xhtml可以正常工作。如果它不適合你 - 提供主文件的完整內容來重現問題。 – Andrey 2013-03-18 05:26:47