Daniel Mauricio Patino León
unread,Nov 12, 2012, 10:26:45 PM11/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.