<!--  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.portal.log.LogManager" %>
<%@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.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="URL";

    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 portletURL=ctx.getParameter(PortletConstants.PORTLET_PAGE_URL)==null ?"":
        (String)ctx.getParameter(PortletConstants.PORTLET_PAGE_URL);
    if ((portletURL==null)||(portletURL.trim().equals("")))
    {
         LogManager.debug("URLPortletURLData.jsp:portletURL is null in request");
         portletURL="http://";
    }
    String timeout=ctx.getParameter(PortletConstants.PORTLET_TIMEOUT)==null ?"":
        (String)ctx.getParameter(PortletConstants.PORTLET_TIMEOUT);
    if ((timeout==null)||(timeout.trim().equals("")))
    {
         LogManager.debug("URLPortletURLData.jsp:timeout is null in request");    
         timeout="10";
    }
    String timeoutMesg=
        ctx.getParameter(PortletConstants.PORTLET_TIMEOUT_MESSAGE)==null ?"":
        (String)ctx.getParameter(PortletConstants.PORTLET_TIMEOUT_MESSAGE);
    if ((timeoutMesg==null)||(timeoutMesg.trim().equals("")))
    {
        LogManager.debug("URLPortletURLData.jsp:timeoutMesg is null in request");    
        timeoutMesg="Timed Out";
    }
    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_URLDATA_SECTION_HEADER);
    String sectionHelp=
        rs.getMessage(ProviderUIBundle.URL_PORTLET_URLDATA_SECTION_HELP);
    String portletURLFieldLabel=
        rs.getMessage(ProviderUIBundle.PORTLET_URL);
    String timeoutFieldLabel=
        rs.getMessage(ProviderUIBundle.TIMEOUT);
    String timeoutMesgFieldLabel=
        rs.getMessage(ProviderUIBundle.TIMEOUT_MESSAGE);

    //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 portletURLField = new TextInputBean(
         PortletConstants.PORTLET_PAGE_URL, portletURL,50,1);
    portletURLField.setRequired("yes");
    portletURLField.setID(PortletConstants.PORTLET_PAGE_URL);
    TextInputBean timeoutField = new TextInputBean(
         PortletConstants.PORTLET_TIMEOUT, timeout,3,1);
    timeoutField.setRequired("yes");
    timeoutField.setID(PortletConstants.PORTLET_TIMEOUT);
    TextInputBean timeoutMesgField = new TextInputBean(
         PortletConstants.PORTLET_TIMEOUT_MESSAGE, timeoutMesg,30,1);
    timeoutMesgField.setRequired("yes");
    timeoutMesgField.setID(PortletConstants.PORTLET_TIMEOUT_MESSAGE);
    timeoutMesgField.setMaximumLength(200);

    //section field labels
    StyledTextBean portletURLLabel = new StyledTextBean("OraFieldText");
    portletURLLabel.setText(portletURLFieldLabel);
    portletURLLabel.setLabeledNodeID(PortletConstants.PORTLET_PAGE_URL);
    StyledTextBean timeoutLabel = new StyledTextBean("OraFieldText");
    timeoutLabel.setText(timeoutFieldLabel);
    timeoutLabel.setLabeledNodeID(PortletConstants.PORTLET_TIMEOUT);
    StyledTextBean timeoutMesgLabel = new StyledTextBean("OraFieldText");
    timeoutMesgLabel.setText(timeoutMesgFieldLabel);
    timeoutMesgLabel.setLabeledNodeID(PortletConstants.PORTLET_TIMEOUT_MESSAGE);

    //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(portletURLLabel);
    cfbs[1].addIndexedChild(timeoutLabel);
    cfbs[2].addIndexedChild(timeoutMesgLabel);
    cfbs[3].addIndexedChild(portletURLField);
    cfbs[4].addIndexedChild(timeoutField);
    cfbs[5].addIndexedChild(timeoutMesgField);

    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);
    }
    //create table, attach rows and render
    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);    

%>

