JSP files and the Portlet tag library

The help.jsp and edit.jsp files are very simple. Note that CSS styles are used as defined in the portlet specification. This ensures that the portlet will render successfully within the theme and across portal vendors.

<div class="portlet-section-header">Help mode</div>
<div class="portlet-section-body">This is the help mode where you can find useful information.</div>

<div class="portlet-section-header">Edit mode</div>
<div class="portlet-section-body">This is the edit mode where you can change your portlet preferences.</div>

The landing page contains the links and form to call the portlet:

(1) <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
 <div class="portlet-section-header">Welcome !</div>
 <div class="portlet-font">Welcome on the JSP Hello User portlet,
 my name is GateIn Portal. What's yours ?</div>
 <div class="portlet-font">Method 1: We simply pass the parameter to the render phase:<br/>
(2) <a href="<portlet:renderURL><portlet:param name="yourname" value="John Doe"/>
                </portlet:renderURL>">John Doe</a></div>
 <div class="portlet-font">Method 2: We pass the parameter to the render phase, using valid XML:
 Please check the source code to see the difference with Method 1.
(3) <portlet:renderURL var="myRenderURL">
    <portlet:param name="yourname" value='John Doe'/>
(4) <a href="<%= myRenderURL %>">John Doe</a></div>
 <div class="portlet-font">Method 3: We use a form:<br/>
(5) <portlet:actionURL var="myActionURL"/>
(6) <form action="<%= myActionURL %>" method="POST">
         <span class="portlet-form-field-label">Name:</span>
         <input class="portlet-form-input-field" type="text" name="yourname"/>
         <input class="portlet-form-button" type="Submit"/>


The portlet taglib which needs to be declared.


The first method shown here is the simplest one. portlet:renderURL will create a URL that calls the render phase of the current portlet and append the result at the place of the markup (within a tag). A parameter is also added directly to the URL.


In this method, the var attribute is used. This avoids having one XML tag within another. Instead of printing the url, the portlet:renderURL tag will store the result in the referenced variable ( myRenderURL).


The variable myRenderURL is used like any other JSP variable.


The third method mixes the form submission and action request. Again, a temporary variable is used to put the created URL into.


The action URL is used in the HTML form.

In the third method, the action phase is triggered first, then the render phase is triggered, which outputs some content back to the web browser based on the available render parameters.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus