myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: Best practices for validating an complete object/entity
Date Wed, 16 Nov 2011 16:46:25 GMT
hi thomas,

extval as well as codi allow dependency injection in constraint-validators.
-> you can inject and call e.g. a service or repository or any other bean
to check if a name already exists (see e.g. [1]).

regards,
gerhard

[1]
https://cwiki.apache.org/confluence/display/EXTCDI/BV+Usage#BVUsage-DependencyInjectioninConstraintValidators

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2011/11/16 Thomas Andraschko <zoigln@googlemail.com>
>
> Hi,
>
> i have some input fields for an entity and i want to check if the entered
> name does already exist.
> So i tried to create an BV constraint for the name property but i also
need
> the parent entity object (for checking if the entity is transient or not).
> In a BV validator i can't get the the parent entity - so it's useless.
> The other idea was to attach it on bean property level for the entity:
>
> @UniqueName
> private Entity entity.
>
> <p:inputText value=#{bean.entity.name}" />
>
> But this wont validate the entity.
> I thought about an custom converter and binding the #{bean.entity}.
> The problem is, in getAsObject i must load the entity by the name and the
> bean.entity will be overwritten. Or not?
>
> How can i prevent that the #{bean.entity} will be overwritten?
> Is there another solution for validate the entity?
>
> I also use CODI and ExtVal.
>
> Thanks!
>
> Best regards,
> Thomas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message