Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
yaragad from Spain
Is possible to use a JSP from .jar in ConfigurationAction Render() ?
June 8, 2011 8:59 AM
Answer

yaragad from Spain

Rank: Junior Member

Posts: 52

Join Date: March 15, 2011

Recent Posts

Im using an Implementation of ConfigurationAction class.
The render method returns the jsp path to be displayed, it works fine, just returning the path "web-inf/jsp/myfile.jsp"

But... is there any way to get that jsp from a .jar file?
Tomas Polesovsky
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
June 8, 2011 1:15 PM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 644

Join Date: February 13, 2009

Recent Posts

AFAIK in current JEE implementation not. I heard that JEE 7 could support it.
yaragad from Spain
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
June 9, 2011 3:12 AM
Answer

yaragad from Spain

Rank: Junior Member

Posts: 52

Join Date: March 15, 2011

Recent Posts

Is there any other possibility? (ie: using an additional library)
Tomas Polesovsky
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
June 9, 2011 10:57 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 644

Join Date: February 13, 2009

Recent Posts

I don't know any library that could do it - I think it depends on every servlet container implementation how it compiles JSPs into servlets and call them.

There could be way to compile your JSPs into servlets during compile time and register them in web.xml (with mapping for the jsp file location). Servlets could be in JAR, but web.xml has to be in your WAR file. But I'm not 100% sure it will work.

-- tom
yaragad from Spain
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
June 10, 2011 1:17 AM
Answer

yaragad from Spain

Rank: Junior Member

Posts: 52

Join Date: March 15, 2011

Recent Posts

Ok, thanks... Maybe there is a simpler solution...

The library (and JSP) will be the same for all portlets () containing
<configuration-action-class>package.ConfigurationActionImpl</configuration-action-class>
in the liferay-portlet.xml.

So... is there a simple way to add the .jar and the .jsp in liferay directory, so I can access throw the portlets?

I mean, add the 2 files somewhere inside liferay-portal-6.0.6 folder and access them from my custom portlets.
- to access the .JAR trough the <configuration-action-class>
- to return the .JSP path in the ConfigurationAction Render method.
Tomas Polesovsky
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
June 10, 2011 2:56 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 644

Join Date: February 13, 2009

Recent Posts

yaragad,

I hope I understand.

You want to share your configuration among many portlets. And those portlets are in different WAR files, right?

I think the most clear and simple solution is to change your portlet's architecture / build process. I.e:
1, move all your portlets into one WAR file so that they could share the JSP in your WEB-INF/jsp directory and ConfigurationActionImpl.
2, or create separate project with your JSP and ConfigurationActionImpl and during build process pack them into all your portlets.

When your WAR files are deployed they all have different servlet context and therefore it's not easy (if even possible) to access JSP that is located somewhere outside. The only way I see could be to use combination of ConfigurationActionImpl+Servlet in JAR file that you put into tomcat/lib/ext dir. Then you only need to register servlet in your web.xml. I hope struts can also redirect to servlet mapping emoticon

-- tom
kevin qian
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
November 19, 2012 1:35 AM
Answer

kevin qian

Rank: New Member

Posts: 1

Join Date: November 19, 2012

Recent Posts

Hello, Tomas,

do u know how to get PortletPreferences in render() method?
Tomas Polesovsky
RE: Is possible to use a JSP from .jar in ConfigurationAction Render() ?
November 27, 2012 1:37 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 644

Join Date: February 13, 2009

Recent Posts

Hello Kevin,

please create a new thread next time, you'll have better chance to get the answer faster.

You can get PortletPreferences from any portlet request object: [url=http://www.bluesunrise.com/portlet-api/javax/portlet/PortletRequest.html#getPreferences()]PortletRequest.getPreferences().

In render() method that means renderRequest.getPreferences().

HTH.

-- tom +