1
votes

In a project we are using Liferay with JSF and Facelets for views.

We want to use only one portlet with many Facelets pages and many backing beans.

For that we have thought to provide a menu bar (which is right now in the portlet only, on top) outside of the portlet and from there we need to show appropriate pages based on user selection on menu items.

I'm not sure how can I show the appropriate page from the Facelet because everytime I try it shows the first page on it.

1

1 Answers

1
votes

- The Menu bar and the page to redirect to are in the same portlet

If the menu bar is in the JSF portlet, you have only to define a JSF navigation-rule in your faces-config.xml file to navigate to the new view.

For example, consider that home.xhtml is the main portlet view (default portlet view) and that doAction() is the method in the managedBean that handle the click on the menu.

public String doAction() {
   return "go_to_page";
}

and in the faces-config.xml

<navigation-rule>
    <from-view-id>home.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>go_to_page</from-outcome>
        <to-view-id>page.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

- The Menu bar and the page to redirect to are not in the same portlet

But if the menu is in another portlet and you don't want to redirect, you have to use IPC (inter portlet communication) to change the view of the JSF Portlet. I wrote this tutorial that may help you to perform the IPC between JSF portlets.