GWT JSR 303 and setConstraintViolations() wrong Path name bug ?

56 views
Skip to first unread message

Daniel Mauricio Patino León

unread,
Nov 12, 2012, 10:26:45 PM11/12/12
to google-we...@googlegroups.com
Hello there today i am almost finish with a medium complex EntityProxy editor module.

But now seems that i found a new hole or don't know why this happens.

This the proxy scenario:

in ProductoProxy i have:

    @Valid
    public ImpuestoProxy getImpuesto();
    @Valid
    public ImpuestoProxy getIeps();

whose are @Embedded pojos.

Then on the ImpuestoProxy i have properties that need be validated differently when it is Impuesto or Ieps so i created a ImpuestoGroup and ImpuestoIepsTasaGroup marker interfaces to validate differently using the same Editor (see below why):

    @NotNull(message="notNull", groups = {ImpuestoGroup.class, ImpuestoIepsTasaGroup.class}) /*so be validated when it;s Impuesto or Ieps */
    @DecimalMin(value="0.0", message="decimalMin:0.0", groups = {ImpuestoGroup.class, ImpuestoIepsMontoGroup.class})
    public Double getTasaImpuesto();

    @NotNull(message="notNull", groups = {ImpuestoIepsMontoGroup.class}) /* so be validated when it's type is Impuesto only */
    @DecimalMin(value="0.0", message="decimalMin:0.0", groups = {ImpuestoIepsMontoGroup.class})
    public BigDecimal getMontoImpuesto();

    ...

Plus i need let user choose predefined valueproxy so i used a:

public class UiOptionalValueListBoxImpl<T, E extends Editor<T>> extends UiBaseBox implements IsEditor<OptionalFieldEditor<T, E>>{
   ...
}

So when the user edits a getImpuesto() and then want to save it i check for constraints  in this manner:

   driver.flush();
               
   ImpuestoProxy proxy = productoProxy.getIeps();

   /* Here i cannot validate the whole ProductoProxy because some constraints fails due my custom groups.
   *  so i need validate only the @Embedded proxy
   */              
   Set constraints = AddProductViewImpl.this.validator.validate(proxy, proxy.getTipoIeps().equals(TipoIeps.MONTO) ? ImpuestoIepsMontoGroup.class : ImpuestoIepsTasaGroup.class);
                                           
   if(!constraints.isEmpty()){
      driver.setConstraintViolations(constraints);
   }
               
   logger.log(Level.INFO, "After the flush we got "+driver.getErrors().size());

In my Editor of ImpuestoProxy view i have my own validation ui framework (user ui messages, etc ...) and to identify a property who us failing i use their path then i compare with the path reported by List<EditorError> reported by the main driver.

The problem becomes here. The next behavior happens:

IsEditor<ValueBoxEditor<T>> report path ok
foo.bar.client.view.Products.ImpuestoEditorImpl INFO: On the sub view we got: ieps.unidadImpuesto notNull

but IsEditor<TakesValueEditor<T>> and IsEditor<LeafValueEditor<T>> don't

foo.bar.client.view.Products.ImpuestoEditorImpl INFO: On the sub view we got: iepstipoIeps notNull

foo.bar.client.view.Products.ImpuestoEditorImpl INFO: On the sub view we got: iepsnombreImpuesto notNull

As you can see there is missing . on the path name. ( iepsnombreImpuesto should be ieps.nombreImpuesto )

Plase note if i validate the whole ProductoProxy  the paths are reported fine

Don't know it the conversion from driver.setConstraintViolations(constraints); to List<EditorError> fails or it's the validation who reports badly the path. Will try atm.

Please help me.

Thanks.

Daniel Mauricio Patino León

unread,
Nov 12, 2012, 10:34:57 PM11/12/12
to google-we...@googlegroups.com
I just confirm that seems to be a bug ? on the conversion of

driver.setConstraintViolations(constraints) to List<EditorError> in the Editor framework

the jsr 303 reports like this:


Mon Nov 12 21:29:55 GMT-600 2012 foo.bar.client.view.BaseViewImpl INFO: tipoIeps

Mon Nov 12 21:29:55 GMT-600 2012 foo.bar.client.view.BaseViewImpl INFO: unidadImpuesto

Just to complement the information i have my subeditors in this manner in my Top editor :

public class AddProductViewImpl extends BaseViewImpl implements AddProductView, Editor<ProductoProxy>{

@UiField(provided=true)
UiOptionalValueListBoxImpl<ImpuestoProxy,ImpuestoEditorImpl> impuesto = new UiOptionalValueListBoxImpl<ImpuestoProxy,ImpuestoEditorImpl>(new Renderer<ImpuestoProxy>() {

@Override
public String render(ImpuestoProxy object) {
return object != null ? (object.getNombreImpuesto() != null ? object.getNombreImpuesto() : "n/d") : "Seleccione un impuesto";
}

@Override
public void render(ImpuestoProxy object, Appendable appendable) throws IOException {
render(object);
}
}, new ImpuestoEditorImpl(true));
...

}

public class UiOptionalValueListBoxImpl<T, E extends Editor<T>> extends UiBaseBox implements IsEditor<OptionalFieldEditor<T, E>> {
...
}


Thank you.


Reply all
Reply to author
Forward
0 new messages