Fórum
Service Builder - read preference table
Smilelws2010 lwz, modificado 10 Anos atrás.
Service Builder - read preference table
Regular Member Postagens: 160 Data de Entrada: 16/12/10 Postagens Recentes
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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Junior Member Postagens: 25 Data de Entrada: 02/02/12 Postagens Recentes
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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Regular Member Postagens: 160 Data de Entrada: 16/12/10 Postagens Recentes
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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Junior Member Postagens: 25 Data de Entrada: 02/02/12 Postagens Recentes
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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Regular Member Postagens: 160 Data de Entrada: 16/12/10 Postagens Recentes
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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens RecentesSmilelws2010 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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
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, modificado 10 Anos atrás.
RE: Service Builder - read preference table
Regular Member Postagens: 160 Data de Entrada: 16/12/10 Postagens Recentes
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