<!--  Copyright (c) 2002, Oracle Corporation. All Rights Reserved -->
<%@ page import="java.util.*"%>
<%@ 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.base.PortletBuilder" %>
<%@page import="oracle.portal.log.LogManager" %>
<%@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" %>
<%@page import="java.net.URLEncoder" %>

<%

    //get the request context and locale. Get the providerBuilder and 
    //portlet builder and then try to retrieve NLS strings
    
    RequestContext ctx=BuilderFactory.getRequestContext();
    Locale locale=ctx.getLocale();

    String resourceBundleString=
        request.getParameter(PortletConstants.RESOURCE_BUNDLE_NAME);

    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 headerTrimTag=
        ctx.getParameter(PortletConstants.PORTLET_HEADER_TRIM_TAG) == null ?"":
        (String)ctx.getParameter(PortletConstants.PORTLET_HEADER_TRIM_TAG);
    String footerTrimTag=
        ctx.getParameter(PortletConstants.PORTLET_FOOTER_TRIM_TAG) == null ? "":
        (String)ctx.getParameter(PortletConstants.PORTLET_FOOTER_TRIM_TAG);

    String portletName=
        ctx.getParameter(PortletConstants.OLD_PORTLET_NAME)==null ? "":
        (String)ctx.getParameter(PortletConstants.OLD_PORTLET_NAME);
        
    
    //retrieve NLS strings
    String sectionHeader=
        rs.getMessage(ProviderUIBundle.URL_PORTLET_FILTERDATA_SECTION_HEADER);
    String sectionHelp=
        rs.getMessage(ProviderUIBundle.URL_PORTLET_FILTERDATA_SECTION_HELP);
    String headerTrimTagFieldLabel=
        rs.getMessage(ProviderUIBundle.HEADER_TRIM_TAG);
    String footerTrimTagFieldLabel=
        rs.getMessage(ProviderUIBundle.FOOTER_TRIM_TAG);

    //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 headerTrimTagField = new TextInputBean(
        PortletConstants.PORTLET_HEADER_TRIM_TAG, headerTrimTag,50,1);
    headerTrimTagField.setRequired("yes");
    headerTrimTagField.setID(PortletConstants.PORTLET_HEADER_TRIM_TAG);
    TextInputBean footerTrimTagField = new TextInputBean(
        PortletConstants.PORTLET_FOOTER_TRIM_TAG, footerTrimTag,50,1);
    footerTrimTagField.setRequired("yes");
    footerTrimTagField.setID(PortletConstants.PORTLET_FOOTER_TRIM_TAG);

    //section field labels
    StyledTextBean headerTrimTagLabel = new StyledTextBean("OraFieldText");
    headerTrimTagLabel.setText(headerTrimTagFieldLabel);
    headerTrimTagLabel.setAccessKey('H');
    headerTrimTagLabel.setLabeledNodeID(PortletConstants.PORTLET_HEADER_TRIM_TAG);
    StyledTextBean footerTrimTagLabel = new StyledTextBean("OraFieldText");
    footerTrimTagLabel.setText(footerTrimTagFieldLabel);
    footerTrimTagLabel.setAccessKey('M');
    footerTrimTagLabel.setLabeledNodeID(PortletConstants.PORTLET_FOOTER_TRIM_TAG);

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

    cfbs[0].addIndexedChild(headerTrimTagLabel);
    cfbs[1].addIndexedChild(footerTrimTagLabel);
    cfbs[2].addIndexedChild(headerTrimTagField);
    cfbs[3].addIndexedChild(footerTrimTagField);
    SpacerBean spacer30 = new SpacerBean(0,30);
    RowLayoutBean[] rlbs = new RowLayoutBean[2];
    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+2]);
        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 oldPortletNameBean=new FormValueBean(
         PortletConstants.OLD_PORTLET_NAME,portletName);         
         
    tabArea.addIndexedChild(resourceBundleNameBean);
    tabArea.addIndexedChild(oldPortletNameBean);

    
    tabArea.render(rContext);    
 
%>
