/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.ui.helpers;

import java.io.IOException;
import java.net.URLEncoder;
import javax.servlet.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.servlet.RequestImpl;

public class LogInOrCreate extends ThrowableContent implements ContentJSP
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private RequestInput rinput = null;

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  public LogInOrCreate()
  {
    super();

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface Content
   *--------------------------------------------------------------------------------
   */

  public boolean needFrame()
  {
    return true;

  } // end needFrame

  public int getMenuSelector()
  {
    return MENU_SELECTOR_NOCHANGE;

  } // end getMenuSelector

  public String getPageTitle(RequestOutput ro)
  {
    return "Log In or Create Account";

  } // end getPageTitle

  public String getPageQID()
  {
    return null;

  } // end getPageQID

  /*--------------------------------------------------------------------------------
   * Implementations from interface ContentJSP
   *--------------------------------------------------------------------------------
   */

  public String getJSPName()
  {
    return "helpers/login_or_create.jsp";

  } // end getJSPName

  public void initialize(RequestInput req)
  {
    rinput = req;

  } // end initialize

  public void terminate(RequestInput req)
  {
    rinput = null;

  } // end terminate

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  public final String getTargetParam()
  {
    return (rinput!=null) ? URLEncoder.encode(rinput.getLocation()) : null;

  } // end getTargetParam

  /*--------------------------------------------------------------------------------
   * External static operations
   *--------------------------------------------------------------------------------
   */

  public static final LogInOrCreate get(ServletRequest sreq) throws ServletException
  {
    Object obj = sreq.getAttribute(RequestImpl.REQUEST_CONTENT);
    if (obj==null)
      throw new ServletException("LogInOrCreate.get: unable to get request content");
    if (obj instanceof LogInOrCreate)
      return (LogInOrCreate)obj;
    throw new ServletException("LogInOrCreate.get: request content is not a LogInOrCreate object");

  } // end get

} // end class LogInOrCreate
