Package net.mlw.vlh

Examples of net.mlw.vlh.ValueListInfo


                ValueListSpaceTag.class);

        Locale local = _parent.getConfig().getLocaleResolver().resolveLocale(
                (HttpServletRequest) pageContext.getRequest());
        MessageSource message = _parent.getConfig().getMessageSource();
      ValueListInfo valueListInfo = getValueListInfo();

        // Create a map of parameters that are used to generate the links.
        parameters = new HashMap(_parent.getTableInfo().getParameters());
        // todo: set these correctly
      parameters.put(ParameterNames.sortColumn, valueListInfo.getSortingColumn());
      parameters.put(ParameterNames.sortDirection, valueListInfo.getSortingDirection());

        StringBuffer sb = new StringBuffer();

        page = _parent.getValueList().getValueListInfo().getPagingPage();
        total = _parent.getValueList().getValueListInfo()
View Full Code Here


      ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);

      Locale local = rootTag.getConfig().getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());
      MessageSource message = rootTag.getConfig().getMessageSource();

      ValueListInfo info = rootTag.getValueList().getValueListInfo();
      if (info.isFocusEnabled())
      {
         StringBuffer sb = new StringBuffer();

         sb.append("<table ").append(getCellAttributes().getCellAttributesAsString()).append(">");
         sb.append("\n <tr>");
         sb.append(generateFocusStatus(info, message, local, rootTag));
         sb.append("\n </tr>");
         sb.append("\n <tr>");
         JspUtils.write(pageContext, sb.toString());
         pageContext.setAttribute("focusStatus" + rootTag.getTableInfo().getId(), new Integer(info.getFocusStatus()));
         return EVAL_BODY_INCLUDE;
      }
      return SKIP_BODY;

   }
View Full Code Here

    * @see javax.servlet.jsp.tagext.Tag#doStartTag()
    */
   public int doEndTag() throws JspException
   {
      ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
      ValueListInfo info = rootTag.getValueList().getValueListInfo();
      if (info.isFocusEnabled())
      {
         JspUtils.write(pageContext, "\n </tr>\n</table>");
      }

      release();
View Full Code Here

      init((HttpServletRequest) pageContext.getRequest());

      Locale locale = getLocale();

      TableInfo tableInfo = getTableInfo();
      ValueListInfo valueListInfo = getValueListInfo();

      // Create a map of parameters that are used to generate the links.
      parameters = new HashMap(tableInfo.getParameters());
      parameters.put(ValueListInfo.SORT_COLUMN + tableInfo.getId(), valueListInfo.getSortingColumn());
      parameters.put(ValueListInfo.SORT_DIRECTION + tableInfo.getId(), valueListInfo.getSortingDirection());

      int page = valueListInfo.getPagingPage();
      int numberOfPages = valueListInfo.getTotalNumberOfPages();

      this.currentPage = page - (pages / 2);
      if (this.currentPage < 1)
      {
         this.currentPage = 1;
      }

      this.maxPage = (this.currentPage - 1) + pages;
      if (this.maxPage > numberOfPages)
      {
         this.currentPage -= (this.maxPage - numberOfPages);
         this.maxPage = numberOfPages;
      }
      if (this.maxPage < 2)
      {
         this.maxPage = 0;
      }
      if (this.currentPage < 1)
      {
         this.currentPage = 1;
      }

      StringBuffer sb = new StringBuffer();

      final String stylePrefix = getConfig().getStylePrefix();
      final String pagingTagStyle = stylePrefix + PAGING_TAG_STYLE + " " + PAGING_TAG_STYLE;
      final String summaryStyle = stylePrefix + SUMMARY_STYLE + " " + SUMMARY_STYLE;
      final String itemsPerPageStyle = stylePrefix + ITEMS_PER_PAGE_STYLE + " " + ITEMS_PER_PAGE_STYLE;
      final String pagingStyle = stylePrefix + PAGING_STYLE + " " + PAGING_STYLE;

      sb.append("<table class='").append(pagingTagStyle).append("'");

      String attributes = getAttributes();
      if (attributes != null)
      {
         if (!BORDER_ATTRIBUTE_PATTERN.matcher(attributes).find())
         {
            sb.append(" border=0");
         }
         if (!CELLSPACING_ATTRIBUTE_PATTERN.matcher(attributes).find())
         {
            sb.append(" cellspacing=0");
         }
         if (!CELLPADDING_ATTRIBUTE_PATTERN.matcher(attributes).find())
         {
            sb.append(" cellpadding=0");
         }
         sb.append(" ").append(attributes);
      }

      sb.append(">");
      sb.append("\n <tr class='").append(pagingTagStyle).append("'>");

      if (showSummary)
      {
         sb.append("\n  <td class='").append(summaryStyle).append("'>");
         renderSumary(sb);
         sb.append("</td>");
         if (showItemsPerPage)
         {
            HashMap itemsPerPageParameters = new HashMap(parameters);
            sb.append("\n  <td class='").append(itemsPerPageStyle).append("'>");
            renderItemsPerPage(sb, itemsPerPageParameters);
            sb.append("</td>");
         }
         sb.append("\n  <td class='").append(pagingStyle).append("'>");
         sb.append("<table border='0' cellspacing='0' cellpadding='0' class='").append(pagingStyle).append("'>");
         sb.append("\n    <tr class='").append(pagingStyle).append("'>");

      }

      parameters.put(ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId(), String.valueOf(valueListInfo.getPagingNumberPer()));

      renderFocusControl(sb);

      String value;
View Full Code Here

    * @todo DO IT WIHTOUT JAVASCRIPT!
    */
   protected void renderItemsPerPage(StringBuffer sb, HashMap itemsPerPageParameters) throws NoSuchMessageException, JspException
   {
      Locale locale = getLocale();
      ValueListInfo valueListInfo = getValueListInfo();
      TableInfo tableInfo = getTableInfo();

      itemsPerPageParameters.remove(ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId());
      itemsPerPageParameters.put(ValueListInfo.PAGING_PAGE + tableInfo.getId(), String.valueOf(valueListInfo.getPagingPage()));

      if (valueListInfo.isFocusEnabled())
      {
         itemsPerPageParameters.put(ValueListInfo.DO_FOCUS + tableInfo.getId(), valueListInfo.isDoFocusAgain() ? "true" : "false");
         if (valueListInfo.getFocusProperty() != null)
         {
            itemsPerPageParameters.put(ValueListInfo.FOCUS_PROPERTY + tableInfo.getId(), valueListInfo.getFocusProperty());
         }
         if (valueListInfo.getFocusValue() != null)
         {
            itemsPerPageParameters.put(ValueListInfo.FOCUS_VALUE + tableInfo.getId(), valueListInfo.getFocusValue());
         }
      }

      String propertyName = ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId();

      String delim = getMessage("paging.delim", null, "", locale);
      sb.append(delim);

      final String stylePrefix = getConfig().getStylePrefix();
      final String commonStyle = stylePrefix + ITEMS_PER_PAGE_STYLE + " " + ITEMS_PER_PAGE_STYLE;
      final String labelStyle = stylePrefix + LABEL_STYLE + " " + LABEL_STYLE;
      final String inputBoxStyle = stylePrefix + INPUT_BOX_STYLE + " " + INPUT_BOX_STYLE;
      final String submitButtonStyle = stylePrefix + SUBMIT_BUTTON_STYLE + " " + SUBMIT_BUTTON_STYLE;

      if (isGenerateItemsPerPageForm())
      {
         sb.append("<form action='#' onsubmit='return false;' class='").append(commonStyle).append("'>");
      }

      sb.append("<table border='0' cellspacing='0' cellpadding='0' class='").append(commonStyle).append("'>");

      sb.append("\n    <tr class='").append(commonStyle).append("'>");

      Map labelAttrs = new HashMap();
      labelAttrs.put("class", labelStyle);

      sb.append("\n     <td nowrap='true' class='").append(labelStyle).append("'>");
      renderPerPageLabel(sb, labelAttrs, getMessage("paging.itemsPerPage.label", null, locale));
      sb.append("</td>");

      Map inputBoxAttrs = new HashMap();
      inputBoxAttrs.put("id", propertyName);
      inputBoxAttrs.put("name", propertyName);
      inputBoxAttrs.put("class", inputBoxStyle);
      inputBoxAttrs.put("title", getMessage("paging.itemsPerPage.title", null, locale));
      inputBoxAttrs.put("value", new Integer(valueListInfo.getPagingNumberPer()));

      sb.append("\n     <td class='").append(inputBoxStyle).append("'>");
      renderPerPageInputBox(sb, inputBoxAttrs);
      sb.append("</td>");

View Full Code Here

    * @throws NoSuchMessageException
    */
   protected void renderSumary(StringBuffer sb) throws NoSuchMessageException, JspException
   {
      Locale locale = getLocale();
      ValueListInfo valueListInfo = getValueListInfo();
      sb.append(getMessage("paging.text.totalRow", new Object[]
      { new Integer(valueListInfo.getTotalNumberOfEntries()) }, locale));
      sb.append(getMessage("paging.text.pageFromTotal", new Object[]
      { new Integer(valueListInfo.getPagingPage()), new Integer(valueListInfo.getTotalNumberOfPages()) }, locale));
   }
View Full Code Here

    */
   protected void renderFocusControl(StringBuffer sb) throws JspException
   {

      Locale locale = getLocale();
      ValueListInfo valueListInfo = getValueListInfo();
      TableInfo tableInfo = getTableInfo();

      String value;

      if (valueListInfo.isFocusEnabled())
      {
         parameters.put(ValueListInfo.FOCUS_PROPERTY + tableInfo.getId(), valueListInfo.getFocusProperty());

         if (valueListInfo.getFocusValue() != null)
         {
            parameters.put(ValueListInfo.FOCUS_VALUE + tableInfo.getId(), valueListInfo.getFocusValue());
         }
         // AAA focus error behavier
         HashMap focusParameters = new HashMap(parameters);
         if (valueListInfo.getFocusStatus() != ValueListInfo.FOCUS_TOO_MANY_ITEMS)
         {
            focusParameters.put(ValueListInfo.DO_FOCUS + tableInfo.getId(), valueListInfo.isDoFocusAgain() ? "false" : "true");

            value = getMessage(valueListInfo.isDoFocusAgain() ? "paging.focus(off)" : "paging.focus(on)", null, locale);

            sb.append("\n     <td>");
            renderPagingLink(sb, parameters, value);
            sb.append("</td>");

            String delim = getMessage("paging.delim", null, "", locale);
            if (value.length() > 0 && delim.length() > 0)
            {
               sb.append("\n     <td>").append(delim).append("</td>");
            }
         }
         else
         {
            if (valueListInfo.isFocusEnabled())
            {
               sb.append("\n     <td>").append(getMessage("paging.focus(error)", null, locale)).append("</td>");
            }
         }

View Full Code Here

    * @param sb
    * @param label
    */
   private void renderContent(StringBuffer sb, String label)
   {
      ValueListInfo valueListInfo = getValueListInfo();
      TableInfo tableInfo = getTableInfo();
      if (this.currentPage == valueListInfo.getPagingPage())
      {
         sb.append("\n     <th>").append(label).append("</th>");
      }
      else
      {
View Full Code Here

      Locale locale = getLocale();

      String delim = getMessage("paging.delim", null, locale);

      ValueListInfo valueListInfo = getValueListInfo();
      TableInfo tableInfo = getTableInfo();

      int page = valueListInfo.getPagingPage();
      int numberOfPages = valueListInfo.getTotalNumberOfPages();

      if (getBodyContent() == null || getBodyContent().getString() == null || getBodyContent().getString().trim().length() == 0)
      {
         while (this.currentPage <= this.maxPage)
         {
View Full Code Here

    */
   public int doEndTag() throws JspException
   {
      ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);

      ValueListInfo info = ValueListRequestUtil.buildValueListInfo((HttpServletRequest) pageContext.getRequest(), rootTag.getTableInfo()
            .getId());
      info.getFilters().putAll(getCellAttributes().getMap());

      WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());

      if (context == null)
      {
         final String message = "Cannot locate the spring WebApplicationContext. Is it configured in your web.xml?";
         LOGGER.error(message);
         throw new JspException(message);
      }

      ValueListHandler vlh = (ValueListHandler) context.getBean(ValueListHandler.DEFAULT_SERVICE_NAME, ValueListHandler.class);
      if (vlh == null)
      {
         final String message = "Cannot locate the ValueListHanlder in the WebApplicationContext, under the name: \""
               + ValueListHandler.DEFAULT_SERVICE_NAME + "\"";
         LOGGER.error(message);
         throw new JspException(message);
      }

      info.setFocusValue(focusValue);
      info.setFocusProperty(focusProperty);

      if (LOGGER.isDebugEnabled())
      {
         LOGGER.debug("Focus settings was setted up. Focus property '" + focusProperty + "', focus value '" + focusValue + "'");
      }
View Full Code Here

TOP

Related Classes of net.mlw.vlh.ValueListInfo

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.