What is PortletURLListener used for? And can I make use of it in a hook? - liferay

Can somebody give me a use case as to how can the PortletURLListener be used? if it can be used at all?
Like we have ModelListener can we also use PortletURLListener?
Just like in ModelListener we can inject functionality on creation of a model, on update of a model or on delete and so on.
So can we use the PortletURLListener the same way like ModelListener to do
something when a specific URL is called? Any other approach if not PortletURLListener? Since the name is such I thought that could be of help.
And can we use it in a hook? or it is just used by Liferay? Any other practical usecase you have seen or implemented by extending or using this class?
Thanks in advance.
Thanks Mark for the prompt :-)

The PortletURLListener is used e.g. for deploying and undeploying by Liferay core. For more details see Liferay sources for PortletHotDeployListener:
https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/deploy/hot/PortletHotDeployListener.java
Answer after Update:
You can create hook and put servlet.service.events.post=com.my.MyAfterChangeAction propery to the portal.properties. The MyAfterChangeAction class must implements com.liferay.portal.kernel.events.Action.

Related

Extending PXMappedCacheExtension

Does anyone have an example of how to add a field to a Mapped cache extension? I am trying to extend the SalesPrice functionality in 2019R1. It looks a lot like a DAC... but something tells me I cant simply just make an extension for it..
Thanks
Please see below the diagram showing how it works.
In short, you create a generic graph and a class inherited from PXMapppedCacheExtension which will have all the fields that you need for your reusable logic.
Then you declare the mapping to the class and the implementation of the generic graph.
Please find the complete description by the following link.

How to display timeline information for routines used by controllers in glimpse/Asp.NET MVC

I am currently using Asp.Net MVC 4 and I would like to include the time of some routines used by my controllers in the glimpse's timeline tab.
I know that I have to create an ITimeLineMessage Implementation and send the timing information with a message broker. But how to create the ITimeLineMessage ?
Here is an implementation using anthonyv's suggestion:
https://gist.github.com/droyad/8292852
Here is a way but its not very nice and not supported:
Retrieve the MessageBroker for the following static method:
Glimpse.Core.Framework.GlimpseConfiguration.GetConfiguredMessageBroker()
Then publish an ITimelineMessage to the MessageBroker:
messageBroker.Publish(timelineMessage)
Note, you could create a generic message type that you use over again that implements ITimelineMessage
To populate the properties of your ITimelineMessage implementation you might also need IExecutionTimer. You can get this via the following static method:
Glimpse.Core.Framework.GlimpseConfiguration.GetConfiguredTimerStrategy()
The above will have the knowledge of when the request started for offsets etc.
As #nikmd23 said, we know this is about as bad as what you could ever want to do but v2 will see a much much more simple way of doing this.
You can create any custom class you want, that class just has to implement ITimelineMessage.
As a general heads up, we are currently working through a way to make this WAY easier. If the approach described there interests you, please do provide your feedback.

Adding new section in control panel of Liferay

I want to add a new section in control panel of liferay and within that section I want to have my custom-portlet. I did it using ext. However I want to do it with hook . Is it possible ?
I don't think it would be that easy with a hook, because of the following reasons:
You can't modify in a Hook - the class com.liferay.portal.util.PortletCategoryKeys which contains the keys for displaying the different sections. The different sections are hard-coded in this class in a String array ALL.
You can't modify the logic of PortalImpl#isControlPanelPortlet() which uses the PortletCategoryKeys#ALL to determine if the request in question is for a control panel portlet.
Then you also have another method which you can't modify with a Hook and is used extensively PortalImpl#getControlPanelCategory()
Doing it with a hook:
I have not tried this but I think if you need to do it with a hook you would have to change all those JSPs which make use of PortletCategoryKeys#ALL and the methods of PortalImpl as stated above, and provide your custom implementation for all these methods in the JSP.
I would really like to know how you implemented it with an EXT may be just the steps or the methods you have overridden. So that I can try to convert those in terms of a hook.
This is as far as my understanding goes. Hope this helps.
With the advent of Marketplace, ControlPanel has a new category named "Marketplace" and that section is introduced in a plugin. However, I never checked if 6.1 GA2 introduced a new section that this plugin just fills. Check the marketplace plugin if you can find a trace of this section implemented there.
On the other hand, nobody has yet named any section that definitely required a new section (though some have asked me how to solve the same problem). For this reason, you might want to re-think the requirement and choose one of the existing sections. If you don't, at least I'd be interested in the name and purpose of the new section - I might find a first one actually justifying this kind of implementation...

How add custom method and fields to Liferay User model class

I want to add 3 more methods and one field to liferay.portal.model.User class. Anyone knows how can I do this? Can I switch the class by hook like this:
<service>
<service-type>com.liferay.portal.model.User</service-type>
<service-impl>my.pack.userExpanded</service-impl>
</service>
I want to have a close look at service builder but can't find good sources which will show how to switch liferay class with my own class (cause of too many uses).
So second question is does anyone know about some good tutorial or blogs regarding this? Especially I am interested in adding extra methods and fields.
The standard Liferay Developer Documentation is good:
http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/overriding-a-portal-servi-4
Another alternative is to add Custom Fields to User entity:
You can't modify a liferay entity. Neither you can use hook to modify these things, hook can only modify limited things as suggested by the documentation.
I don't think you can even use a EXT to modify a liferay entity.
So now the what comes to my mind remains is to create custom-fields for your field requirement and build a helper utility class which will provide you with your required User methods.
You can make the helper class available to the portal by packaging in a jar and pasting it in the global path (in tomcat [TOMCAT_HOME]/lib/ext).

Seam component reuse - outjected #DataModel variable conflict

I need your suggestions as usual ;)
In my Seam app, there's a JSF view page processing 3 similar types of data, so I wrote a Seam component and would like to reuse it three times. The problem is, the component outjects some data used by the view into #DataModel variable. Now, is there a clever way to variate three conflicting variable names without using inheritance etc? If not, what kind of other approach would you suggest? Thanks in advance.
i suggest don't use outjection and use inheritance and just getters to access variable.
ie: #{bean1.var} #{bean2.var} #{bean3.var}

Resources