jsf-2navigationwebspherewebsphere-portaljsr286

navigation between jsf pages within one portlet on WebSphere Portal 8.0


I'm working on WebSphere Portal 8.0 and I am trying to make portlet with few faces. Can anyone share with me how can I make a simple link to other JSF site within one portlet? I mean, I was trying to use this, but it doesn't work:

<h:outputLink value="page2.xhtml">
    <h:outputText value="take me to the page2" />
</h:outputLink>

I'm redirected to the misterious link but I would like to stay on the same site but change face in this single portlet.


Solution

  • I have got answer.

    If you want use GET, use this:

    <h:link value="take me to the page2" outcome="page2" />
    

    Or by POST use:

    <h:form>
        <h:commandLink action="#{menager.navigateToPage2}" value="take me to the page2" />
    </h:form>
    

    and in faces-config.xml

    <managed-bean>
        <managed-bean-name>menadzer</managed-bean-name>
        <managed-bean-class>test.Menadzer</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>symbolAktywnejSpolki</property-name>
            <value>#{param.symbol}</value>
        </managed-property>
    </managed-bean>
    
    <navigation-rule>
        <display-name>index.xhtml</display-name>
        <from-view-id>index.xhtml</from-view-id>
        <navigation-case>
            <from-action>#{menager.navigateToPage2}</from-action>
            <from-outcome>page2</from-outcome>
            <to-view-id>page2.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
    

    and the class:

    public class Menager {
        ...
        public String navigateToPage2() {
            return "page2";
        }
    }
    

    and if you use WebSphere Portal add this, to the faces-config.xml:

    <application>
        <view-handler>com.ibm.faces20.portlet.FaceletPortletViewHandler</view-handler>
        <resource-handler>com.ibm.faces20.portlet.httpbridge.PortletResourceHandler</resource-handler>
        <el-resolver>com.ibm.faces20.portlet.PortletELResolver</el-resolver>
    </application>