[
http://opensource.atlassian.com/projects/hibernate/browse/HV-39?page=com....
]
Jorelia ANDRE commented on HV-39:
---------------------------------
Hello,
I think it is a bug in Jboss Seam Core, function :
- public InvalidValue[] validate(String propertyExpression, Object value)
from package
- package org.jboss.seam.core
at:
if (dot>bracket)
{
componentName = propertyExpression.substring(2, dot);
propertyName = propertyExpression.substring( dot+1, propertyExpression.length()-1
);
}
else
{
componentName = propertyExpression.substring(2, bracket);
>>>>>>>>>>>>>> HERE .....
propertyName = propertyExpression.substring( bracket+1,
propertyExpression.length()-2 );
}
Validator class does not retrieve the property name on array - The
property name is the index of array !?
---------------------------------------------------------------------------------------------------------
Key: HV-39
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-39
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 3.0.0.ga
Environment: Unix and Windows with RAD 7 (websphere) - JAVA 5.0 - JSF + JBoss
Seam 1.2.1, facelet v1.1.12.
Reporter: Jorelia ANDRE
Attachments: validator-bugArray-2.PNG, validator-bugArray.PNG
Bonjour Emmanuel,
I've created a custom validator by using hibernate validator framework. So, I've
put the new annotation on array of string (myString[] = new String[10]). Then I've
used <s:validateAll> from JBoss Seam to validate the backing bean but unfortunately
the isValid() method is never called. The reason is that the ClassValidator.java cannot
retrieve properly the property name. Instead of, the property name is the index of the
element !!!
Here is the case sample:
====================
The XHTML PAGE:
-------------------------
<!-- -->
<!-- 10 PRODUCTS -->
<!-- -->
<div class="colonneData">
<h:inputText id="numProduit1" value="#{myBean.product[0]}"
/>
</div>
<div class="colonneData">
<h:inputText id="numProduit1" value="#{myBean.product[1]}"
/>
</div>
<div class="colonneData">
<h:inputText id="numProduit1" value="#{myBean.product[2]}"
/>
</div>
etc.....
The BEAN PAGE:
-------------------------
@Name("myBean")
@Scope(CONVERSATION)
@AutoCreate
public class myBean extends ControleurPresentation {
@CheckProductNumber
private String[] product= new String[10];
}
The VALIDATOR
-------------------------
public class CheckProductNumberValidator implements Validator<CheckProductNumber>
{
public boolean isValid(Object value) {
/* your validation code */
return true;
}
}
UNDER THE DEBUGGER
=====================
Hibernate code:
============
/**
* Apply constraints of a particular property value of a bean type and return all the
failures.
* The InvalidValue objects returns return null for InvalidValue#getBean() and
InvalidValue#getRootBean()
* Note this is not recursive.
*/
//TODO should it be recursive?
public InvalidValue[] getPotentialInvalidValues(String propertyName, Object value) {
List<InvalidValue> results = new ArrayList<InvalidValue>();
for ( int i = 0; i < memberValidators.size() ; i++ ) {
XMember getter = memberGetters.get( i );
if ( getPropertyName( getter ).equals( propertyName ) ) {
Validator validator = memberValidators.get( i );
if ( !validator.isValid( value ) ) {
results.add( new InvalidValue( interpolate(validator), beanClass, propertyName,
value, null ) );
}
}
}
return results.toArray( new InvalidValue[results.size()] );
}
>>>>>>>>>>> So, the parameter propertyName has the
value of "0" !!!!! and the test if ( getPropertyName( getter ).equals(
propertyName ) ) failed because there is no getter for "0" !!!! of course.
The valueBinding of the UIComponent is :
/pages/materielPromo/rechercheMultiCriteres.xhtml @70,203
value="#{myBean.product[0]}"
Probably that the bug is in extracting the property.
Please could you confirm the bug ASAP and give any workaround.
Thank you very much.
NOTE: (I'm pretty sure that somebody I've already requested that...)
=====
1) @Valid should work for array of string String[] - Most of validator should work with
array of String and Integer
2) Validators should implement setter and getter to be able to reuse them in the case to
build our own validator by calling yours.
3) More Javadoc on validator class will help and good for the community.
Thank you in advance.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira