The first thing that we want to do is replace the summary view with our own content. Our Hello portlet is going to display "Hello, user!", where user is the user's portal login name. Since this is a Model-View-Controller (MVC) application, we need to make changes in each of these three areas.
The following diagram shows how the summary page is generated by the code we are about to write:
The model, view, and controller have already been generated for us. In each of the next three sections, you need to modify the source code by adding the code shown in the comment block.
We need to add the user's name to the Hello model class. We create a field called salutation to hold this name.
* This class is the model for the Hello portlet. Add any data needed
* by the summary view to this class.
public class HelloModel extends BaseObject
//*** Add the following section ***/
private String salutation;
public String getSalutation()
public void setSalutation(String salutation)
this.salutation = salutation;
//*** End add section ***/
In the Hello view controller, we need to create our model class and populate it with the user's name. Then the model is made available to the summary view by adding a view object with the name helloData.
//***Add the following import statement***/
//**End add import statement***/
public void summary(ControllerContext ctx)
// set 'summary.jsp' as the view for this page.
//***Add the following code section***/
// Retrieve the user name, store it in a HelloModel object,
// and add the HelloModel as a view object
HelloModel model = new HelloModel();
//***End add code section***/
In the summary view, we need to display the "Hello, user!" text. We can reference the HelloModel data using the helloData name for the view object that we created in the controller. Replace the [summary page] line at the bottom of this file with the code in the comment block.
<%@ page contentType="text/html" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="vs" uri="http://teradata.com/viewpoint/security" %>
<%--Add the following code section--%>
<%--End add code section--%>
This completes the changes to the summary page. If you redeploy your portlet, you should now see the new text: