Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-1214

Alternate EL property reference #{entity[fieldName]} doesn't work

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 1.2.1.GA
    • Fix Version/s: 1.3.0.ALPHA
    • Component/s: Core
    • Labels:
      None

      Description

      Validation fails for inputText fields where the value expression is of the form: #

      {entity[fieldName]}

      The problem is in Expressions.java, in the validate() method:

         public InvalidValue[] validate(String propertyExpression, Object value)
         {
            int dot = propertyExpression.lastIndexOf('.');
            int bracket = propertyExpression.lastIndexOf('[');
            if (dot<=0 && bracket<=0) 
            {
               return new InvalidValue[0];
            }
            String componentName;
            String propertyName;
            if (dot>bracket)
            {
               componentName = propertyExpression.substring(2, dot);
               propertyName = propertyExpression.substring( dot+1, propertyExpression.length()-1 );
            }
            else
            {
               componentName = propertyExpression.substring(2, bracket);
               propertyName = propertyExpression.substring( bracket+1, propertyExpression.length()-2 );
            }
            String modelExpression = propertyExpression.substring(0, dot) + '}';
            
            Object modelInstance = createValueBinding(modelExpression).getValue(); //TODO: cache the ValueBinding object!
            return getValidator(modelInstance, componentName).getPotentialInvalidValues(propertyName, value);
         }
      

      This line is the problem:
      String modelExpression = propertyExpression.substring(0, dot) + '}';

      if a dot is not found, 'dot' is -1... boom!

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                pmuir Pete Muir
                Reporter:
                pgmjsd Joshua Davis
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: