Dokumentáció
A Liferay az erőforrások és az ismeretek gazdag tárházát kínálja, hogy elősegítse technológiájának a közösség általi jobb használatát és alkalmazását.
Customizing JSPs Without Overriding the Original
If we can override a JSP with a hook plugin, why learn another way to accomplish the same thing? Good question. Each time the original (overridden) file is changed by Liferay (for example, to fix a bug) after you override it, you’ll have to make those changes manually to your customized file, to benefit from them.
You can avoid this drawback and make your JSP modifications less invasive by rendering the original JSP into a string and modifying it dynamically afterwards. This way you can change minor elements of a JSP, like adding a new heading or button, without modifying your hook every time you upgrade Liferay. Here’s an example that customizes the search portlet. Specifically, it adds helpful text to aid the user in searching for content. Since this technique involves string manipulation, it’s mainly useful for making a small number of changes to a JSP.
Open the
[LIFERAY_HOME]/tomcat-[version]/webapps/ROOT/html/portlet/search/search.jspfile.Append the following code to the end of the JSP file:
<liferay-util:buffer var="html"> <liferay-util:include page="/html/portlet/search/view.portal.jsp" /> </liferay-util:buffer> <% html = StringUtil.add( html, "Didn't find what you were looking for? Refine your search and " + "try again!", "\n"); %> <%= html %>Start your Liferay instance or restart it if you already have one running.
Add the Search portlet to a page by selecting Add → Content and Applications → Tools → Search.
Input text into the search field and click Search.
Your custom string is now displayed at the bottom of the Search portlet.
Figure 6.3: After customizing the JSP file, your custom string is displayed.
Next, we’ll explore application adapters and what they can do for your sites and site templates.