<%
/* Copyright (c) 2002, 2003 Oracle Corporation. All Rights Reserved. */
%>
<%@ taglib uri="http://xmlns.oracle.com/uix/ui" prefix="uix" %>

<%@ page import="java.util.Locale,
           oracle.cabo.share.nls.LocaleContext,
           oracle.cabo.share.config.Configuration,
           oracle.cabo.ui.ServletRenderingContext,
           oracle.webdb.utils.SimpleStringBuffer,
           oracle.webdb.reformlet.Utility,
           oracle.webdb.providerui.RequestContext,
           oracle.webdb.providerui.ResourceService,
           oracle.webdb.providerui.ProviderBuilderConstants,
           oracle.webdb.providerui.PortletConstants,
           oracle.webdb.providerui.builder.BuilderFactory,
           oracle.webdb.providerui.resource.ProviderUIBundle,
           oracle.webdb.providerui.builder.base.ProviderBuilder"
           session="true" %>

<%!
  private static String getValue (String szValue, 
                                  RequestContext reqContext) 
  {
    String szRet = (String) reqContext.getParameter(szValue);
    return (szRet == null) ? "" : szRet; 
  }
%>

<%
  RequestContext reqContext = 
                      BuilderFactory.getRequestContext();
  Locale locale = reqContext.getLocale();
%>

<%@ include file="ProviderBuilderCaboSetup.jsp" %>

<% 
  ProviderBuilder providerBuilder = BuilderFactory
    .getProviderBuilder(ProviderBuilderConstants.WEBCLIPPING_PROVIDER_BUILDER);
  String resourceBundleClass = providerBuilder.getResourceBundleClass();
  
  ResourceService rs =
    BuilderFactory.getResourceService(resourceBundleClass,locale);

  //String strHeader1Text = rs.getMessage(ProviderUIBundle.EDIT_WEBCLIPPING_PROVIDER_STEP1_TITLE);
  String szTimeoutHeader = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_TIMEOUT_TITLE);
  String szTimeoutExplanation = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_TIMEOUT_DESCRIPTION);
  String szTimeoutLabel = 
	rs.getMessage(ProviderUIBundle.TIMEOUT);
  String szTimeoutValue = getValue(PortletConstants.PORTLET_TIMEOUT, reqContext);  

  String szCacheExpirationHeader = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_CACHE_TITLE);
  String szCacheExpirationExplanation = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_CACHE_DESCRIPTION);
  String szCacheExpirationLabel = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_CACHE_EXPIRATION_LABEL);
  String szCacheExpirationValue = getValue(PortletConstants.PORTLET_CACHE_EXPIRES, reqContext);
  
  String szUseInvalidationCachingLabel = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_CACHE_SCHEME_LABEL);
  String szValidationOption   = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_VALIDATION_CACHE_OPTION);
  String szInvalidationOption = 
	rs.getMessage(ProviderUIBundle.WEBCLIPPING_INVALIDATION_CACHE_OPTION);

  String szUseInvalidationCachingValue = getValue(PortletConstants.USE_INVALIDATION_CACHING, reqContext);
  String szCacheOptionSelected = szUseInvalidationCachingValue.equals("true")?"1":"0"; 

%>

  <uix:tableLayout width="100%">
    <uix:contents>

     <%-- Timeout starts here --%>
     <uix:rowLayout>
        <uix:contents>
          <uix:header text="<%=szTimeoutHeader %>">
            <uix:contents>
              <uix:rowLayout>
                <uix:contents>
                  <uix:styledText styleClass="OraInstructionText"
                        text="<%=szTimeoutExplanation %>"/>
                </uix:contents>
              </uix:rowLayout>
            </uix:contents>
          </uix:header>
        </uix:contents>
      </uix:rowLayout>

      <uix:rowLayout>
        <uix:contents>
          <uix:tableLayout hAlign="center" cellSpacing="5" width="70%">
            <uix:contents>

            <uix:rowLayout>
              <uix:cellFormat height="8"/>
            </uix:rowLayout>

             <uix:rowLayout>
              <uix:contents>
                <uix:cellFormat wrappingDisabled="true">
                 <contents>
                   <uix:styledText styleClass="OraFieldText"
                     text="<%=szTimeoutLabel %>"/>
                 </contents>      
                </uix:cellFormat>
                <uix:cellFormat>
                 <contents>
                   <uix:textInput name="<%=PortletConstants.PORTLET_TIMEOUT %>"
                        text="<%=szTimeoutValue %>" columns="50"/>
                 </contents>      
                </uix:cellFormat>
              </uix:contents>
             </uix:rowLayout>

            </uix:contents>
          </uix:tableLayout>
        </uix:contents>
      </uix:rowLayout>
      <%-- Timeout ends here --%>

     <%-- Cache starts here --%>
     <uix:rowLayout>
        <uix:contents>
          <uix:header text="<%=szCacheExpirationHeader %>">
            <uix:contents>
              <uix:rowLayout>
                <uix:contents>
                  <uix:styledText styleClass="OraInstructionText"
                        text="<%=szCacheExpirationExplanation %>"/>
                </uix:contents>
              </uix:rowLayout>
            </uix:contents>
          </uix:header>
        </uix:contents>
      </uix:rowLayout>

      <uix:rowLayout>
        <uix:contents>
          <uix:tableLayout hAlign="center" cellSpacing="5" width="70%">
            <uix:contents>

            <uix:rowLayout>
              <uix:cellFormat height="8"/>
            </uix:rowLayout>

             <uix:rowLayout>
              <uix:contents>
                <uix:cellFormat wrappingDisabled="true">
                 <contents>
                   <uix:styledText styleClass="OraFieldText"
                     text="<%=szCacheExpirationLabel %>"/>
                 </contents>      
                </uix:cellFormat>
                <uix:cellFormat>
                 <contents>
                   <uix:textInput name="<%=PortletConstants.PORTLET_CACHE_EXPIRES %>"
                        text="<%=szCacheExpirationValue %>" columns="50"/>
                 </contents>      
                </uix:cellFormat>
              </uix:contents>
             </uix:rowLayout>

             <uix:rowLayout>
              <uix:contents>
                <uix:cellFormat wrappingDisabled="true">
                 <contents>
                   <uix:styledText styleClass="OraFieldText"
                     text="<%=szUseInvalidationCachingLabel %>"/>
                 </contents>      
                </uix:cellFormat>
                <uix:cellFormat>
                 <uix:list name="<%=PortletConstants.USE_INVALIDATION_CACHING %>"
                           size="1"
                           selectedIndex="<%=szCacheOptionSelected%>">
                     <uix:contents>
                       <uix:option text="<%= szValidationOption %>" 
                                   value="false"/>
                       <uix:option text="<%= szInvalidationOption %>" 
                                   value="true"/>
                     </uix:contents>                 
                   </uix:list>
                </uix:cellFormat>
              </uix:contents>
             </uix:rowLayout>
        
            </uix:contents>
          </uix:tableLayout>
        </uix:contents>
      </uix:rowLayout>
      <%-- Timeout ends here --%>

    </uix:contents>
  </uix:tableLayout>
