Search code examples
jsf-2glassfish-4uiinclude

ui:include parameter passing does not work when remote page is included


I have a basic UI (index.html) that is divided into Header, Footer and Content. The content-page is either on the same (local.xhtml) server like the index.html or on another (remote.xhtml) server. Including the pages and dynamically reloading them with ajax works pretty good. But parameter passing only works on the local content page. The parameter is retrieved of a Bean called Login which also is on the same server as the index.html.

index.xhtml (excerpt):

<h:panelGroup id="content" layout="block">
    <ui:include src="#{contentLoader.page}" >
        <ui:param name="userName" value="#{login.userName}" />
    </ui:include>
</h:panelGroup>
<h:form>
    <f:ajax render=":content">
        <ul>
            <li><h:commandLink value="include1"
                        action="#{contentLoader.LocalPage}" /></li>
            <li><h:commandLink value="include2"
                        action="#{contentLoader.remotePage}" /></li>
        </ul>
    </f:ajax>
</h:form>

local.xhtml

<h:body>
 <ui:composition>
    <h:form id="form">

        <h:outputText value= "Local Page. Parameter is: #{userName}"/>

    </h:form>
 </ui:composition>
</h:body>

remote.xhtml

   <h:body>
      <ui:composition>
         <h:form id="form">

           <h:outputText value= "Remote Page. Parameter is: #{userName}"/>

        </h:form>
       </ui:composition>
    </h:body>

local.xhtml prints out: "Local Page. Parameter is: MyUser"

remote.xhtml only: "Remote Page. Parameter is: "

I am using Glassfish4 as WebServer and JSF2


Solution

  • Thank you. The hints in the comments solved my Problem. For now this works fine for me:

    <iframe> was solving my problem. Parameter passing within URL and JSF works brilliant.

    Just "including" the remote page with <iframe src="#{myBean.Url}"></iframe> and reading the parameter with JSF Function "#{param['param1']}"

    {myBean.Url} return a String in this format: localhost:8680/MyServiceservice/faces/myPage.html?param1=value1 with value1 being the parameter I want to transfer.