[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1214) Alternate EL property reference #{entity[fieldName]} doesn't work

C B (JIRA) jira-events at lists.jboss.org
Thu Jun 21 05:19:56 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-1214?page=comments#action_12366280 ] 
            
C B commented on JBSEAM-1214:
-----------------------------

For me, this still doe not work in seam 1.3.0.ALPHA!

Everything works smoothly as long as the data entered is valid.
But if I enter invalid data, a hibernate validation exception is shown on a seam debug page instead of the form being rendered again with error message decorations. The effect is the same as if I had omitted the <s:validate/> (resp. <s:validateAll>) tags.

The problem not only shows up in conjunction with #{entity[fieldName]} but also when you use a variable that has been assigned with the JSTL <c:set> tag before as shown in the snippet below.

{code} 
<c:set var="field" value="#{fooHome.instance.name}" />
			
<s:decorate id="nameDecoration">
	<div class="prop">
		<s:label ...</s:label>
		
		<span class="value #{invalid?'errors':''}">
			<s:validateAll>
				<h:inputText id="name" required="true"
					value="#{field}"/>
			</s:validateAll>
		</span>
		
		<s:message styleClass="error errors"/>
	</div>
</s:decorate>
{code} 

the exception:
Exception during request processing:
Caused by javax.servlet.ServletException with message: "#{fooHome.persist}: org.hibernate.validator.InvalidStateException: validation failed for: ch.XXXXXX.ttrack.Foo"

> Alternate EL property reference #{entity[fieldName]} doesn't work
> -----------------------------------------------------------------
>
>                 Key: JBSEAM-1214
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1214
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.2.1.GA
>            Reporter: Joshua Davis
>         Assigned To: Pete Muir
>            Priority: Minor
>             Fix For: 1.3.0.ALPHA
>
>
> 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:
> {code}
>    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);
>    }
> {code}
> This line is the problem:
>       String modelExpression = propertyExpression.substring(0, dot) + '}';
> if a dot is not found, 'dot' is -1... boom!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list