Whe doEdit method is called in liferay? - liferay

Can anybody tell me how can we call doEdit method? Is it used to edit entire portlet or Elements of portlet. If possible try to give me demo application. Thanks.

doEdit method gets called when you open Preferences screen of portlet.
If you use edit mode in your portlet.xml and provide edit-jsp init paramter, you will able to see Preferences as option on clicking on wrench icon. When you click on that icon at that time doEdit method gets called jsp mentioned as edit-jsp will be rendered.

Let me start with a statement that EDIT mode is a mode in which portlet configuration is done (e.g. in a weather portlet, this mode would be used to configure city for which a weather would be shown).
Now, doEdit() method is invoked when you request portlet in EDIT mode, just like doView() is invoked when requesting it in VIEW mode or doHelp() in HELP mode. This is nothing Liferay specific, but comes from Portlet specification (JSR-168).
So just invoke your portlet in EDIT mode to have doEdit() called.
For a complete demo sample you may check Liferay's official guide:
http://www.manning.com/sezov/
Just download sources and take a look at their Hello World portlet which includes calling and overriding doEdit().

Related

Call Custom aAction from Liferay Theme

I have A Custom Theme project & A Custom portlet project in liferay.
I want to call a custom action which is in Custom portlet from navigation.vm File of Theme Project.
actionurl is : /c/journal/upload_article which is called from same portlet project successfully.
How to call this from theme project?
Any help is really appreciated.
It sounds weird to "call" an action from a theme. If you embed a form to upload content on every page, naturally, you'd need a target for the upload. But still, the theme seems to be the wrong place to do so.
Nevertheless: It seems that you're using a non-custom URL for uploading (/c/journal/upload_article). You can do so from wherever in HTML. The big question then is: Where will you end up after the upload, as it doesn't happen from within a page.
If you need a proper portlet URL on an individual page, and want to return to the same page, the best way forward is to embed a portlet in the theme (which makes a great search term for Liferay's documentation). From that portlet you can utilize Liferay's API to do what you're trying to achieve. Make it a very lightweight portlet, because, well, it will be embedded on every single page.

Liferay: Page to portlet mapping

I have a requirement in liferay portal to allow user to add some specific portlets on a particular page. Same can be done in 2 ways:
This will require some custom code to be plugged in add panel code
create a custom portlet which will be present on left hand
side of page and allows portlet to be added and dragged on page.
On add of portlet it checks if the page can have this portlet and accordingly remove it
The question I have is which of these 2 approaches shall be used, and how?
Note: I was unable to find much about this on google as well
I believe Liferay permission system is strong enough to express what you need.
The portlet list shown in "Add more portlets" menu can be customized through a Regular Role. See How to customize which portlets to show in “Add more portlets” menu for detailed info.
To restrict the options for a single page (or several pages), modify its permissions, so that only the new Regular Role is be able to update it.
Based on your comment to Tomáš Piňos's answer, my suggestion would be to create a custom portlet that uses Liferay's API and enables you to do just this: On the page where it's available, use it to enable/disable the portlets you'd like to be there by use of Liferay's API. You'll find quite a lot of sample when you're looking for the old sevencogs example (that sadly does not compile any more, but in general the API has only changed marginally). The most up to date resources with further links to the ancient code are these 2 blog articles.
About your third option (as you ask in the comments): Yes, it's possible: You can override Liferay's Services as well as react to model changes. This means that you could add your own check on updates. However, I'd feel it inappropriate to offer the option to add any portlet only to prohibit it whenever a user indeed uses the offered option. That's why I didn't include this option in my initial answer.

How to add preference option to the liferay portlet

I want to create a portlet where the portlet allow access to the remote application. That is the content of the portlet should be dynamic so for the same reason I want to add one option "Preferences" in the portlet (Where the look and feel and configuration options exists). In that preference page If will give some http url (http://localhost:8080/Myapp/Mypage) then on click of save button, the URL page should display in the portlet. How can I do that? Note I am going to use same portlet in different pages with different URLs.
Liferay's "Preferences" link shows the portlet in JSR-286 "edit" mode. That's all there is: If you implement this mode, you'll automatically get the Preferences link.
Why are they named differently? IMHO Edit-Mode is rather misleading as you're editing the preferences rather than any data displayed in the portlet.
You can use Liferay Iframe Portlet which allow access to the remote application.
Refer following url for detail description of look and feel and configuration options : Iframe Portlet

Development questions related to Liferay 6

I am using Liferay version 6.06. I have developed a Login Portlet using Liferay plugins SDK under which the View JSP consists of a login screen. Upon submitting credentials from this view JSP it will be received by the processAction Method of my Custom Portlet class. All this works good.
I have two questions:
Currently the Login Portlet is being part of Sample Category under Liferay screen (I want to have my own screen, where initially upon entering http://localhost:8080/mycontext, I want to show that Login screen).
And once the credentials are received inside the processAction method of my Custom Portlet class, I want to display my own two portlets.
Could anybody tell me how to achieve this?
Beside you don't need a customized login for your Usecase, in case you still need to customize the login process you should:
build a hook which is a kind of plugin able to interact with Liferay's core functionalities.
In case you don't know take a look [here] http://www.liferay.com/it/documentation/liferay-portal/6.0/development/-/ai/hooks
or just use the property login.events.post=my.custom.PortletAction
and put your business logic after successfull user login

how to develop application like LifeRay Control panel

I want to develop an application like LifeRay control panel which has right navigation menu and a page that renders the clicked menu.
My question is how to develop at for example as one portlet or multi portlet taking into considaration (portlet communication)? and how to handle navigation inside portlet?
I'm using Icefaces(JSF) for portlet development and there is a section repeated for other pages(template)
Is there an example in liferay source for this?
Can't you just adjust a theme to have the navigation at the side as opposed to the default (at the top)? This way you'd be developing a plain portal application without any special magic - probably the most intuitive way to go.
Also, others will likely be able to quickly understand what you did and are able to add functionality.

Resources