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.

The Hello Model

We need to add the user's name to the Hello model class. We create a field called salutation to hold this name.



package com.teradata.portlets.hello.model;

import com.teradata.commons.util.BaseObject;

 * 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()
        return salutation;

    public void setSalutation(String salutation)
        this.salutation = salutation;
    //*** End add section ***/


The Hello Controller

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.


import com.teradata.portlets.hello.service.HelloManager;
import com.teradata.portlets.util.TdPortletUtils;

//***Add the following import statement***/
import com.teradata.portlets.hello.model.HelloModel;
//**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();
        ctx.addViewObject("helloData", model);

        //***End add code section***/


The Hello Summary View

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="" %>
<%@ taglib prefix="fn" uri="" %>
<%@ taglib prefix="vs" uri="" %>

<jsp:include page="include.jsp"/>

<%--Add the following code section--%>
Hello, ${helloData.salutation}!
<%--End add code section--%>

This completes the changes to the summary page. If you redeploy your portlet, you should now see the new text: