Example #1
0
 /**
  * @see org.esupportail.commons.web.component.UIAbstractPaginatorStyle#makeDivPages(
  *     javax.faces.application.Application)
  */
 @SuppressWarnings("unchecked")
 @Override
 protected Div makeDivPages(final Application a) {
   if (logger.isDebugEnabled()) {
     logger.debug("entering makeDivPagination(" + a + ")");
   }
   Div divPages = (Div) a.createComponent(Div.COMPONENT_TYPE);
   divPages.setParent(this);
   divPages.setStyleClass(NAVIGATION_BLOCK);
   // if there are more than one page on display pagination
   if (getPaginator().getFirstPageNumber() != getPaginator().getLastPageNumber()) {
     HtmlTag ul1 = (HtmlTag) a.createComponent(HtmlTag.COMPONENT_TYPE);
     ul1.setValue(HTML.UL_ELEM);
     ul1.setParent(divPages);
     // PREVIOUS BUTTON
     if (getPaginator().getCurrentPage() != getPaginator().getFirstPageNumber()) {
       ul1.getChildren()
           .add(
               makeLiGroup(
                   a,
                   getStringsVar() + "['" + PREVIOUS_BUTTON_I18N_KEY + "']",
                   null,
                   true,
                   PaginatorUtils.GOTO_PREVIOUS,
                   null,
                   null));
     }
     // BODY of Paginator
     divPages = makePages(divPages, getPaginator(), ul1, a);
   }
   return divPages;
 }
Example #2
0
  /**
   * @param divPagination
   * @param pagi
   * @param ul1
   * @param a
   * @return Div
   */
  @SuppressWarnings("unchecked")
  private Div makePages(
      final Div divPagination, final Paginator pagi, final HtmlTag ul1, final Application a) {
    Div divTemp = divPagination;
    if (!pagi.getFirstPagesNumber().isEmpty()) {
      for (Object o : pagi.getFirstPagesNumber()) {
        Integer page = (Integer) o;
        if (page != pagi.getCurrentPage()) {
          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      null));
        } else {

          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      PaginatorUtils.CURRENT_PAGE));
        }
      }
      ul1.getChildren().add(makeLiText(a));
      String nameValueButton =
          getPaginatorELExpression() + "." + PaginatorUtils.LAST_PAGE_NUMBER + "+1";
      ul1.getChildren()
          .add(
              makeLiGroup(
                  a,
                  nameValueButton,
                  PaginatorUtils.LAST_PAGE_NUMBER,
                  true,
                  PaginatorUtils.RELOAD_DATA,
                  PaginatorUtils.CURRENT_PAGE,
                  null));
    } else if (!pagi.getLastPagesNumber().isEmpty()) {
      String nameValueButton =
          getPaginatorELExpression() + "." + PaginatorUtils.FIRST_PAGE_NUMBER + "+1";
      ul1.getChildren()
          .add(
              makeLiGroup(
                  a,
                  nameValueButton,
                  PaginatorUtils.FIRST_PAGE_NUMBER,
                  true,
                  PaginatorUtils.RELOAD_DATA,
                  PaginatorUtils.CURRENT_PAGE,
                  null));
      ul1.getChildren().add(makeLiText(a));
      for (Object o : pagi.getLastPagesNumber()) {
        Integer page = (Integer) o;
        if (page != pagi.getCurrentPage()) {
          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      null));
        } else {
          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      PaginatorUtils.CURRENT_PAGE));
        }
      }
    } else if (!pagi.getMiddlePagesNumber().isEmpty()) {
      String nameValueButton =
          getPaginatorELExpression() + "." + PaginatorUtils.FIRST_PAGE_NUMBER + "+1";
      ul1.getChildren()
          .add(
              makeLiGroup(
                  a,
                  nameValueButton,
                  PaginatorUtils.FIRST_PAGE_NUMBER,
                  true,
                  PaginatorUtils.RELOAD_DATA,
                  PaginatorUtils.CURRENT_PAGE,
                  null));
      ul1.getChildren().add(makeLiText(a));
      for (Object o : pagi.getMiddlePagesNumber()) {
        Integer page = (Integer) o;
        if (page != pagi.getCurrentPage()) {
          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      null));
        } else {

          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      PaginatorUtils.CURRENT_PAGE));
        }
      }
      ul1.getChildren().add(makeLiText(a));
      nameValueButton = getPaginatorELExpression() + "." + PaginatorUtils.LAST_PAGE_NUMBER + "+1";
      ul1.getChildren()
          .add(
              makeLiGroup(
                  a,
                  nameValueButton,
                  PaginatorUtils.LAST_PAGE_NUMBER,
                  true,
                  PaginatorUtils.RELOAD_DATA,
                  PaginatorUtils.CURRENT_PAGE,
                  null));
    } else {
      // in the case of a paginator with very little page
      for (Object o : pagi.getNearPages()) {
        Integer page = (Integer) o;
        if (page != pagi.getCurrentPage()) {
          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      null));
        } else {

          ul1.getChildren()
              .add(
                  makeLiGroup(
                      a,
                      "" + (page + 1),
                      "" + page,
                      false,
                      PaginatorUtils.RELOAD_DATA,
                      PaginatorUtils.CURRENT_PAGE,
                      PaginatorUtils.CURRENT_PAGE));
        }
      }
    }
    if (getPaginator().getCurrentPage() != getPaginator().getLastPageNumber()) {
      ul1.getChildren()
          .add(
              makeLiGroup(
                  a,
                  getStringsVar() + "['" + NEXT_BUTTON_I18N_KEY + "']",
                  null,
                  true,
                  PaginatorUtils.GOTO_NEXT,
                  null,
                  null));
    }
    divTemp.getChildren().add(ul1);
    return divTemp;
  }