2013-03-15 66 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