<%@ page import="oracle.portal.provider.v1.*,oracle.portal.provider.v1.http.*" session="false" %>

<%-- 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(HttpProvider.PORTLET_RENDER_REQUEST);
    String title = request.getParameter("lotto_title");
    String sTitle = request.getParameter("lotto_short_title");
    String action = request.getParameter("lotto_action");
    NameValuePersonalizationObject data = null;

    // Cancel automatically redirects to the page -- so will only receive 'OK' or 'APPLY'
    if (action != null) {
        data = (NameValuePersonalizationObject) PortletRendererUtil.getEditData(portletRequest);
        data.setPortletTitle(title);
        data.setPortletShortTitle(sTitle);
        PortletRendererUtil.submitEditData(portletRequest, data);
        if (action.equalsIgnoreCase("OK")) {
            response.sendRedirect(portletRequest.getBackURL());
            return;
        } else if (action.equalsIgnoreCase("APPLY")) {
            response.sendRedirect(portletRequest.getPageURL());
            return;
        }
    }

    // otherwise just render the form


    data = (NameValuePersonalizationObject) PortletRendererUtil.getEditData(portletRequest);
    title = data.getPortletTitle();
    sTitle = data.getPortletShortTitle();
%>

<% PortletRendererUtil.renderCustomizeFormHeader(portletRequest, out, null, "lotto_action", null, null); %>

<TABLE BORDER="0">
    <TR>
        <TD WIDTH="20%">
            <P ALIGN="RIGHT">Title:
        </TD>
        <TD WIDTH="80%">
            <INPUT TYPE="TEXT" NAME="lotto_title" VALUE="<%= title %>" SIZE="20">
        </TD>
    </TR>
    <TR>
        <TD WIDTH="20%">
            <P ALIGN="RIGHT">Short Title:
        </TD>
        <TD WIDTH="80%">
            <INPUT TYPE="TEXT" NAME="lotto_short_title" VALUE="<%= sTitle %>" SIZE="20" MAXLENGTH="20">
        </TD>
    </TR>
</TABLE>

<% PortletRendererUtil.renderCustomizeFormFooter(portletRequest, out); %>

