« Back to Liferay Faces

Deploying JSF Portlets via WSRP

(Redirected from How to deploy and test a WSRP Java Server Faces Portlet)

This is an article showing how to configure a WSRP Producer portlet on one instance of a Liferay Portal, and then configure a WSRP Consumer portlet on another instance of a Liferay Portal that renders the producer's content.

NOTE: This procedure assumes that you will be using two separate instances of the Liferay Portal, one instance for the Consumer Portlet and another instance for the Producer Portlet.  However, the Liferay WSRP implementation does not require this.

Install the WSRP Plugin #

First we need to install the code necessary to render and configure a WSRP Portlet on the Portal which will be designated as the Consumer.

  1. Start up your application server, and point your browser to http://localhost:8080/.
  2. Log into your Consumer portal as an admin.
  3. Click on "Go To" in the upper righthand corner, and from the dropdown menu click Control Panel.
  4. Click the "Store" link under the Marketplace heading.
  5. Click "Utility" in the Apps menu.
  6. Click "See All" in the utility portlet's upper right hand corner.
  7. Click on the "WSRP CE" portlet.
  8. Click on the "Free" button for this portlet.
  9. Check "Purchase This App for My Personal Account."
  10. Agree to the EULA and TOS.
  11. Click on the "Free" button.
  12. Click "See Purchased."
  13. Click "Download."
  14. Click "Install" (as an administrator).
  15. Click on the "Control Panel" link to refresh the control panel.
  16. Scroll down to the Portal section of the Control Panel sidebar on the left, and click on the new WSRP portlet link.
  17. Repeat these steps on the Producer Liferay portal to install the WSRP plugin on it as well.

Install a JSF Portlet to assign as a Producer #

  1. Go to http://www.liferay.com/.
  2. Sign in.
  3. Click on "Community."
  4. Click on "Liferay Faces" under Liferay Projects on the left.
  5. Click "Demos."
  6. Under JSF2 Portlet Binary Downloads, click the second link to download the 3.1.1-ga2 (Liferay 6.1.x) war file.
  7. Copy the downloaded war file into the producer's Liferay deploy directory.

Configure the Producer #

  1. Go back into the Producer's Control Panel an on the left sidebar click the WSRP plugin page under the Portal category.
  2. Click "Producers."
  3. Click "Add Producer."
  4. Name your producer something like "jsf2 producer."
  5. Select JSF2 in the menu under available on the right (it is from the war file you just deployed). 
  6. Click the left arrow to put it into the Current box.
  7. Click "Save."
  8. Copy the URL that is shown in the WSRP Porlets list for jsf2 producer.
  9. Test this url in a new browser tab to make sure that it shows some WSDL mark up.
  10. Modify the URL to use the Producer's ip address instead of "localhost."
  11. Retest the modified URL to make sure that it also shows the WSDL markup for the producer portlet.
  12. Send this URL to the admin of the Consumer portal.

Configure the Consumer #

  1. Go back into the Consumer's Control Panel an on the left sidebar click the WSRP plugin page under the Portal category.
  2. Click on the "Consumers" tab.
  3. Click "Add Consumer."
  4. Name the new consumer "jsf2  consumer."
  5. Paste in the producer's portlet URL. 
  6. Click "Save."
  7. Click on the "Actions" menu for jsf2 consumer on the right hand side of the WSRP page, and in the dropdown menu click "Manage Portlets."
  8. Click the "Add Portlet" button.
  9. Name the portlet "jsf2 wsrp portlet."
  10. Select JSF2 from the Remote Portlet dropdown menu.
  11. Click "Save."

Add the WSRP Consumer to a portal page on the Consumer #

  1. Click "Back to liferay.com" to get back to the front page of the Consumer portal.
  2. Add a page called "wsrp jsf2 bridge."
  3. Click on the new page.
  4. Click the "Add" menu in the top left corner.
  5. Fromt the dropdown select "More..."
  6. Under WSRP you should see the "jsf2 wsrp portlet."
  7. Add it to the test page.
  8. You should see portlet rendered on the page from the producer.
  9. There will be log entries in the producer's catalina.out log file under the producer's tomcat logs directory.
  10. Click Submit on the portlet and you should see the validation errors for required fields.
  11. Fill out the form completely and hit "Submit" at the bottom.
  12. The main div of the portlet will be rerendered with a "Thank you for applying for a job..." message.
  13. If you see the "Thank you..." message then the JSF2 portlets are working with WSRP, and the consumer is rendering from its producer.

Bonus: Modify to the Producer to do a full post back on submit #

  1. Shut down the producer portal.
  2. Check that the consumer portlet is no longer rendering.
  3. Edit the applicant.xhtml file in the liferay-portal-6.1.1/tomcat-7.0.27/webapps/jsf2-portlet/views/ directory on the producer.
  4. Remove the <f:ajax execute="@form" render="@form" /> call from under the submit button on the form.
  5. Just remove that whole line with the f:ajax tag.
  6. Startup your producer liferay portal.

Test your Consumer portlet for a full page refresh on submit (no ajax submit) #

  1. Check that the Consumer portal can now re-render that WSRP portlet on your test page of the Consumer portal.
  2. Fill out the form completely and hit "Submit" at the bottom.
  3. You shuld see a full page refresh with a "Thank you for applying for a job ..." message.
  4. If you see the "Thank you ..." message then JSF2 portlets are working with WSRP, and the consumers are rendering from their producers.
  5. If you see a a long URL with different characters and symbols in the address bar instead of the normal http://localhost:8080/web/guest/wsrp-jsf2-bridge one, that is also an indication of the full post back instead of an ajax submit.

See Also:

28 Attachments
Average (2 Votes)
The average rating is 4.5 stars out of 5.