[ 
https://issues.apache.org/jira/browse/TAP5-2101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13637884#comment-13637884
 ] 

Alejandro Scandroli commented on TAP5-2101:
-------------------------------------------


I'm trying to leverage this to create an edit block for @Embedded properties 
(http://jira.codehaus.org/browse/TYNAMO-22).

One issue I found is that BeanEditContext and BeanValidationContext get out of 
sync on submit. When working with nested BeanEditors they return different 
classes, that is:
BeanEditContext.getBeanClass() != BeanValidationContext.getBeanType()

The issue is that the BeanEditContext anonymous inner class is "delegating" the 
call to the BeanEditor's model on the fly and the model changes. This could be 
easily solved by creating a BeanEditContextImpl that takes a Class in its 
constructor.

One other thing, I've also noticed that the Environment ends up with more 
BeanValidationContext in the stack than it should. If I'm not mistaken the 
stack should end up completely empty after the request. If that's the case, I 
think that the _originalBeanValidationContext_ push in 
BeanEditor.cleanupEnvironment() it's unnecessary. After all it is a stack so 
the previous BeanValidationContext is still there. 




                
> BeanEditor should always provide a new BeanValidationContext (JSR-303)
> ----------------------------------------------------------------------
>
>                 Key: TAP5-2101
>                 URL: https://issues.apache.org/jira/browse/TAP5-2101
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-beanvalidator
>            Reporter: Luca Menegus
>            Assignee: Kalle Korhonen
>             Fix For: 5.3.7, 5.4
>
>         Attachments: beaneditor-jsr303.patch
>
>
> We found that the current BeanEditor implementation:
> * fails to beanvalidate (JSR-303) complex beans (beans that contain other 
> beans)
> * fails to validate more than one bean in the same page (when more than one 
> BeanEditor is present in teh page)
> The problem is that  BeanEditor doesn't provide the correct 
> BeanValidationContext to the validation framework.
> Given the following beans:
> public class ComplexBean {
>     private SomeSimpleBean someSimpleBean;
>    @NotNull private String simpleNotNullProperty;
>     ...
> }
> public class SimpleBean {
>     @Min(6) private int minValue;
>  ..
> }
> One would expect that the following page would validate all the constraint 
> from both ComplexBean and SimpleBean:
> <t:form validate="complexBean">
>               <t:BeanEditor object="complexBean" />
>               <t:BeanEditor object="complexBean.someSimpleBean" />
> ...
> Instead only ComplexBean.simpleNotNullProperty constraint is validated.
> Moreover not even:
> <t:form validate="this"> 
> <t:BeanEditor object="beanA" /> 
> <t:BeanEditor object=" beanB " /> 
> <t:form/> 
> Is (bean)validating properly....
> BeanEditor should provide the validation framework with a new 
> BeanValidationContext bound to the object being validated all the times.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to