1

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

Niko
  • 23
  • 4
  • Are you 100% sure the 'remote.xhtml' is included from a remote server. I very strongly doubt it is. https://stackoverflow.com/questions/11965157/uiinclude-can-not-include-pages-with-different-server-context – Kukeltje Feb 03 '18 at 18:15
  • Well they are on two different glassfish instances. One resides on localhost:8680 the other is on localhost:8880. – Niko Feb 03 '18 at 18:55
  • That's the same (another server). Unless you have some customs resource resolver this won't work but then it is not a remote server anymore. – Kukeltje Feb 03 '18 at 19:00
  • what do you mean by custom ressource resolver? And why is in not a remote server anymore? What i want to do is a microservice base web application with each MS having its own UI. The frontend MS includes the UI of the other MSs. – Niko Feb 03 '18 at 19:51
  • Ahh... I have a deja-by now. Just re-read you earlier question. A custom resource resolver can load a sec for a ui:include from anywhere but for the ui:include it looks like it is local. A plain src for a ui:include can without a resourceresolver not be anything outside the current webapp. So your assumption in the question is 'wrong'. It does not come from a remote server. See https://stackoverflow.com/questions/11965157/uiinclude-can-not-include-pages-with-different-server-context – Kukeltje Feb 03 '18 at 21:07
  • See the suggestion on your other question... the custom resource resolver... did you even read that comment? People appreciate it you reply if they try to help you. – Kukeltje Feb 03 '18 at 21:10
  • I read it. But this is facelet composition. I thought it is different with ui:include. – Niko Feb 05 '18 at 07:40
  • Then please next time state what you 'think'. Resolving resources is used for both (And more).Read it again, BalusC improved it. – Kukeltje Feb 05 '18 at 07:44

1 Answers1

0

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.

Niko
  • 23
  • 4