Package net.mlw.vlh.web

Examples of net.mlw.vlh.web.ValueListConfigBean


    /**
     * @return style
     */
    public String getRowStyleClass() throws JspException {
        ValueListConfigBean config = getRootTag().getConfig();
        if (currentRowNumber == getRootTag().getValueList().getValueListInfo().getFocusedRowNumberInTable())
        {
           return config.getFocusedRowStyle();

        }
        else {
            return (currentRowNumber % config.getStyleCount() == 0) ? "odd" : "even";
        }
    }
View Full Code Here


    public String getHeaderLabel(ColumnInfo columnInfo, TableInfo tableInfo,
                                 ValueListInfo info, Map includeParameters)
    {
        StringBuffer sb = new StringBuffer();

        ValueListConfigBean config = tableInfo.getConfig();
        Map parameters = new HashMap(includeParameters);

        if (columnInfo.getDefaultSort() != null)
        {
            // Get the current sort column and direction.
            String column = info.getSortingColumn();
            Integer direction = info.getSortingDirection();

            sb.append("<a href=\"").append(tableInfo.getUrl());

            parameters.put(ValueListInfo.PAGING_PAGE + tableInfo.getId(), "1");
            parameters.put(ValueListInfo.SORT_COLUMN + tableInfo.getId(),
                    columnInfo.getAdapterPropertyName());
            parameters
                    .put(
                            ValueListInfo.SORT_DIRECTION + tableInfo.getId(),
                            ((columnInfo.getAdapterPropertyName()
                                    .equals(column)) ? (ValueListInfo.ASCENDING
                                    .equals(direction) ? ValueListInfo.DESCENDING
                                    : ValueListInfo.ASCENDING)
                                    : columnInfo.getDefaultSort()));

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

            sb.append(config.getLinkEncoder().encode(
                    tableInfo.getPageContext(), parameters));

            sb.append("\">").append(columnInfo.getTitle()).append("</a>");
        }
        else
View Full Code Here

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

      DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);

      ValueListConfigBean config = rootTag.getConfig();

      appendClassCellAttribute(rowTag.getRowStyleClass());

      if (locale == null)
      {
         locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());
      }

      if (rowTag.getCurrentRowNumber() == 0) // if this is the 1st row == the one with cell headers
      {

         String titleKey = getTitleKey();
         String label = (titleKey == null) ? getTitle() : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);

         ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, label), getAdapterProperty(), defaultSort,
               getAttributes());

         // Process toolTip if any
         // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
         String toolTipKey = getToolTipKey();
         columnInfo.setToolTip((toolTipKey == null) ? getToolTip() : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey,
               locale));

         columnInfo.setNestedList(this.nestedColumnInfoList);

         rowTag.addColumnInfo(columnInfo);
      }

      DisplayProvider displayProvider = rowTag.getDisplayProvider();

      StringBuffer sb = new StringBuffer(displayProvider.getCellPreProcess(getCellAttributes()));

      if (displayProvider.doesIncludeBodyContent() && bodyContent != null && bodyContent.getString() != null
            && bodyContent.getString().trim().length() > 0)
      {
         sb.append(bodyContent.getString().trim());
         bodyContent.clearBody();
      }
      else
      {
         if (property != null && rowTag.getBeanName() != null)
         {
            try
            {
               Object bean = pageContext.getAttribute(rowTag.getBeanName());
               if (bean != null)
               {
                  Object value = null;
                  try
                  {
                     value = PropertyUtils.getProperty(bean, property);
                  }
                  catch (Exception e)
                  {
                     //Do nothing, if you want to handle this exception, then
                     // use a try catch in the body content.
                     LOGGER.error("<vlh:column> Error getting property='" + property + "' from the iterated JavaBean name='"
                           + rowTag.getBeanName() + "'\n The row's JavaBean was >>>" + bean
                           + "<<<\n Check the syntax or the spelling of the column's property!");
                  }

                  if (value != null)
                  {
                     if (sum != null && value instanceof Number)
                     {
                        double doubleValue = ((Number) value).doubleValue();
                        Double sumValue = (Double) pageContext.getAttribute(sum);
                        if (sumValue == null)
                        {
                           sumValue = new Double(doubleValue);
                        }
                        else
                        {
                           sumValue = new Double(sumValue.doubleValue() + doubleValue);
                        }
                        pageContext.setAttribute(sum, sumValue);
                     }
                     String formattedValue = JspUtils.format(value, format, locale);

                     if (groupKey == null
                           || (config.getCellInterceptor() == null || !config.getCellInterceptor().isHidden(pageContext, groupKey,
                                 property, formattedValue)))
                     {
                        sb.append(displayProvider.emphase(formattedValue, getEmphasisPattern(), getColumnStyleClass()));
                     }

                  }
                  else
                  {
                     if (LOGGER.isDebugEnabled())
                     {
                        LOGGER.debug("The property '" + property + "' of the iterated JavaBean '" + bean + "' is null!");
                     }

                     Object nullValue = (defaultValue == null) ? config.getNullToken() : defaultValue;

                     if (groupKey == null
                           || (config.getCellInterceptor() == null || !config.getCellInterceptor().isHidden(pageContext, groupKey,
                                 property, nullValue)))
                     {
                        sb.append(nullValue);
                     }
                  }
View Full Code Here

   public String getColumnStyleClass() throws JspException
   {

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

      ValueListConfigBean config = rootTag.getConfig();

      if (config == null)
      {
         throw new JspException("No config found on root tag");
      }

      return config.getStylePrefix();
   }
View Full Code Here

    */
   public int doEndTag() throws JspException
   {

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

      DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);
      appendClassCellAttribute(rowTag.getRowStyleClass());

      Locale locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());

      if (rowTag.getCurrentRowNumber() == 0)
      {
         String titleKey = getTitleKey();
         String label = (titleKey == null) ? getTitle() : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);

         StringBuffer header = new StringBuffer(512);
         if (label != null)
         {
            header.append(label);
         }

         header
               .append("<input type=\"checkbox\" onclick=\"for(i=0; i < this.form.elements.length; i++) {if (this.form.elements[i].name=='")
               .append(getName()).append("') {this.form.elements[i].checked = this.checked;}}\"/>");

         ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, header.toString()), property, null,
               getAttributes());

         // Process toolTip if any
         // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
         String toolTipKey = getToolTipKey();
         columnInfo.setToolTip((toolTipKey == null) ? getToolTip() : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey,
               locale));

         rowTag.addColumnInfo(columnInfo);
      }

View Full Code Here

    * @return The formated HTML.
    */
   public String getHeaderLabel(ColumnInfo columnInfo, TableInfo tableInfo, ValueListInfo info, Map includeParameters)
   {

      ValueListConfigBean config = tableInfo.getConfig();
      Map parameters = new HashMap(includeParameters);

      if (columnInfo.getDefaultSort() != null)
      {
         // Get the current sort column and direction.
         String column = info.getSortingColumn();
         Integer direction = info.getSortingDirection();

         parameters.put(ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId(), String.valueOf(info.getPagingNumberPer()));
         parameters.put(ValueListInfo.PAGING_PAGE + tableInfo.getId(), "1");
         parameters.put(ValueListInfo.SORT_COLUMN + tableInfo.getId(), columnInfo.getAdapterPropertyName());
         parameters
               .put(
                     ValueListInfo.SORT_DIRECTION + tableInfo.getId(),
                     ((columnInfo.getAdapterPropertyName().equals(column)) ? (ValueListInfo.ASCENDING.equals(direction) ? ValueListInfo.DESCENDING
                           : ValueListInfo.ASCENDING)
                           : columnInfo.getDefaultSort()));

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

         StringBuffer sb = new StringBuffer();

         renderHeaderLabelLink(sb, columnInfo, tableInfo, info, parameters);

         if (columnInfo.getAdapterPropertyName().equals(column))
         {
            if (usePadding)
            {
               sb.append("&nbsp;");
            }
            sb.append("<img src=\"").append(getImageHome((HttpServletRequest) tableInfo.getPageContext().getRequest())).append("/sort(");
            sb.append((ValueListInfo.ASCENDING.equals(direction) ? ValueListInfo.DESCENDING : ValueListInfo.ASCENDING));
            sb.append(").png\" border=\"0\"/>");
         }
         else if (columnInfo.getDefaultSort() != null)
         {
            Locale locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) (tableInfo.getPageContext().getRequest()));
            String altSort;
            try
            {
               altSort = config.getDisplayHelper().help(tableInfo.getPageContext(),
                     config.getMessageSource().getMessage("sorting", null, "Sort", locale));
            }
            catch (JspException e)
            {
               LOGGER.error("getHeaderLabel() - Error getting property 'sorting' : " + e.getMessage()
                     + " Locale locale = " + locale
View Full Code Here

   }

   protected void init(HttpServletRequest request) throws JspException
   {
      this.rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
      ValueListConfigBean config = rootTag.getConfig();
      this.displayHelper = config.getDisplayHelper();
      this.messageSource = config.getMessageSource();
      this.currentLocale = config.getLocaleResolver().resolveLocale(request);
   }
View Full Code Here

    * @return The formated HTML.
    */
   public String getHeaderLabel(ColumnInfo columnInfo, TableInfo tableInfo, ValueListInfo info, Map includeParameters)
   {

      ValueListConfigBean config = tableInfo.getConfig();
      Map parameters = new HashMap(includeParameters);

      if (columnInfo.getDefaultSort() != null)
      {
         //Get the current sort column and direction.
View Full Code Here

    * @see javax.servlet.jsp.tagext.Tag#doEndTag()
    */
   public int doEndTag() throws JspException
   {
      ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
      ValueListConfigBean config = rootTag.getConfig();
      DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);
      appendClassCellAttribute(rowTag.getRowStyleClass());
      Locale locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());

      if (rowTag.getCurrentRowNumber() == 0)
      {
         String titleKey = getTitleKey();
         String label = (titleKey == null) ? getTitle() : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);

         ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, label), null, null, getAttributes());
        
         // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
         String toolTipKey = getToolTipKey();
         columnInfo.setToolTip((toolTipKey == null) ? getToolTip() : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey,
               locale));

         rowTag.addColumnInfo(columnInfo);
      }

View Full Code Here

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

      DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);

      ValueListConfigBean config = rootTag.getConfig();

      appendClassCellAttribute(rowTag.getRowStyleClass());

      if (locale == null)
      {
         locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());
      }

      if (rowTag.getCurrentRowNumber() == 0) // if this is the 1st row == the one with cell headers
      {

         String titleKey = getTitleKey();
         String label = (titleKey == null) ? getTitle() : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);

         ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, label), getAdapterProperty(), defaultSort,
               getAttributes());

         // Process toolTip if any
         // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
         String toolTipKey = getToolTipKey();
         columnInfo.setToolTip((toolTipKey == null) ? getToolTip() : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey,
               locale));

         columnInfo.setNestedList(this.nestedColumnInfoList);

         rowTag.addColumnInfo(columnInfo);
      }

      DisplayProvider displayProvider = rowTag.getDisplayProvider();

      StringBuffer sb = new StringBuffer(displayProvider.getCellPreProcess(getCellAttributes()));

      boolean hasBodyContent = false;
     
      if (displayProvider.doesIncludeBodyContent() && bodyContent != null && bodyContent.getString() != null
            && bodyContent.getString().trim().length() > 0)
      {
         sb.append(bodyContent.getString().trim());
         bodyContent.clearBody();
         hasBodyContent = true;
      }
     
      {
         if (property != null && rowTag.getBeanName() != null)
         {
            try
            {
               Object bean = pageContext.getAttribute(rowTag.getBeanName());
               if (bean != null)
               {
                  Object value = null;
                  try
                  {
                     value = PropertyUtils.getProperty(bean, property);
                  }
                  catch (Exception e)
                  {
                     //Do nothing, if you want to handle this exception, then
                     // use a try catch in the body content.
                     LOGGER.error("<vlh:column> Error getting property='" + property + "' from the iterated JavaBean name='"
                           + rowTag.getBeanName() + "'\n The row's JavaBean was >>>" + bean
                           + "<<<\n Check the syntax or the spelling of the column's property!");
                  }

                  if (value != null)
                  {
                     if (sum != null && value instanceof Number)
                     {
                        double doubleValue = ((Number) value).doubleValue();
                        Double sumValue = (Double) pageContext.getAttribute(sum);
                        if (sumValue == null)
                        {
                           sumValue = new Double(doubleValue);
                        }
                        else
                        {
                           sumValue = new Double(sumValue.doubleValue() + doubleValue);
                        }
                        pageContext.setAttribute(sum, sumValue);
                     }
                    
                     if( ! hasBodyContent)
                     {
                     String formattedValue = JspUtils.format(value, format, locale);

                     if (groupKey == null
                           || (config.getCellInterceptor() == null || !config.getCellInterceptor().isHidden(pageContext, groupKey,
                                 property, formattedValue)))
                     {
                        sb.append(displayProvider.emphase(formattedValue, getEmphasisPattern(), getColumnStyleClass()));
                     }
                     }

                  }
                  else if (!hasBodyContent)
                  {
                     if (LOGGER.isDebugEnabled())
                     {
                        LOGGER.debug("The property '" + property + "' of the iterated JavaBean '" + bean + "' is null!");
                     }

                     Object nullValue = (defaultValue == null) ? config.getNullToken() : defaultValue;

                     if (groupKey == null
                           || (config.getCellInterceptor() == null || !config.getCellInterceptor().isHidden(pageContext, groupKey,
                                 property, nullValue)))
                     {
                        sb.append(nullValue);
                     }
                  }
View Full Code Here

TOP

Related Classes of net.mlw.vlh.web.ValueListConfigBean

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.