Tapestry
  1. Tapestry
  2. TAPESTRY-617

get static field fail with use table component, bug report like bug tapestry-408

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.5
    • Fix Version/s: 3.0.5
    • Component/s: Contrib
    • Labels:
      None
    • Environment:
      weblogic+windows2000+jdk1.4.2

      Description

      bug report like bug tapestry-408
      in my table component define
      columns="id.bigClientId:title1:[0].id.bigClientId,
      contractDate:mydate:@com.csair.keyacc.Visit@formatter.format([0].contractDate)"
      it can't access static field !!
      weblogic 8.1.3+windows 2000+eclipse
      /* when weblogic classpath include ognl.jar

      • mywebapp
      • +web-inf
      • +lib ognl.jar;tapestry-3.x.x.jar; tapestry-contrib-3.x.x.jar;
      • */

      //org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator.java

      public Object getColumnValue(ITableColumn objColumn, Object objRow)
      {
      // If no expression is given, then this is dummy column. Return something.
      if (m_strExpression == null || m_strExpression.equals(""))
      return "";

      if (m_objParsedExpression == null)
      {
      synchronized (this)

      { if (m_objParsedExpression == null) m_objParsedExpression = OgnlUtils.getParsedExpression(m_strExpression); }
      }

      try
      { Object objValue = Ognl.getValue(m_objParsedExpression, objRow); return objValue; }
      catch (OgnlException e)
      { LOG.error( "Cannot use column expression '" + m_strExpression + "' in row", e); return ""; }
      }


      patch:
      // org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator.java
      /**
      * @see org.apache.tapestry.contrib.table.model.simple.ITableColumnEvaluator#getColumnValue(ITableColumn, Object)
      */
      public Object getColumnValue(ITableColumn objColumn, Object objRow)
      {
      // If no expression is given, then this is dummy column. Return something.
      if (m_strExpression == null || m_strExpression.equals(""))
      return "";

      if (m_objParsedExpression == null)
      {
      synchronized (this)
      { if (m_objParsedExpression == null) m_objParsedExpression = OgnlUtils.getParsedExpression(m_strExpression); }

      }

      try
      {

      ClassResolver resolver= new ClassResolver(){

      public Class classForName(String className, Map context) throws ClassNotFoundException

      { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); return Class.forName(className, true, contextClassLoader); }

      };
      Map context = Ognl.createDefaultContext(objRow, resolver);

      Object objValue= Ognl.getValue(m_objParsedExpression, context, objRow);

      //Object objValue = Ognl.getValue(m_objParsedExpression, objRow);
      return objValue;
      }
      catch (OgnlException e)

      { System.out.println("ognl exception!!"); e.printStackTrace(); LOG.error( "Cannot use column expression '" + m_strExpression + "' in row", e); return ""; }

      catch(RuntimeException ex)

      { System.out.println("throw Exception OgnlTableColumnEvaluator!!"); ex.printStackTrace(); throw ex; }

      catch(Exception ex)

      { ex.printStackTrace(); throw new RuntimeException(ex); }

      }

      weblogic 8.1.3+windows 2000+eclipse
      /* when weblogic classpath include ognl.jar;tapestry-3.x.x.jar;tapestry-contrib-patch.jar

      • mywebapp
      • +web-inf
      • +lib ognl.jar;tapestry-3.x.x.jar; tapestry-contrib-3.x.x.jar;
      • */

      and run Ok!

        Activity

        Hide
        Brian K. Wallace added a comment -

        Added context class loader parameter to Ognl.getValue call

        Show
        Brian K. Wallace added a comment - Added context class loader parameter to Ognl.getValue call

          People

          • Assignee:
            Brian K. Wallace
            Reporter:
            samwen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development