Customizing portal JSPs from a portlet

Brian Chan
Brian Chan
Less Than a Minute Read

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>

Page Comments
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.
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. ?

The Technicalities of Static Sites

David Oliveira Montenegro
View Blog >

Customization is Dead! Long Live Customization!

David H Nebinger
View Blog >
customization banner image.png

Public Bug Bounty Program

David H Nebinger
View Blog >
bugbounty.png
Showing 1 to 3 of 3 entries.