Question

I am using IPC for communicating with multiple portlets. So, we have one Universal Admin portlet, which has configuration properties, which will be stored in portlet preferences.

If I want to get the portlet preferences of specific portlet in any other portlet, I should know it's ID.

So, How do I set the portlet ID for my portlets manually, how do I get that in code?

Était-ce utile?

La solution

As you talk about "a specific other portlet", you seem to already know the portlet that you want to access - and thus should have access to its id... Or, in other words, I'm not sure what you're trying to achieve, or how your UniversalAdmin portlet would access that information.

Basically, Liferay's API gives you access to the different sites that you can create in Liferay, e.g. as GroupService (a site has the technical name 'group'). Pages in Liferay are called Layouts, sites/groups are made up of up to two LayoutSets (public and private pages). These Layouts give you access to the portlets that are contained on them. Just check the full API at http://docs.liferay.com/portal/6.1/javadocs/. It helps to have some basic understanding of Liferay's ServiceBuilder to know how to work with the API

Edit: As you say you want to generate the portlet id by yourself. You'll know best yourself why you want to do this - I recommend to look into the good-old sevencogs sample code. Unfortunately it's discontinued (you'll find it in old sourcecode releases), but James Falkner has blogged about some of its features. You specifically want to look at the paragraphs "Adding a Portlet to a Layout (Page)" and "Adding Resources to a Layout" - but the rest is also quite interesting.

In short: Liferay depends on some elements of this ID to be reproducible - for non-instantiable portlets you have no choice and the ID is fully predetermined. This predetermined ID, for instanciable portlets, is followed by "INSTANCE" and some random characters. As I said above: It's unclear to me what you gain when you run the random number generator yourself instead of relying on the existing mechanism, but you'll know better what you want to achieve.

Autres conseils

I have not in mind a way to change the portlet id.

Although if you want to define your specific id in every portlet you could use the portle-name tag of the portlet.xml in order to set a pseudo-id. By this way you can use this tag as it a unique id that refers to every portlet.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top