Friday, September 25, 2015

Portlet Modes in Liferay


By default Portlet API 2.0 provide 3 portlet modes. This means whether you use Liferay Portal, IBM WebSphere Portal or any other portal 3 modes are present.

Default modes are:-

  • VIEW
  • EDIT(Preferences)
  • HELP

In addition to above modes Liferay Provide 6 other modes :-

  • About
  • Config
  • Print
  • Edit Defaults
  • Edit Guest
  • Preview

Their are basically two steps for enable modes in Liferay:-
1)Provide entry in portlet.xml. Ex-For enable HELP mode
            <portlet-mode>help</portlet-mode>

2)Create jsp for that Mode.

So Lets enable all the modes step by step:-



Step 1:-Create Liferay Project
Inside eclipse IDE Click on File->New->Liferay plugin project



Provide Project name as modes and click finish.

Step 2:-Create Portlet inside Project
Right Click on your project ie modes and click on New than click on Liferay Portlet



Give Portlet Class as Demo and Select MVCPortlet in Superclass . Now Click Next.



By Default only view mode is selected . Now Select all the other modes and Click Finish.

Step 3:-Check portlet.xml
Just Open portlet.xml and you can see that eclipse ide provide all the entries automatically


Explanation:-
From line 48 to 56 you can see that all modes are supported.
From line 9 to 44 all init-param for jsp are also created.

Step 4:-Check Jsp files
Inside your project go to docroot/html/demo .Here you see all the jsp files with a simple message is already created as:-




Step 5:-Check Output
Deploy the portlet and add to the page. Now Click on gear icon:-



Now Click On Preferences for Edit Mode, Help for help mode etc.





Hope this will Help....

You can Download Source code from  Portlet Modes in Liferay.

In the next blog we see Edit Mode in Detail.

Related Post:-

No comments:

Post a Comment

Total Pageviews

Like Us on Facebook

Number Of Unique Visitor

Free counters!