/*
 * 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-02 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.ui.conf.view;

import java.util.*;
import javax.servlet.*;
import org.apache.log4j.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.conf.*;
import com.silverwrist.venice.ui.helpers.HTMLRendering;
import com.silverwrist.venice.ui.servlet.RequestImpl;

public class FindPostView implements ContentJSP
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private RequestInput rinput = null;
  private HTMLRendering html = null;
  private CommunityContext comm;
  private ConferenceContext conf;
  private TopicContext topic;
  private String term = "";
  private int offset = 0;
  private int find_count = 0;
  private List results = null;
  private int max_results = 0;

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

  public FindPostView(CommunityContext comm, ConferenceContext conf, TopicContext topic)
  {
    this.comm = comm;
    this.conf = conf;
    this.topic = topic;

  } // end constructor

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

  public boolean needFrame()
  {
    return true;

  } // end needFrame

  public int getMenuSelector()
  {
    return MENU_SELECTOR_COMMUNITY;

  } // end getMenuSelector

  public String getPageTitle(RequestOutput ro)
  {
    return "Find Posts";

  } // end getPageTitle

  public String getPageQID()
  {
    return null;

  } // end getPageQID

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

  public String getJSPName()
  {
    return "conf/find.jsp";

  } // end getJSPName

  public void initialize(RequestInput req)
  {
    rinput = req;
    html = (HTMLRendering)(req.queryService(HTMLRendering.class));

  } // end initialize

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

  } // end terminate

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

  public final CommunityContext getCommunity()
  {
    return comm;

  } // end getCommunity

  public final ConferenceContext getConference()
  {
    return conf;

  } // end getConference

  public final TopicContext getTopic()
  {
    return topic;

  } // end getTopic

  public final String getTerm()
  {
    return term;

  } // end getTerm

  public final void setTerm(String s)
  {
    term = s;

  } // end setTerm

  public final int getOffset()
  {
    return offset;

  } // end getOffset

  public final void setOffset(int v)
  {
    offset = v;

  } // end setOffset

  public final int getFindCount()
  {
    return find_count;

  } // end getFindCount

  public final void setFindCount(int v)
  {
    find_count = v;

  } // end setFindCount

  public final List getResults()
  {
    return results;

  } // end getResults

  public final void setResults(List l)
  {
    results = l;

  } // end setResults

  public final int getMaxResults()
  {
    return max_results;

  } // end getMaxResults

  public final void setMaxResults(int v)
  {
    max_results = v;

  } // end setMaxResults

  public final String formatDate(Date date)
  {
    return ((html==null) ? null : html.formatDate(date));

  } // end formatDate

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

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

  } // end get

} // end class FindPostView
