« Back

Customizing portal JSPs from a portlet

Company Blogs August 26, 2008 By Brian Chan Staff

Previously, to customize a core portal JSP, you would have to use the ext environment.

You can do it now in a plugin via our liferay-hook.xml file. Just specify a directory of where your custom JSPs are, and on deploy of that plugin (portlet, theme, hook, etc.), the core portal JSPs will be overwritten with what's in your plugin, and on undeploy, it'll be reverted back.

When writing these custom JSPs, you cannot assume that you will be the only plugin to do this. So this feature is really geared more for SI's that are customing Liferay for a client and don't want to go through the trouble of an ext environment.

This makes sense because you can already override the implementation of beans (via Spring by just setting another implementation) and you an already set events and override portal.properties, so why not JSPs.

Here's a sample liferay-hook.xml.

<hook>
	<event>
		<event-class>com.liferay.wol.hook.events.StartupAction</event-class>
		<event-type>application.startup.events</event-type>
	</event>
	<event>
		<event-class>com.liferay.wol.hook.events.LoginPostAction</event-class>
		<event-type>login.events.post</event-type>
	</event>
	<model-listener>
		<model-listener-class>com.liferay.wol.hook.listeners.GroupListener</model-listener-class>
		<model-name>com.liferay.portal.model.Group</model-name>
	</model-listener>
	<model-listener>
		<model-listener-class>com.liferay.wol.hook.listeners.UserListener</model-listener-class>
		<model-name>com.liferay.portal.model.User</model-name>
	</model-listener>
	<portal-properties>portal.properties</portal-properties>
	<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>

Threaded Replies Author Date
Just what we've been waiting for. Customers are... Paul Hussein August 27, 2008 2:34 AM
In which version is this available? Thomas Kellerer September 3, 2008 12:59 AM
I backported this to 5.1.x because it's so... Brian Chan September 3, 2008 9:41 AM
So if you want to replace the login.jsp page... Eric Soucy October 8, 2008 7:38 PM

Just what we've been waiting for. Customers are always asking for mods to vanilla portlets and its painful to have to create an ext environment, and then every version change update this.
Posted on 8/27/08 2:34 AM.
In which version is this available?
Posted on 9/3/08 12:59 AM.
I backported this to 5.1.x because it's so useful. It'll be available in 5.1.2 which we're releasing this week.
Posted on 9/3/08 9:41 AM in reply to Thomas Kellerer.
So if you want to replace the login.jsp page for example, what would you do exactly ?
just create this:
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>

and then what ? put the custom login.jsp in the /META-INF/custom_jsps dir. ?
Posted on 10/8/08 7:38 PM.