コード例 #1
0
  /** 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
コード例 #2
0
 /** 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
コード例 #3
0
  /** 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