Re: Use Spring's LocalValidatorFactoryBean

2010-04-09 Thread Carlos Vara
Just a quick check, in case you are using @SpringBean outside of a Wicket
component, you have to inject it manually
using: InjectorHolder.getInjector().inject(this);

On Fri, Apr 9, 2010 at 5:32 PM, David Chang  wrote:

> I am hoping to use Spring's LocalValidatorFactoryBean and define it in a
> Spring context file as follows:
>
> 
> http://www.springframework.org/schema/beans";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:tx="http://www.springframework.org/schema/tx";
> xmlns:util="http://www.springframework.org/schema/util";
> xmlns:mvc="http://www.springframework.org/schema/mvc";
> xmlns:context="http://www.springframework.org/schema/context";
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd
> http://www.springframework.org/schema/task
> http://www.springframework.org/schema/task/spring-task-3.0.xsd
> http://www.springframework.org/schema/util
> http://www.springframework.org/schema/util/spring-util-3.0.xsd";>
>
>  class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"
> />
>
> 
>
>
> However, Spring-configured validator in code is always null:
>
> @SpringBean
> protected Validator validator;
>
> In the same Spring context file, I defined other DAO beans used by wicket
> components and they are just fine.
>
> Did anyone have success in configuring and using LocalValidatorFactoryBean?
> What did I do is wrong?
>
> I am using Spring 3.0.2, Hibernate Validator 4.0.2, and Wicket 1.4.7.
>
> Thanks for any input!
>
> Best.
>
>
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Any "mature" work on integrating Hibernate Validator with Wicket?

2010-04-06 Thread Carlos Vara
Hi David,

The code may be simple, but the idea/benefits I see may be great. Wouldn't
> be better to make it available on wicketstuff in good shape instead of me or
> others googling it out? :) Just my 2 cents.
>

I totally agree with you here. I find JSR-303 to be a great standard that
addresses the validation problem very well, so having a minimal start point
inside wicket to use it would be a good idea.

Seeing as it is only 2 simple classes, and that the external dependencies
can be reduced to a minimum (just javax-validation-api), I proposed a RFE in
wickets jira: https://issues.apache.org/jira/browse/WICKET-2825 Vote for it
if you like the idea :-)




> Regards,
>
> David
>
>
> --- On Mon, 4/5/10, Carlos Vara  wrote:
>
> > From: Carlos Vara 
> > Subject: Re: Any "mature" work on integrating Hibernate Validator with
> Wicket?
> > To: users@wicket.apache.org
> > Date: Monday, April 5, 2010, 4:52 PM
> > Hi David,
> >
> > I'm the author of the first article that you linked to:
> > http://carinae.net/tag/hibernate-validator/
> >
> > <
> http://carinae.net/2009/12/integration-of-jsr-303-bean-validation-standard-and-wicket-1-4/
> >Basically,
> > you hardly need more than the two provided validators (for
> > property
> > validation on field input, and full bean validation on form
> > input). I added
> > some extra code to integrate it with Spring and to
> > centralize the locale,
> > but if you don't need it, you can easily use only those
> > validators without
> > anything else.
> >
> > The way I see it, there is no code in wicketstuff because
> > it is quite simple
> > to integrate jsr303 and wicket, so picking the code from my
> > or others blog,
> > and maybe tweaking it a little for your needs is probably
> > all you need.
> >
> >
> >
> > On Mon, Apr 5, 2010 at 9:39 PM, Ben Tilford 
> > wrote:
> >
> > > So far this is what I've got. Doesn't do anything with
> > groups or the more
> > > advanced stuff but this may be all it takes.
> > >
> > > public class BeanComponentValidator extends
> > AbstractValidator {
> > >
> > >
> > >public BeanComponentValidator() {
> > >super();
> > >}
> > >
> > >
> > >@Override
> > >protected void
> > onValidate(IValidatable validatable) {
> > >
> > for(ConstraintViolation violation :
> > > validate(validatable.getValue())) {
> > >
> > validatable.error(new
> > >
> > ValidationError().addMessageKey(violation.getMessage()));
> > >}
> > >
> > >}
> > >
> > >Set>
> > validate(T value) {
> > >Validator validator =
> > >
> > >
> > Validation.buildDefaultValidatorFactory().getValidator();//this
> > may only
> > > be
> > > working because I'm using Spring 3.0.2 and Hibernate
> > 3.5 I don't know for
> > > sure.
> > >return
> > validator.validate(value);
> > >}
> > > }
> > >
> > >
> > > On Mon, Apr 5, 2010 at 12:15 PM, Martin Makundi <
> > > martin.maku...@koodaripalvelut.com>
> > wrote:
> > >
> > > > Hi!
> > > >
> > > > It's quite easy to add trivial min/max/required
> > validators using (any)
> > > > helper method. Maybe bindgen project would be
> > closest to this.. it's
> > > > already working with annotations, it could
> > perhaps parse also
> > > > annotations of property target objects.
> > > >
> > > > **
> > > > Martin
> > > >
> > > > 2010/4/5 David Chang :
> > > > > Using Hibernate Validator may bring a few
> > good things:
> > > > >
> > > > > 1. On the data end, it helps to improve
> > data, performance, etc. Also
> > > the
> > > > annotation you write on domain objects get
> > translated into database
> > > creation
> > > > and objects save/update. You can find more on in
> > this area. Obviously,
> > > this
> > > > has nothing to do with wicket.
> > > > >
> > > > > 2. Regarding the web tier, it is often
> > needed to write validation rules
> > > > such as not null or the maximum chars in an input
> > field being less than
> > > 10.
> > > > In pure wicket, you have to add 

Re: Any "mature" work on integrating Hibernate Validator with Wicket?

2010-04-05 Thread Carlos Vara
Hi David,

I'm the author of the first article that you linked to:
http://carinae.net/tag/hibernate-validator/

Basically,
you hardly need more than the two provided validators (for property
validation on field input, and full bean validation on form input). I added
some extra code to integrate it with Spring and to centralize the locale,
but if you don't need it, you can easily use only those validators without
anything else.

The way I see it, there is no code in wicketstuff because it is quite simple
to integrate jsr303 and wicket, so picking the code from my or others blog,
and maybe tweaking it a little for your needs is probably all you need.



On Mon, Apr 5, 2010 at 9:39 PM, Ben Tilford  wrote:

> So far this is what I've got. Doesn't do anything with groups or the more
> advanced stuff but this may be all it takes.
>
> public class BeanComponentValidator extends AbstractValidator {
>
>
>public BeanComponentValidator() {
>super();
>}
>
>
>@Override
>protected void onValidate(IValidatable validatable) {
>for(ConstraintViolation violation :
> validate(validatable.getValue())) {
>validatable.error(new
> ValidationError().addMessageKey(violation.getMessage()));
>}
>
>}
>
>Set> validate(T value) {
>Validator validator =
>
>  Validation.buildDefaultValidatorFactory().getValidator();//this may only
> be
> working because I'm using Spring 3.0.2 and Hibernate 3.5 I don't know for
> sure.
>return validator.validate(value);
>}
> }
>
>
> On Mon, Apr 5, 2010 at 12:15 PM, Martin Makundi <
> martin.maku...@koodaripalvelut.com> wrote:
>
> > Hi!
> >
> > It's quite easy to add trivial min/max/required validators using (any)
> > helper method. Maybe bindgen project would be closest to this.. it's
> > already working with annotations, it could perhaps parse also
> > annotations of property target objects.
> >
> > **
> > Martin
> >
> > 2010/4/5 David Chang :
> > > Using Hibernate Validator may bring a few good things:
> > >
> > > 1. On the data end, it helps to improve data, performance, etc. Also
> the
> > annotation you write on domain objects get translated into database
> creation
> > and objects save/update. You can find more on in this area. Obviously,
> this
> > has nothing to do with wicket.
> > >
> > > 2. Regarding the web tier, it is often needed to write validation rules
> > such as not null or the maximum chars in an input field being less than
> 10.
> > In pure wicket, you have to add many validation rules yourself manually
> for
> > each field. Why should I do so second time in wicket if I can explicitly
> > specify them on domain objects via Hibernate Validator (or Bean
> Validation,
> > JSR 303, now official)? I hope to see wicket can take adavantage of bean
> > validation to let us code faster and have more maintainable code.
> > >
> > > Please feel free to comment I am wrong.
> > >
> > > Best.
> > >
> > >
> > >
> > >
> > >
> > > --- On Mon, 4/5/10, Martin Makundi  >
> > wrote:
> > >
> > >> From: Martin Makundi 
> > >> Subject: Re: Any "mature" work on integrating Hibernate Validator with
> > Wicket?
> > >> To: users@wicket.apache.org
> > >> Date: Monday, April 5, 2010, 11:31 AM
> > >> Do you have any user stories on the
> > >> topic? It would be useful to
> > >> evaluate how interesting the use case is. Me myself I
> > >> cannot immagine
> > >> anything "useful" could come out of hibernate validators,
> > >> only
> > >> something very trivial. Could be wrong, thoug.
> > >>
> > >> **
> > >> Martin
> > >>
> > >> 2010/4/5 David Chang :
> > >> >
> > >> > thanks for chiming in. sorry if i was not clear in
> > >> prevoius posts.
> > >> >
> > >> > i would like to hear comments whether it is worthy to
> > >> explore or any benefits. i also would like to know whether
> > >> there is more "mature" work since i only found experimental
> > >> work. i am unable to find anything aobut it on wicketstuff.
> > >> >
> > >> > regards.
> > >> >
> > >> >
> > >> > --- On Mon, 4/5/10, Igor Vaynberg 
> > >> wrote:
> > >> >
> > >> >> From: Igor Vaynberg 
> > >> >> Subject: Re: Any "mature" work on integrating
> > >> Hibernate Validator with Wicket?
> > >> >> To: users@wicket.apache.org
> > >> >> Date: Monday, April 5, 2010, 11:21 AM
> > >> >> you have answered your own question
> > >> >> twice, why does anyone else need to reply?
> > >> >>
> > >> >> -igor
> > >> >>
> > >> >> On Mon, Apr 5, 2010 at 8:01 AM, David Chang <
> david_q_zh...@yahoo.com
> > >
> > >> >> wrote:
> > >> >> >
> > >> >> > Hi folks, I feel a bit puzzled about not
> > >> getting any
> > >> >> response on this topic. I have to say that I am
> > >> new in
> > >> >> Wicket. If this a bad or wrong question or if this
> > >> is
> > >> >> something not worthy to explore, please feel free
> > >> to let me
> > >> >> know.
> > >> >> >
> > >> >> > Thanks for any input!
> > >> >> >
> > >> >> >
> > >>

Re: (my code palette) how to set default options in object palette

2010-01-31 Thread Carlos Vara
Hi Victor,

a quickstart is a wicket project using this maven archetype:

http://wicket.apache.org/quickstart.html


On Sun, Jan 31, 2010 at 7:46 PM, victorTrapiello wrote:

>
> Thank you very mucv Nino, but what do you mena by a quick start¿? I´m new
> in
> this comunity.
>
> nino martinez wael wrote:
> >
> > Ok Victor next step for you would be to create a quickstart.. So we can
> > play
> > with it.. I've sure had this working with wicket 1.2 / 1.3 soo should
> > still
> > be the case.
> >
> > 2010/1/29 victorTrapiello 
> >
> >>
> >> I does not work, I think the key point is my
> >>
> >> IChoiceRenderer renderer = new ChoiceRenderer("fullName", "fullName");
> >>
> >> i leave it empty and it works for the available subject but not for the
> >> predefined!
> >>
> >> any more thoughts¿?
> >>
> >> Thank you very much guys
> >>
> >>
> >>
> >> nino martinez wael wrote:
> >> >
> >> > Form f=new Form("form");
> >> > add(f);
> >> > List persons = ComponentReferenceApplication.getPersons();;
> >> > IChoiceRenderer renderer = new ChoiceRenderer("fullName",
> >> "fullName");
> >> > final Palette palette = new Palette("palette", new
> >> > ListModel(new
> >> > ArrayList()), new CollectionModel(
> >> >   persons), renderer, 10, true);
> >> > palette.setmodelObject or something like that.
> >> >
> >> > 2010/1/29 victorTrapiello 
> >> >
> >> >>
> >> >> well I have defined my palette component like this:
> >> >>
> >> >> asignString is an string linst with the available subjects (It works
> >> >> fine,
> >> >> the palette shows the proper subjects, but it doesn´t show the
> default
> >> >> selected one which I save them in the list "lSelected"
> >> >>
> >> >>  IChoiceRenderer renderer = new ChoiceRenderer("", "");
> >> >>  List lSelected=new ArrayList();
> >> >>lSelected.add("predefined");
> >> >>Model aux=new Model();
> >> >>aux.setObject((Serializable) lSelected);
> >> >>
> >> >>final Palette palette = new Palette("palette", aux, new Model(
> >> >>(Serializable) asignString), renderer, 10, true);
> >> >>
> >> >> Any thought¿?
> >> >>
> >> >> thankyou in advance
> >> >>
> >> >>
> >> >> James Carman-3 wrote:
> >> >> >
> >> >> > Make sure your model reflects the selected state.  Palette will
> pick
> >> >> > that up automatically
> >> >> >
> >> >> > On Sat, Jan 23, 2010 at 12:50 PM, victorTrapiello
> >> >> 
> >> >> > wrote:
> >> >> >>
> >> >> >>
> >> >> >> I use the palette component, to assigne option to a User. but I
> >> don't
> >> >> >> find a functionnality, how to set already selected option ?.
> >> >> >>
> >> >> >> Exemple : a user selected option, I store it into a database:
> >> >> >> In the future, the user want to update his option, at the moment
> he
> >> >> >> doesn't see his previous selected option.
> >> >> >>
> >> >> >>  Do you have a solution.¿?, doe sir make sense¿?
> >> >> >>
> >> >> >> cheers!!
> >> >> >>
> >> >> >> quote author="MartinM">
> >> >> >> Well.. you can override newChoicesComponent
> >> >> >>
> >> >> >> **
> >> >> >> Martin
> >> >> >>
> >> >> >> 2009/4/28 新希望软件 -- 俞宏伟 :
> >> >> >>> yes, i can setMarkupId for Palette. but now i want to filter for
> >> >> >>> palette's
> >> >> >>> choicesComponent.
> >> >> >>>
> >> >> >>> there is no public getChoicesComponent() method for
> >> choicesComponent.
> >> >> >>>
> >> >> >>>
> >> >> >>>
> >> >> >>> 2009/4/28 Martin Makundi 
> >> >> >>>
> >> >>  Why cannot get markupid? You can determine it yourself
> >> (setMarkupId)
> >> >> 
> >> >>  You could also update via ajax using a textfield which sends the
> >> >>  filtered text to server and server updates the select via
> ajax...
> >> >> 
> >> >>  I wonder if someone has made a select in which the filter is
> >> >> visually
> >> >>  built into the select component?
> >> >> 
> >> >>  **
> >> >>  Martin
> >> >> 
> >> >>  2009/4/28 新希望软件 -- 俞宏伟 :
> >> >>  > I want to add a filter for palette choice list, because
>  choice
> >> >> list
> >> >>   have a
> >> >>  > very large HTML SELECT list.
> >> >>  >
> >> >>  > I found that there is a select filter implement(
> >> >>  > http://www.barelyfitz.com/projects/filterlist/index.php/1),
> but
> >> i
> >> >> can
> >> >>  not
> >> >>  > get select component markupid, so filter can not init.
> >> >>  >
> >> >>  > --
> >> >>  >
> >> >>  > H. L. Mencken <
> >> >>  http://www.brainyquote.com/quotes/authors/h/h_l_mencken.html>
> >> >>  > - "It is even harder for the average ape to believe that he
> has
> >> >>  > descended
> >> >>  > from man."
> >> >>  >
> >> >> 
> >> >> 
> >> >> -
> >> >>  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> >>  For additional commands, e-mail: users-h...@wicket.apache.org
> >> >> 
> >> >> 
> >> >> >>>
> >> >> >>
> >> >> >>
> >> 

Re: Integrating Hibernate Validator with Wicket

2010-01-04 Thread Carlos Vara
Hi,

if you prefer to use JSR 303 Bean Validation (it's very similar to Hibernate
Validator, in fact, it is the reference implementation), I made a blog post
about how to integrate it with Wicket:

http://carinae.net/2009/12/integration-of-jsr-303-bean-validation-standard-and-wicket-1-4/


On Mon, Jan 4, 2010 at 11:28 AM, ayman elwany  wrote:

> thanks Martin for the link , I used it but I had a problem;
>
>
> public class CarPage extends WebPage {
>
> *   ..*
> *   ..*
>UserModel user=  ((LoginSession)getSession()).getUserBean();
>  *  ..*
> *..*
> *   ..*
> private void fillPersonalInfoComponents(Form personalForm) {
>  *   ..*
>  *   ..   *
>PropertyModel fullnamepropertyModel =new
> PropertyModel(user, "fullNameValue");
> fullName = new TextField("fullName", fullnamepropertyModel);
>  personalForm.add(fullName);
> //System.out.println("Model =
> "+fullnamepropertyModel.getChainedModel().getClass().getName());
> fullName.add(new HibernateValidator(fullnamepropertyModel,
> "fullNameValue"));
>
>  }
> }
>
>
>
> And the user model is
>
> public class UserModel implements Serializable {
>
> /**
>  *
>  */
> private static final long serialVersionUID = 1011452297289823651L;
>*   ..*
> *   ..*
> *   ..*
>
> @NotNull
> @NotEmpty
> private String fullNameValue;
>*   ..*
> *   ..*
> *   ..*
> }
>
>
> but it always fails and gives me that my model is null .  but the strange
> behaviour that when I changed  HibernateValidator constructor
>
> *from*
>
> public HibernateValidator(I*Model entityModel*, String property) {
> this.property = property;
> if (entityModel != null)
> hibernateValidator = new
> ClassValidator(*entityModel.getObject().getClass()*
> );
> }
>
>
> *TO*
> public HibernateValidator(*Object bean, *String property) {
> this.property = property;
> //if (entityModel != null)
> hibernateValidator = new ClassValidator(*bean.getClass()*);
> }
>
> and did this
>
> fullName.add(new HibernateValidator(user, "fullNameValue"));
>
> the validation worked *fine *!!!
>
> so is there is any problem in the propertymodel with hibernate validator???
>
> On Mon, Jan 4, 2010 at 8:37 AM, Martin Makundi <
> martin.maku...@koodaripalvelut.com> wrote:
>
> > http://42lines.net/content/integrating-hibernate-validator-and-wicket
> >
> > 2010/1/4 ayman elwany :
> > > Hi,
> > >
> > > Is there any common practice to integrate wicket with hibernate
> validator
> > ?
> > >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>