Package org.hdiv.state

Examples of org.hdiv.state.IPage


    assertTrue(pageId > 0);
  }

  public void testAddPage() {

    IPage page = new Page();
    page.setId(20);

    IState state = new State(0);
    state.setAction("/action");
    IParameter param = new Parameter("name", "value", false, null, true);
    state.addParameter(param);
    page.addState(state);

    session.addPage("20", page);

  }
View Full Code Here


  }

  public void testGetState() {

    IPage page = new Page();
    page.setId(20);

    IState state = new State(0);
    state.setAction("/action");
    IParameter param = new Parameter("name", "value", false, null, true);
    state.addParameter(param);
    page.addState(state);

    session.addPage("20", page);

    // Restore state
    IState restored = session.getState("20", 0);
View Full Code Here

    assertEquals(state, restored);
  }

  public void testGetPage() {

    IPage page = new Page();
    page.setId(20);

    IState state = new State(0);
    state.setAction("/action");
    IParameter param = new Parameter("name", "value", false, null, true);
    state.addParameter(param);
    page.addState(state);

    session.addPage("20", page);

    // Restore page
    IPage restored = session.getPage("20");

    assertNotNull(restored);
    assertEquals(page, restored);
  }
View Full Code Here

  public void testAddPage() {

    // cache's maximum size is defined using the Spring factory.
    IStateCache cache = this.getApplicationContext().getBean(IStateCache.class);

    IPage page1 = new Page();
    IPage page2 = new Page();
    IPage page3 = new Page();

    IState state1 = new State(0);
    IState state2 = new State(0);
    IState state3 = new State(0);

    page1.addState(state1);
    page1.setId(1);
    cache.addPage("1");

    page2.addState(state2);
    page2.setId(2);
    cache.addPage("2");

    page3.addState(state3);
    page3.setId(3);
    cache.addPage("3");

    log.info("cache:" + cache.toString());
  }
View Full Code Here

    assertNotNull(stateId);
    request.addParameter("_PREVIOUS_HDIV_STATE_", stateId);

    // New request
    IState state = this.stateUtil.restoreState(stateId);
    IPage page = this.session.getPage(state.getPageId() + "");
    dataComposer = this.dataComposerFactory.newInstance(request);
    HDIVUtil.setDataComposer(dataComposer, request);

    dataComposer.startPage(page);
    dataComposer.beginRequest(state);
View Full Code Here

    if (preState != null && preState.length() > 0) {

      // We are modifying an existing state, preload dataComposer with it
      IState state = this.stateUtil.restoreState(preState);
      if (state.getPageId() > 0) {
        IPage page = this.session.getPage(state.getPageId() + "");
        if (page != null) {
          dataComposer.startPage(page);
        }
      }
      if (state != null) {
        dataComposer.beginRequest(state);
      }

    } else if (this.reuseExistingPage(request)) {
      String hdivStateParamName = (String) request.getSession().getAttribute(Constants.HDIV_PARAMETER);
      String hdivState = request.getParameter(hdivStateParamName);

      if (hdivState != null) {
        IState state = this.stateUtil.restoreState(hdivState);
        if (state.getPageId() > 0) {
          IPage page = this.session.getPage(Integer.toString(state.getPageId()));
          dataComposer.startPage(page);
        } else {
          dataComposer.startPage();
        }
      } else {
View Full Code Here

      String stateId = stateScope.addState(state, this.getStateSuffix(state.getMethod()));
      return stateId;
    }

    // Add to page scope
    IPage page = this.getPage();
    state.setPageId(page.getId());
    page.addState(state);

    // Save Page in session if this is the first state to add
    boolean firstState = page.getStatesCount() == 1;
    if (firstState) {

      super.session.addPage(page.getName(), page);
    }

    String id = this.getPage().getId() + DASH + state.getId() + DASH + this.getStateSuffix(state.getMethod());
    return id;
  }
View Full Code Here

    if (this.isRequestStarted()) {
      // A request is started but not ended
      this.endRequest();
    }

    IPage page = this.getPage();
    if (page.getStatesCount() > 0) {
      // The page has states, update them in session
      super.session.addPage(page.getName(), page);
    } else {
      if (log.isDebugEnabled()) {
        log.debug("The page [" + page.getName() + "] has no states, is not stored in session");
      }
    }

  }
View Full Code Here

    List<String> pageIds = cache.getPageIds();

    for (int i = 0; i < pageIds.size(); i++) {

      String pageId = pageIds.get(i);
      IPage currentPage = this.getPageFromSession(session, pageId);
      if ((currentPage != null) && (currentPage.getFlowId() != null)) {

        String pageFlowId = currentPage.getFlowId();

        if (conversationId.equalsIgnoreCase(pageFlowId)) {

          this.removePageFromSession(session, pageId);
          pageIds.remove(i);
View Full Code Here

   *         exception is thrown.
   */
  public IState getState(String pageId, int stateId) {

    try {
      IPage currentPage = this.getPage(pageId);
      return currentPage.getState(stateId);

    } catch (Exception e) {
      throw new HDIVException(HDIVErrorCodes.PAGE_ID_INCORRECT, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.hdiv.state.IPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.