You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Musachy Barroso <mu...@gmail.com> on 2007/04/22 02:18:24 UTC

PROPOSAL: S2 ajax validation

I'd like to propose a change on the way we do ajax validation. Instead of
using DWR which requires an external dependency and configuring a servlet,
I'd like to have an interceptor in the dojo plugin that extends the
validator interceptor, which outputs JSON with the messages when there are
validation errors.

To use ajax validation all a user would have to do is add the interceptor to
his/her class and set "validate" to "true" in either the form, or the
submit/anchor that is submitting the form.

regards
musachy
-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
Given that DWR integration is broken anyway, and the ajax validation had
mixed content of 2.1 already, I started to draft the documentation for it
here (DWR was there before):

http://cwiki.apache.org/confluence/display/WW/AJAX+Validation

//editing help more than welcomed :)
musachy

On 4/29/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> One of the things I want to do is update the documentation for all the
> ajax tags, so we don't have that super-page with everything on it :). I
> think Don told me once that the wiki could be branched with the code. If the
> boxes are the only way I will just wait until we start building 2.1 to
> avoid more confusion. Ted, any idea when you will be able(assuming you will
> be able) to roll 2.0.8 out?
>
> musachy
>
> On 4/29/07, Dave Newton < newton.dave@yahoo.com> wrote:
> >
> > --- Musachy Barroso < musachy@gmail.com> wrote:
> > > is there anyway I can update the docs (wiki)
> > > without affecting 2.0.8 documentation?
> >
> > AFAIK this is handled w/ version notations in colorful
> > boxes so it'll stand out :/ I don't know if there is a
> > [reasonable] way to support a 2.0 vs. 2.1 docs on a
> > higher level--it'd be Really Nice, though.
> >
> > d.
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
One of the things I want to do is update the documentation for all the ajax
tags, so we don't have that super-page with everything on it :). I think Don
told me once that the wiki could be branched with the code. If the boxes are
the only way I will just wait until we start building 2.1 to avoid more
confusion. Ted, any idea when you will be able(assuming you will be able) to
roll 2.0.8 out?

musachy

On 4/29/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- Musachy Barroso <mu...@gmail.com> wrote:
> > is there anyway I can update the docs (wiki)
> > without affecting 2.0.8 documentation?
>
> AFAIK this is handled w/ version notations in colorful
> boxes so it'll stand out :/ I don't know if there is a
> [reasonable] way to support a 2.0 vs. 2.1 docs on a
> higher level--it'd be Really Nice, though.
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Dave Newton <ne...@yahoo.com>.
--- Musachy Barroso <mu...@gmail.com> wrote:
> is there anyway I can update the docs (wiki)
> without affecting 2.0.8 documentation?

AFAIK this is handled w/ version notations in colorful
boxes so it'll stand out :/ I don't know if there is a
[reasonable] way to support a 2.0 vs. 2.1 docs on a
higher level--it'd be Really Nice, though.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
Just to follow up on this, everything is in trunk. This is how it works:

Actions with the "jsonValidation" interceptor applied, will return something
like:

/* {
        "errors": ["Action error"],
        "fieldErrors": {
           "name": ["Name is required", "Something else"]
        }
    } */

if validation fails. If validation succeeds, action will return regular
output. If the there is a request parameter, "validateOnly" the action won't
be executed, even if validation succeeds, in which case this will be
returned:

/* {} */

The interceptor has a "validationFailedStatus" which will be used as the
request status, if validation fails (not used by default).

The submit, anchor, and bind tags have a new attribute "ajaxAfterValidation"
(false by default), which if set to true, an ajax request will be made, if
validation succeeds. So now if you are using the ajaxtags to make ajax
requests, ajax validation can be used by setting this attribute to true.

The ajax validation example in showcase is updated with 2 examples, one
using regular submit after validation and another using ajax request after
validation. Feedback is appreciated :)

musachy
//is there anyway I can update the docs(wiki) without affecting
2.0.8documentation?


On 4/23/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> That would be the function I mentioned before. With that in mind, I think
> it would be better to have the interceptor and the generic function in core,
> so it can be used with other js libraries. I was going to put it in the Dojo
> plugin as we are moving all the ajax stuff there, but it isn't specific to
> Dojo in any way.
>
> musachy
>
> On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
> >
> > Excellent. Well, then really all that is lacking is a generic JS script
> > to handle the response and add errors to the form/labels/some div. It
> > would be excellent to have a JS plugin model where developers can select
> > the JS framework they want to use and then they can plugin to the Struts
> > handling via a little bit of JS glue.
> >
> > -bp
> >
> >
> > Musachy Barroso wrote:
> > > Thanks for the code. Mine is very similar with some JSON encoding
> > > added. The
> > > resulting JSON is a little bit different:
> > >
> > > /*
> > > {
> > >   "errors": [
> > >       "Error0", "Error1"
> > >   ],
> > >   "fieldErrors": {
> > >       "field1" : ["Error0", "Error1"],
> > >       "field2": ["Error0", "Error1"],
> > >   }
> > > }
> > > */
> > >
> > > musachy
> > >
> > > On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
> > >>
> > >> I've also done this exercise twice in the past and both times I used
> > >> other JS libraries including prototype. My first solution was
> > >> specifically for WebWork and I don't recall any changes I had to make
> > >> when moving it over to Struts2.
> > >>
> > >> Perhaps it makes sense to ensure that this will be completely
> > pluggable
> > >> since many folks are using other JS libraries. My solution only
> > requires
> > >> a form post that is the same or a partial version of the post that
> > would
> > >> normally be submitted. This allows me to use pretty much any library
> > >> that can handle form submission.
> > >>
> > >> I've included my latest interceptor for you guys to look over. Let me
> > >> know what you think. I was planning on making a Struts2 plugin that
> > had
> > >> this and the necessary JavaScript files and template to work with
> > >> Prototype once I had finished it off. But if you are heading in that
> > >> direction, we should collaborate on it.
> > >>
> > >> -bp
> > >>
> > >>
> > >> Musachy Barroso wrote:
> > >> > This would be for 2.1, and it would be in Bind.js. It is actually
> > only
> > >> > one
> > >> > function, which will be calling the functions in
> > >> > validation.js(addError/clearErrors...). I'm planning to do some
> > >> > cleanup after that as we
> > >> > have some javascript/css files hanging around, which are not used.
> > >> >
> > >> > musachy
> > >> >
> > >> > On 4/23/07, Ian Roughley <ia...@fdar.com> wrote:
> > >> >>
> > >> >> Is the Ajax code all in a module now ( 2.1.x)?  Would this change
> > be
> > >> >> checked into the 2.0.x branch or just the trunk under the Ajax
> > >> module,
> > >> >> and then some cleanup/removal of existing code in the trunk?
> > >> >>
> > >> >> /Ian
> > >> >>
> > >> >> Musachy Barroso wrote:
> > >> >> > I have this working, but I want to give  it a little more time
> > to
> > >> >> > anyone to
> > >> >> > object before committing it :), just to review, these are the
> > >> >> different
> > >> >> > validation options:
> > >> >> >
> > >> >> > 1. regular form, regular submit button  (normal validation)
> > >> >> > 2. css_html form, or xhtml form (validate="true"), regular
> > submit
> > >> >> button
> > >> >> > (client validation)
> > >> >> > 3. css_html form, or xhtml form (validate="true"), ajax submit
> > >> button
> > >> >> > (client validation)
> > >> >> > 4. regular form, css_html form, or xhtml form, where action has
> > the
> > >> >> > "ajaxValidation" interceptor, ajax submit button
> > (validate="true")
> > >> >> (ajax
> > >> >> > validation = dojo+interceptor, no DWR)
> > >> >> >
> > >> >> > regards
> > >> >> > musachy
> > >> >> >
> > >> >> > On 4/21/07, Musachy Barroso < musachy@gmail.com> wrote:
> > >> >> >>
> > >> >> >> I'd like to propose a change on the way we do ajax validation.
> > >> >> >> Instead of
> > >> >> >> using DWR which requires an external dependency and configuring
> > a
> > >> >> >> servlet,
> > >> >> >> I'd like to have an interceptor in the dojo plugin that extends
> >
> > >> the
> > >> >> >> validator interceptor, which outputs JSON with the messages
> > when
> > >> >> >> there are
> > >> >> >> validation errors.
> > >> >> >>
> > >> >> >> To use ajax validation all a user would have to do is add the
> > >> >> >> interceptor
> > >> >> >> to his/her class and set "validate" to "true" in either the
> > >> form, or
> > >> >> the
> > >> >> >> submit/anchor that is submitting the form.
> > >> >> >>
> > >> >> >> regards
> > >> >> >> musachy
> > >> >> >> --
> > >> >> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >>
> > >> >>
> > ---------------------------------------------------------------------
> > >> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > >> >> For additional commands, e-mail: dev-help@struts.apache.org
> > >> >>
> > >> >>
> > >> >
> > >> >
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: dev-help@struts.apache.org
> > >>
> > >>
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
That would be the function I mentioned before. With that in mind, I think it
would be better to have the interceptor and the generic function in core, so
it can be used with other js libraries. I was going to put it in the Dojo
plugin as we are moving all the ajax stuff there, but it isn't specific to
Dojo in any way.

musachy

On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
>
> Excellent. Well, then really all that is lacking is a generic JS script
> to handle the response and add errors to the form/labels/some div. It
> would be excellent to have a JS plugin model where developers can select
> the JS framework they want to use and then they can plugin to the Struts
> handling via a little bit of JS glue.
>
> -bp
>
>
> Musachy Barroso wrote:
> > Thanks for the code. Mine is very similar with some JSON encoding
> > added. The
> > resulting JSON is a little bit different:
> >
> > /*
> > {
> >   "errors": [
> >       "Error0", "Error1"
> >   ],
> >   "fieldErrors": {
> >       "field1" : ["Error0", "Error1"],
> >       "field2": ["Error0", "Error1"],
> >   }
> > }
> > */
> >
> > musachy
> >
> > On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
> >>
> >> I've also done this exercise twice in the past and both times I used
> >> other JS libraries including prototype. My first solution was
> >> specifically for WebWork and I don't recall any changes I had to make
> >> when moving it over to Struts2.
> >>
> >> Perhaps it makes sense to ensure that this will be completely pluggable
> >> since many folks are using other JS libraries. My solution only
> requires
> >> a form post that is the same or a partial version of the post that
> would
> >> normally be submitted. This allows me to use pretty much any library
> >> that can handle form submission.
> >>
> >> I've included my latest interceptor for you guys to look over. Let me
> >> know what you think. I was planning on making a Struts2 plugin that had
> >> this and the necessary JavaScript files and template to work with
> >> Prototype once I had finished it off. But if you are heading in that
> >> direction, we should collaborate on it.
> >>
> >> -bp
> >>
> >>
> >> Musachy Barroso wrote:
> >> > This would be for 2.1, and it would be in Bind.js. It is actually
> only
> >> > one
> >> > function, which will be calling the functions in
> >> > validation.js(addError/clearErrors...). I'm planning to do some
> >> > cleanup after that as we
> >> > have some javascript/css files hanging around, which are not used.
> >> >
> >> > musachy
> >> >
> >> > On 4/23/07, Ian Roughley <ia...@fdar.com> wrote:
> >> >>
> >> >> Is the Ajax code all in a module now (2.1.x)?  Would this change be
> >> >> checked into the 2.0.x branch or just the trunk under the Ajax
> >> module,
> >> >> and then some cleanup/removal of existing code in the trunk?
> >> >>
> >> >> /Ian
> >> >>
> >> >> Musachy Barroso wrote:
> >> >> > I have this working, but I want to give  it a little more time to
> >> >> > anyone to
> >> >> > object before committing it :), just to review, these are the
> >> >> different
> >> >> > validation options:
> >> >> >
> >> >> > 1. regular form, regular submit button  (normal validation)
> >> >> > 2. css_html form, or xhtml form (validate="true"), regular submit
> >> >> button
> >> >> > (client validation)
> >> >> > 3. css_html form, or xhtml form (validate="true"), ajax submit
> >> button
> >> >> > (client validation)
> >> >> > 4. regular form, css_html form, or xhtml form, where action has
> the
> >> >> > "ajaxValidation" interceptor, ajax submit button (validate="true")
> >> >> (ajax
> >> >> > validation = dojo+interceptor, no DWR)
> >> >> >
> >> >> > regards
> >> >> > musachy
> >> >> >
> >> >> > On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
> >> >> >>
> >> >> >> I'd like to propose a change on the way we do ajax validation.
> >> >> >> Instead of
> >> >> >> using DWR which requires an external dependency and configuring a
> >> >> >> servlet,
> >> >> >> I'd like to have an interceptor in the dojo plugin that extends
> >> the
> >> >> >> validator interceptor, which outputs JSON with the messages when
> >> >> >> there are
> >> >> >> validation errors.
> >> >> >>
> >> >> >> To use ajax validation all a user would have to do is add the
> >> >> >> interceptor
> >> >> >> to his/her class and set "validate" to "true" in either the
> >> form, or
> >> >> the
> >> >> >> submit/anchor that is submitting the form.
> >> >> >>
> >> >> >> regards
> >> >> >> musachy
> >> >> >> --
> >> >> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> >> For additional commands, e-mail: dev-help@struts.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: dev-help@struts.apache.org
> >>
> >>
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Brian Pontarelli <br...@pontarelli.com>.
Excellent. Well, then really all that is lacking is a generic JS script 
to handle the response and add errors to the form/labels/some div. It 
would be excellent to have a JS plugin model where developers can select 
the JS framework they want to use and then they can plugin to the Struts 
handling via a little bit of JS glue.

-bp


Musachy Barroso wrote:
> Thanks for the code. Mine is very similar with some JSON encoding 
> added. The
> resulting JSON is a little bit different:
>
> /*
> {
>   "errors": [
>       "Error0", "Error1"
>   ],
>   "fieldErrors": {
>       "field1" : ["Error0", "Error1"],
>       "field2": ["Error0", "Error1"],
>   }
> }
> */
>
> musachy
>
> On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
>>
>> I've also done this exercise twice in the past and both times I used
>> other JS libraries including prototype. My first solution was
>> specifically for WebWork and I don't recall any changes I had to make
>> when moving it over to Struts2.
>>
>> Perhaps it makes sense to ensure that this will be completely pluggable
>> since many folks are using other JS libraries. My solution only requires
>> a form post that is the same or a partial version of the post that would
>> normally be submitted. This allows me to use pretty much any library
>> that can handle form submission.
>>
>> I've included my latest interceptor for you guys to look over. Let me
>> know what you think. I was planning on making a Struts2 plugin that had
>> this and the necessary JavaScript files and template to work with
>> Prototype once I had finished it off. But if you are heading in that
>> direction, we should collaborate on it.
>>
>> -bp
>>
>>
>> Musachy Barroso wrote:
>> > This would be for 2.1, and it would be in Bind.js. It is actually only
>> > one
>> > function, which will be calling the functions in
>> > validation.js(addError/clearErrors...). I'm planning to do some
>> > cleanup after that as we
>> > have some javascript/css files hanging around, which are not used.
>> >
>> > musachy
>> >
>> > On 4/23/07, Ian Roughley <ia...@fdar.com> wrote:
>> >>
>> >> Is the Ajax code all in a module now (2.1.x)?  Would this change be
>> >> checked into the 2.0.x branch or just the trunk under the Ajax 
>> module,
>> >> and then some cleanup/removal of existing code in the trunk?
>> >>
>> >> /Ian
>> >>
>> >> Musachy Barroso wrote:
>> >> > I have this working, but I want to give  it a little more time to
>> >> > anyone to
>> >> > object before committing it :), just to review, these are the
>> >> different
>> >> > validation options:
>> >> >
>> >> > 1. regular form, regular submit button  (normal validation)
>> >> > 2. css_html form, or xhtml form (validate="true"), regular submit
>> >> button
>> >> > (client validation)
>> >> > 3. css_html form, or xhtml form (validate="true"), ajax submit 
>> button
>> >> > (client validation)
>> >> > 4. regular form, css_html form, or xhtml form, where action has the
>> >> > "ajaxValidation" interceptor, ajax submit button (validate="true")
>> >> (ajax
>> >> > validation = dojo+interceptor, no DWR)
>> >> >
>> >> > regards
>> >> > musachy
>> >> >
>> >> > On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
>> >> >>
>> >> >> I'd like to propose a change on the way we do ajax validation.
>> >> >> Instead of
>> >> >> using DWR which requires an external dependency and configuring a
>> >> >> servlet,
>> >> >> I'd like to have an interceptor in the dojo plugin that extends 
>> the
>> >> >> validator interceptor, which outputs JSON with the messages when
>> >> >> there are
>> >> >> validation errors.
>> >> >>
>> >> >> To use ajax validation all a user would have to do is add the
>> >> >> interceptor
>> >> >> to his/her class and set "validate" to "true" in either the 
>> form, or
>> >> the
>> >> >> submit/anchor that is submitting the form.
>> >> >>
>> >> >> regards
>> >> >> musachy
>> >> >> --
>> >> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: dev-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
By the way, should we ever bring the JSON plugin in?

musachy

On 4/23/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> Thanks for the code. Mine is very similar with some JSON encoding added.
> The resulting JSON is a little bit different:
>
> /*
> {
>    "errors": [
>        "Error0", "Error1"
>    ],
>    "fieldErrors": {
>        "field1" : ["Error0", "Error1"],
>        "field2": ["Error0", "Error1"],
>    }
> }
> */
>
> musachy
>
> On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
>
> > I've also done this exercise twice in the past and both times I used
> > other JS libraries including prototype. My first solution was
> > specifically for WebWork and I don't recall any changes I had to make
> > when moving it over to Struts2.
> >
> > Perhaps it makes sense to ensure that this will be completely pluggable
> > since many folks are using other JS libraries. My solution only requires
> > a form post that is the same or a partial version of the post that would
> >
> > normally be submitted. This allows me to use pretty much any library
> > that can handle form submission.
> >
> > I've included my latest interceptor for you guys to look over. Let me
> > know what you think. I was planning on making a Struts2 plugin that had
> > this and the necessary JavaScript files and template to work with
> > Prototype once I had finished it off. But if you are heading in that
> > direction, we should collaborate on it.
> >
> > -bp
> >
> >
> > Musachy Barroso wrote:
> > > This would be for 2.1, and it would be in Bind.js. It is actually only
> > > one
> > > function, which will be calling the functions in
> > > validation.js(addError/clearErrors...). I'm planning to do some
> > > cleanup after that as we
> > > have some javascript/css files hanging around, which are not used.
> > >
> > > musachy
> > >
> > > On 4/23/07, Ian Roughley <ian@fdar.com > wrote:
> > >>
> > >> Is the Ajax code all in a module now (2.1.x)?  Would this change be
> > >> checked into the 2.0.x branch or just the trunk under the Ajax
> > module,
> > >> and then some cleanup/removal of existing code in the trunk?
> > >>
> > >> /Ian
> > >>
> > >> Musachy Barroso wrote:
> > >> > I have this working, but I want to give  it a little more time to
> > >> > anyone to
> > >> > object before committing it :), just to review, these are the
> > >> different
> > >> > validation options:
> > >> >
> > >> > 1. regular form, regular submit button  (normal validation)
> > >> > 2. css_html form, or xhtml form (validate="true"), regular submit
> > >> button
> > >> > (client validation)
> > >> > 3. css_html form, or xhtml form (validate="true"), ajax submit
> > button
> > >> > (client validation)
> > >> > 4. regular form, css_html form, or xhtml form, where action has the
> >
> > >> > "ajaxValidation" interceptor, ajax submit button (validate="true")
> > >> (ajax
> > >> > validation = dojo+interceptor, no DWR)
> > >> >
> > >> > regards
> > >> > musachy
> > >> >
> > >> > On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
> > >> >>
> > >> >> I'd like to propose a change on the way we do ajax validation.
> > >> >> Instead of
> > >> >> using DWR which requires an external dependency and configuring a
> > >> >> servlet,
> > >> >> I'd like to have an interceptor in the dojo plugin that extends
> > the
> > >> >> validator interceptor, which outputs JSON with the messages when
> > >> >> there are
> > >> >> validation errors.
> > >> >>
> > >> >> To use ajax validation all a user would have to do is add the
> > >> >> interceptor
> > >> >> to his/her class and set "validate" to "true" in either the form,
> > or
> > >> the
> > >> >> submit/anchor that is submitting the form.
> > >> >>
> > >> >> regards
> > >> >> musachy
> > >> >> --
> > >> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> > >> >
> > >> >
> > >> >
> > >> >
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: dev-help@struts.apache.org
> > >>
> > >>
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
Thanks for the code. Mine is very similar with some JSON encoding added. The
resulting JSON is a little bit different:

/*
{
   "errors": [
       "Error0", "Error1"
   ],
   "fieldErrors": {
       "field1" : ["Error0", "Error1"],
       "field2": ["Error0", "Error1"],
   }
}
*/

musachy

On 4/23/07, Brian Pontarelli <br...@pontarelli.com> wrote:
>
> I've also done this exercise twice in the past and both times I used
> other JS libraries including prototype. My first solution was
> specifically for WebWork and I don't recall any changes I had to make
> when moving it over to Struts2.
>
> Perhaps it makes sense to ensure that this will be completely pluggable
> since many folks are using other JS libraries. My solution only requires
> a form post that is the same or a partial version of the post that would
> normally be submitted. This allows me to use pretty much any library
> that can handle form submission.
>
> I've included my latest interceptor for you guys to look over. Let me
> know what you think. I was planning on making a Struts2 plugin that had
> this and the necessary JavaScript files and template to work with
> Prototype once I had finished it off. But if you are heading in that
> direction, we should collaborate on it.
>
> -bp
>
>
> Musachy Barroso wrote:
> > This would be for 2.1, and it would be in Bind.js. It is actually only
> > one
> > function, which will be calling the functions in
> > validation.js(addError/clearErrors...). I'm planning to do some
> > cleanup after that as we
> > have some javascript/css files hanging around, which are not used.
> >
> > musachy
> >
> > On 4/23/07, Ian Roughley <ia...@fdar.com> wrote:
> >>
> >> Is the Ajax code all in a module now (2.1.x)?  Would this change be
> >> checked into the 2.0.x branch or just the trunk under the Ajax module,
> >> and then some cleanup/removal of existing code in the trunk?
> >>
> >> /Ian
> >>
> >> Musachy Barroso wrote:
> >> > I have this working, but I want to give  it a little more time to
> >> > anyone to
> >> > object before committing it :), just to review, these are the
> >> different
> >> > validation options:
> >> >
> >> > 1. regular form, regular submit button  (normal validation)
> >> > 2. css_html form, or xhtml form (validate="true"), regular submit
> >> button
> >> > (client validation)
> >> > 3. css_html form, or xhtml form (validate="true"), ajax submit button
> >> > (client validation)
> >> > 4. regular form, css_html form, or xhtml form, where action has the
> >> > "ajaxValidation" interceptor, ajax submit button (validate="true")
> >> (ajax
> >> > validation = dojo+interceptor, no DWR)
> >> >
> >> > regards
> >> > musachy
> >> >
> >> > On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
> >> >>
> >> >> I'd like to propose a change on the way we do ajax validation.
> >> >> Instead of
> >> >> using DWR which requires an external dependency and configuring a
> >> >> servlet,
> >> >> I'd like to have an interceptor in the dojo plugin that extends the
> >> >> validator interceptor, which outputs JSON with the messages when
> >> >> there are
> >> >> validation errors.
> >> >>
> >> >> To use ajax validation all a user would have to do is add the
> >> >> interceptor
> >> >> to his/her class and set "validate" to "true" in either the form, or
> >> the
> >> >> submit/anchor that is submitting the form.
> >> >>
> >> >> regards
> >> >> musachy
> >> >> --
> >> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >> >
> >> >
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: dev-help@struts.apache.org
> >>
> >>
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Brian Pontarelli <br...@pontarelli.com>.
I've also done this exercise twice in the past and both times I used 
other JS libraries including prototype. My first solution was 
specifically for WebWork and I don't recall any changes I had to make 
when moving it over to Struts2.

Perhaps it makes sense to ensure that this will be completely pluggable 
since many folks are using other JS libraries. My solution only requires 
a form post that is the same or a partial version of the post that would 
normally be submitted. This allows me to use pretty much any library 
that can handle form submission.

I've included my latest interceptor for you guys to look over. Let me 
know what you think. I was planning on making a Struts2 plugin that had 
this and the necessary JavaScript files and template to work with 
Prototype once I had finished it off. But if you are heading in that 
direction, we should collaborate on it.

-bp


Musachy Barroso wrote:
> This would be for 2.1, and it would be in Bind.js. It is actually only 
> one
> function, which will be calling the functions in
> validation.js(addError/clearErrors...). I'm planning to do some
> cleanup after that as we
> have some javascript/css files hanging around, which are not used.
>
> musachy
>
> On 4/23/07, Ian Roughley <ia...@fdar.com> wrote:
>>
>> Is the Ajax code all in a module now (2.1.x)?  Would this change be
>> checked into the 2.0.x branch or just the trunk under the Ajax module,
>> and then some cleanup/removal of existing code in the trunk?
>>
>> /Ian
>>
>> Musachy Barroso wrote:
>> > I have this working, but I want to give  it a little more time to
>> > anyone to
>> > object before committing it :), just to review, these are the 
>> different
>> > validation options:
>> >
>> > 1. regular form, regular submit button  (normal validation)
>> > 2. css_html form, or xhtml form (validate="true"), regular submit 
>> button
>> > (client validation)
>> > 3. css_html form, or xhtml form (validate="true"), ajax submit button
>> > (client validation)
>> > 4. regular form, css_html form, or xhtml form, where action has the
>> > "ajaxValidation" interceptor, ajax submit button (validate="true") 
>> (ajax
>> > validation = dojo+interceptor, no DWR)
>> >
>> > regards
>> > musachy
>> >
>> > On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
>> >>
>> >> I'd like to propose a change on the way we do ajax validation.
>> >> Instead of
>> >> using DWR which requires an external dependency and configuring a
>> >> servlet,
>> >> I'd like to have an interceptor in the dojo plugin that extends the
>> >> validator interceptor, which outputs JSON with the messages when
>> >> there are
>> >> validation errors.
>> >>
>> >> To use ajax validation all a user would have to do is add the
>> >> interceptor
>> >> to his/her class and set "validate" to "true" in either the form, or
>> the
>> >> submit/anchor that is submitting the form.
>> >>
>> >> regards
>> >> musachy
>> >> --
>> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
>> >
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
>


Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
This would be for 2.1, and it would be in Bind.js. It is actually only one
function, which will be calling the functions in
validation.js(addError/clearErrors...). I'm planning to do some
cleanup after that as we
have some javascript/css files hanging around, which are not used.

musachy

On 4/23/07, Ian Roughley <ia...@fdar.com> wrote:
>
> Is the Ajax code all in a module now (2.1.x)?  Would this change be
> checked into the 2.0.x branch or just the trunk under the Ajax module,
> and then some cleanup/removal of existing code in the trunk?
>
> /Ian
>
> Musachy Barroso wrote:
> > I have this working, but I want to give  it a little more time to
> > anyone to
> > object before committing it :), just to review, these are the different
> > validation options:
> >
> > 1. regular form, regular submit button  (normal validation)
> > 2. css_html form, or xhtml form (validate="true"), regular submit button
> > (client validation)
> > 3. css_html form, or xhtml form (validate="true"), ajax submit button
> > (client validation)
> > 4. regular form, css_html form, or xhtml form, where action has the
> > "ajaxValidation" interceptor, ajax submit button (validate="true") (ajax
> > validation = dojo+interceptor, no DWR)
> >
> > regards
> > musachy
> >
> > On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
> >>
> >> I'd like to propose a change on the way we do ajax validation.
> >> Instead of
> >> using DWR which requires an external dependency and configuring a
> >> servlet,
> >> I'd like to have an interceptor in the dojo plugin that extends the
> >> validator interceptor, which outputs JSON with the messages when
> >> there are
> >> validation errors.
> >>
> >> To use ajax validation all a user would have to do is add the
> >> interceptor
> >> to his/her class and set "validate" to "true" in either the form, or
> the
> >> submit/anchor that is submitting the form.
> >>
> >> regards
> >> musachy
> >> --
> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: PROPOSAL: S2 ajax validation

Posted by Ian Roughley <ia...@fdar.com>.
Is the Ajax code all in a module now (2.1.x)?  Would this change be 
checked into the 2.0.x branch or just the trunk under the Ajax module, 
and then some cleanup/removal of existing code in the trunk?

/Ian

Musachy Barroso wrote:
> I have this working, but I want to give  it a little more time to 
> anyone to
> object before committing it :), just to review, these are the different
> validation options:
>
> 1. regular form, regular submit button  (normal validation)
> 2. css_html form, or xhtml form (validate="true"), regular submit button
> (client validation)
> 3. css_html form, or xhtml form (validate="true"), ajax submit button
> (client validation)
> 4. regular form, css_html form, or xhtml form, where action has the
> "ajaxValidation" interceptor, ajax submit button (validate="true") (ajax
> validation = dojo+interceptor, no DWR)
>
> regards
> musachy
>
> On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
>>
>> I'd like to propose a change on the way we do ajax validation. 
>> Instead of
>> using DWR which requires an external dependency and configuring a 
>> servlet,
>> I'd like to have an interceptor in the dojo plugin that extends the
>> validator interceptor, which outputs JSON with the messages when 
>> there are
>> validation errors.
>>
>> To use ajax validation all a user would have to do is add the 
>> interceptor
>> to his/her class and set "validate" to "true" in either the form, or the
>> submit/anchor that is submitting the form.
>>
>> regards
>> musachy
>> -- 
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: PROPOSAL: S2 ajax validation

Posted by Musachy Barroso <mu...@gmail.com>.
I have this working, but I want to give  it a little more time to anyone to
object before committing it :), just to review, these are the different
validation options:

1. regular form, regular submit button  (normal validation)
2. css_html form, or xhtml form (validate="true"), regular submit button
(client validation)
3. css_html form, or xhtml form (validate="true"), ajax submit button
(client validation)
4. regular form, css_html form, or xhtml form, where action has the
"ajaxValidation" interceptor, ajax submit button (validate="true") (ajax
validation = dojo+interceptor, no DWR)

regards
musachy

On 4/21/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> I'd like to propose a change on the way we do ajax validation. Instead of
> using DWR which requires an external dependency and configuring a servlet,
> I'd like to have an interceptor in the dojo plugin that extends the
> validator interceptor, which outputs JSON with the messages when there are
> validation errors.
>
> To use ajax validation all a user would have to do is add the interceptor
> to his/her class and set "validate" to "true" in either the form, or the
> submit/anchor that is submitting the form.
>
> regards
> musachy
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd




-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd