<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page session="false" import="oracle.portal.provider.v2.*" %>
<%@ page import="oracle.portal.provider.v2.render.*" %>
<%@ page import="oracle.portal.provider.v2.http.HttpCommonConstants" %>
<%@ page import="oracle.portal.provider.v2.personalize.NameValuePersonalizationObject" %>

<%-- This page both displays the customization form and processes it.
     We display the form if there isn't a submitted title parameter,
     else we apply the changes --%>

<%
    PortletRenderRequest portletRequest = (PortletRenderRequest)
        request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
    String title = request.getParameter("mTitle");
    String actionParam = PortletRendererUtil.getEditFormParameter(portletRequest);
    String action = request.getParameter(actionParam);
    NameValuePersonalizationObject data = (NameValuePersonalizationObject)
        PortletRendererUtil.getEditData(portletRequest);

    // Cancel automatically redirects to the page -- so will only receive 'OK' or 'APPLY'
    if (action != null) {
        data.setPortletTitle(title);
        PortletRendererUtil.submitEditData(portletRequest, data);
        return;
    }

    // otherwise just render the form
    title = data.getPortletTitle();
%>
<p> Title:  <INPUT TYPE="text" NAME="mTitle" VALUE="<%= title %>" />

