Foren
RE: Service Builder - read preference table
Smilelws2010 lwz, geändert vor 10 Jahren.
Service Builder - read preference table
Regular Member Beiträge: 160 Beitrittsdatum: 16.12.10 Neueste Beiträge
HI
Is it possible to read preference table for the portlet inside a method in the Liferay service builder, XxxServiceImpl.java?
If so how can we do that?
Thanks and looking forward to see the insights and possible solutions to read a name value pair from preference table in liferay.
Regards,
Smile
Is it possible to read preference table for the portlet inside a method in the Liferay service builder, XxxServiceImpl.java?
If so how can we do that?
Thanks and looking forward to see the insights and possible solutions to read a name value pair from preference table in liferay.
Regards,
Smile
Sanketh Iyer, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Junior Member Beiträge: 25 Beitrittsdatum: 02.02.12 Neueste Beiträge
You can create a method with ActionRequest or Renderrequest as a parameter in your xxxLocalServiceImpl.java class.
You can fetch the preferences by using
PortletPreferences prefs = request.getPreferences();
Now you can call this method from your controller class
You can fetch the preferences by using
PortletPreferences prefs = request.getPreferences();
Now you can call this method from your controller class
Smilelws2010 lwz, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Regular Member Beiträge: 160 Beitrittsdatum: 16.12.10 Neueste Beiträge
Thanks Sanketh for the help.
But can you get ActionRequest or RenderRequest object inyour service builder implementation class? I doubt that.
Could you help me with that. And correct me if I am wrong.
Thanks
Smile
But can you get ActionRequest or RenderRequest object inyour service builder implementation class? I doubt that.
Could you help me with that. And correct me if I am wrong.
Thanks
Smile
Sanketh Iyer, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Junior Member Beiträge: 25 Beitrittsdatum: 02.02.12 Neueste Beiträge
In your controller you can use:
xxxLocalServiceUtil.yourMethod(actionRequest);
and you can have a method in your xxxLocalServiceImpl
yourMethod(ActionRequest actionRequest){}
xxxLocalServiceUtil.yourMethod(actionRequest);
and you can have a method in your xxxLocalServiceImpl
yourMethod(ActionRequest actionRequest){}
Smilelws2010 lwz, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Regular Member Beiträge: 160 Beitrittsdatum: 16.12.10 Neueste Beiträge
Thanks a lot Sanketh for the guidance.
I will try to do that and see how it goes.
I will try to do that and see how it goes.
Apoorva Prakash, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste BeiträgeSmilelws2010 lwz:
HI
Is it possible to read preference table for the portlet inside a method in the Liferay service builder, XxxServiceImpl.java?
If so how can we do that?
Thanks and looking forward to see the insights and possible solutions to read a name value pair from preference table in liferay.
Regards,
Smile
Hello Smile,
With the following code snippet, you can get the preferences object in doView...
Portlet portlet = (Portlet)renderRequest.getAttribute(WebKeys.RENDER_PORTLET);
PortletPreferences preferences = null;
try{
preferences =PortletPreferencesFactoryUtil.getPortletSetup(renderRequest, portlet.getPortletId());
}catch(SystemException se){
log.info(se.getMessage() + "occured in getting prefs");
}
Yes Sanketh mentioned it correctly, you can always pass the actionRequest or renderRequest as a argument of *LocalServiceUtil and *ServiceUtil class.
For more details about custom configurations, see this link.
HTH.
Thanka and Regards,
Apoorva Prakash
David H Nebinger, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Sorry, but this is really a bad idea...
SB code is meant to be used by multiple portlets. Each portlet has it's own portlet prefs (they are not shared nor overlap), so it's really a poor design to rely on the preferences of the calling portlet within your SB code...
Since the preferences belong to the SB code, you should handle them there. There's a number of different ways to accomplish this (a static singleton, spring injection, direct spring context access, etc.).
SB code is meant to be used by multiple portlets. Each portlet has it's own portlet prefs (they are not shared nor overlap), so it's really a poor design to rely on the preferences of the calling portlet within your SB code...
Since the preferences belong to the SB code, you should handle them there. There's a number of different ways to accomplish this (a static singleton, spring injection, direct spring context access, etc.).
Smilelws2010 lwz, geändert vor 10 Jahren.
RE: Service Builder - read preference table
Regular Member Beiträge: 160 Beitrittsdatum: 16.12.10 Neueste Beiträge
Thanks for the information David and Apoorva.
David,
I am not trying to read the preference of the calling portlet.
I am trying to read some values stored in the SB impl class based on the parameter passed by the calling portlet. And then I will have to look up the preferences table and get other details related to the parameter passed. Is that possible?
I will try to do the suggestions or will create a separate table other than preference and will try to query that using jdbc. Please suggest if this is going nowhere.
Reagrds,
SMile
David,
I am not trying to read the preference of the calling portlet.
I am trying to read some values stored in the SB impl class based on the parameter passed by the calling portlet. And then I will have to look up the preferences table and get other details related to the parameter passed. Is that possible?
I will try to do the suggestions or will create a separate table other than preference and will try to query that using jdbc. Please suggest if this is going nowhere.
Reagrds,
SMile