<!--  Copyright (c) 2002, Oracle Corporation. All Rights Reserved -->
<%@ page import="java.util.*"%>
<%@page import="oracle.portal.log.LogManager" %>
<%@ page import="oracle.webdb.providerui.builder.BuilderFactory" %>
<%@page import="oracle.webdb.providerui.RequestContext" %>
<%@page import="oracle.webdb.providerui.PortletConstants" %>
<%@page import="oracle.webdb.providerui.ResourceService"%>
<%@page import="oracle.webdb.providerui.resource.ProviderUIBundle" %>
<%@page import="oracle.webdb.providerui.builder.base.ProviderBuilder" %>
<%@page import="oracle.webdb.providerui.builder.BuilderUtils" %>
<%@page import="oracle.webdb.providerui.builder.base.PortletBuilder" %>
<%@page import="oracle.cabo.ui.*" %>
<%@page import="oracle.cabo.ui.beans.*" %>
<%@page import="oracle.cabo.ui.beans.form.*" %>
<%@page import="oracle.cabo.ui.beans.layout.*" %>
<%@page import="oracle.cabo.share.nls.LocaleContext" %>
<%

    //get the request context and locale. Get the providerBuilder and 
    //portlet builder and then try to retrieve NLS strings
    
    String portletType=request.getParameter(
            PortletConstants.PORTLET_TYPE);
    String providerName=request.getParameter(
                 PortletConstants.PROVIDER_NAME);
    LogManager.debug(BuilderUtils.concatenateStrings(
       "PORTLETMetadata.jsp portletType=",portletType,
           " providerName=",providerName));

    RequestContext ctx=BuilderFactory.getRequestContext();
    Locale locale=ctx.getLocale();
    // hard code the resource bundle name so other wizards can share this tab
    // String resourceBundleString=
    //    request.getParameter(PortletConstants.RESOURCE_BUNDLE_NAME);
    String resourceBundleString= "oracle.webdb.providerui.resource.ProviderUIBundle";
    String mode=
        request.getParameter(PortletConstants.MODE);

    LogManager.debug(BuilderUtils.concatenateStrings(
            new String[] {"PortletMetadata.jsp ResourceBundleString ",
                          "from request=",resourceBundleString}));

    ResourceService rs = 
        BuilderFactory.getResourceService(
        resourceBundleString,locale);
    //rendering context on which  to render UI Bean
    ServletRenderingContext rContext = new ServletRenderingContext(pageContext);
    rContext.setLocaleContext(new LocaleContext(locale));


    //retrieve parameter from request
    String portletName = ctx.getParameter(
         PortletConstants.PORTLET_FIELD_NAME) == null ? "":
         (String)ctx.getParameter(PortletConstants.PORTLET_FIELD_NAME);
    String portletDisplayName = ctx.getParameter(
          PortletConstants.PORTLET_DISPLAY_NAME) == null ? "" :
          (String)ctx.getParameter(PortletConstants.PORTLET_DISPLAY_NAME);
    String portletDesc= ctx.getParameter(
          PortletConstants.PORTLET_DESC) == null ? "" :
          (String)ctx.getParameter(PortletConstants.PORTLET_DESC);
    //retrieve NLS strings
    String sectionHeader=
        rs.getMessage(ProviderUIBundle.PORTLET_METADATA_SECTION_HEADER);
    String sectionHelp=
        rs.getMessage(ProviderUIBundle.PORTLET_METADATA_SECTION_HELP);
    String nameFieldLabel=
        rs.getMessage(ProviderUIBundle.PORTLET_NAME);
    String displayNameFieldLabel=
        rs.getMessage(ProviderUIBundle.PORTLET_DISPLAY_NAME);
    String descFieldLabel=
        rs.getMessage(ProviderUIBundle.PORTLET_DESCRIPTION);

    //section Header
    HeaderBean header = new HeaderBean(sectionHeader);
    //section help
    StyledTextBean instructionText = new StyledTextBean("OraInstructionText");
    instructionText.setText(sectionHelp);
    header.addIndexedChild(instructionText);
    header.render(rContext);


    //section fields
    TextInputBean portletNameField = new TextInputBean(
         PortletConstants.PORTLET_FIELD_NAME, portletName,30,1);
    portletNameField.setRequired("yes");
    portletNameField.setID(PortletConstants.PORTLET_FIELD_NAME);
    portletNameField.setMaximumLength(30);
    TextInputBean portletDisplayNameField = new TextInputBean(
         PortletConstants.PORTLET_DISPLAY_NAME, portletDisplayName,30,1);
    portletDisplayNameField.setRequired("yes");
    portletDisplayNameField.setID(PortletConstants.PORTLET_DISPLAY_NAME);
    portletDisplayNameField.setMaximumLength(200);
    TextInputBean portletDescField = new TextInputBean(
        PortletConstants.PORTLET_DESC, portletDesc,50,3);
    portletDescField.setRequired("yes");
    portletDescField.setID(PortletConstants.PORTLET_DESC);
    portletDescField.setMaximumLength(200);
    //section field labels
    StyledTextBean portletNameLabel = new StyledTextBean("OraFieldText");
    portletNameLabel.setText(nameFieldLabel);
    portletNameLabel.setLabeledNodeID(PortletConstants.PORTLET_FIELD_NAME);
    StyledTextBean portletDisplayNameLabel = new StyledTextBean("OraFieldText");
    portletDisplayNameLabel.setText(displayNameFieldLabel);
    portletDisplayNameLabel.setLabeledNodeID(
        PortletConstants.PORTLET_DISPLAY_NAME);
    StyledTextBean portletDescLabel = new StyledTextBean("OraFieldText");
    portletDescLabel.setText(descFieldLabel);
    portletDescLabel.setLabeledNodeID(PortletConstants.PORTLET_DESC);

    //create cellFormBeans, attach them to rowLayoutBeans and attach that to 
    //TableLayoutBean and then render it
    CellFormatBean[] cfbs=new CellFormatBean[6];
    for (int i=0;i<cfbs.length;i++)
    {
        cfbs[i]=new CellFormatBean();
        cfbs[i].setHAlign("left");
    }

    cfbs[0].addIndexedChild(portletNameLabel);
    cfbs[1].addIndexedChild(portletDisplayNameLabel);
    cfbs[2].addIndexedChild(portletDescLabel);
    cfbs[3].addIndexedChild(portletNameField);
    cfbs[4].addIndexedChild(portletDisplayNameField);
    cfbs[5].addIndexedChild(portletDescField);
    SpacerBean spacer30 = new SpacerBean(0,30);

    RowLayoutBean[] rlbs = new RowLayoutBean[3];
    for (int i=0;i<rlbs.length;i++)
    {
        rlbs[i]=new RowLayoutBean();
        rlbs[i].setHAlign("center");
        rlbs[i].addIndexedChild(cfbs[i]);
        rlbs[i].addIndexedChild(cfbs[i+3]);
        rlbs[i].addIndexedChild(spacer30);
    }
    TableLayoutBean tabArea = new TableLayoutBean();

    tabArea.setWidth("70%");
    tabArea.setHAlign("center");
    SpacerBean spacer10 = new SpacerBean(0,10);

    tabArea.addIndexedChild(spacer10);
    for (int i=0;i<rlbs.length;i++)
    {
        tabArea.addIndexedChild(rlbs[i]);
    }

    FormValueBean resourceBundleNameBean=new FormValueBean(
         PortletConstants.RESOURCE_BUNDLE_NAME,resourceBundleString);

    FormValueBean portletTypeBean=new FormValueBean(
         PortletConstants.PORTLET_TYPE,portletType);

    FormValueBean providerNameBean=new FormValueBean(
         PortletConstants.PROVIDER_NAME,providerName);
         
    FormValueBean oldPortletNameBean=new FormValueBean(
         PortletConstants.OLD_PORTLET_NAME,portletName);

    tabArea.addIndexedChild(resourceBundleNameBean);
    tabArea.addIndexedChild(portletTypeBean);
    tabArea.addIndexedChild(providerNameBean);
    tabArea.addIndexedChild(oldPortletNameBean);


    tabArea.render(rContext);    
%>


