/** Handle a Search request. */
  public void doSearch(RunData runData, Context context) {
    // access the portlet element id to find our state
    String peid = ((JetspeedRunData) runData).getJs_peid();
    SessionState state = ((JetspeedRunData) runData).getPortletSessionState(peid);

    // read the search form field into the state object
    String search = StringUtil.trimToNull(runData.getParameters().getString(FORM_SEARCH));

    // set the flag to go to the prev page on the next list
    if (search == null) {
      state.removeAttribute(STATE_SEARCH);
    } else {
      state.setAttribute(STATE_SEARCH, search);
    }

    // start paging again from the top of the list
    resetPaging(state);

    // if we are searching, turn off auto refresh
    if (search != null) {
      ObservingCourier observer = (ObservingCourier) state.getAttribute(STATE_OBSERVER);
      if (observer != null) {
        observer.disable();
      }
    }

    // else turn it back on
    else {
      enableObserver(state);
    }
  } // doSearch
 /** Enable the observer, unless we are in search mode, where we want it disabled. */
 public void enableObserver(SessionState state) {
   // get the observer
   ObservingCourier observer = (ObservingCourier) state.getAttribute(STATE_OBSERVER);
   if (observer != null) {
     // we leave it disabled if we are searching, or if the user has last selected to be manual
     if ((state.getAttribute(STATE_SEARCH) != null)
         || (state.getAttribute(STATE_MANUAL_REFRESH) != null)) {
       observer.disable();
     } else {
       observer.enable();
     }
   }
 } // enableObserver
  /** Add the menus for manual / auto - refresh. */
  protected void addRefreshMenus(Menu bar, SessionState state) {
    // only offer if there's an observer
    ObservingCourier observer = (ObservingCourier) state.getAttribute(STATE_OBSERVER);
    if (observer == null) return;

    bar.add(new MenuDivider());
    bar.add(
        new MenuEntry(
            (observer.getEnabled() ? rb.getString("ref.manref") : rb.getString("ref.autoref")),
            "doAuto"));
    if (!observer.getEnabled()) {
      bar.add(new MenuEntry(rb.getString("ref.refresh"), "doRefresh"));
    }
  } // addRefreshMenus
  /** Toggle auto-update */
  public void doAuto(RunData data, Context context) {
    // access the portlet element id to find our state
    String peid = ((JetspeedRunData) data).getJs_peid();
    SessionState state = ((JetspeedRunData) data).getPortletSessionState(peid);

    // get the observer
    ObservingCourier observer = (ObservingCourier) state.getAttribute(STATE_OBSERVER);
    if (observer != null) {
      boolean enabled = observer.getEnabled();
      if (enabled) {
        observer.disable();
        state.setAttribute(STATE_MANUAL_REFRESH, "manual");
      } else {
        observer.enable();
        state.removeAttribute(STATE_MANUAL_REFRESH);
      }
    }
  } // doAuto