You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ravi_eze <ra...@yahoo.com> on 2007/12/31 08:35:24 UTC
wrong request parameters sent
hi,
i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;
validate=true). I am trying to get the validation done by ajax and when i
un-check all boxes or check some of the boxes i see that always c3 is being
set in request parameter.
when i tried to debug i found the following statement in validationClient.js
which could be a cause of this behavior:
var vc = this;
var form = input.form;
var params = new Object();
for (var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if (e.name != null && e.name != '') {
params[e.name] = e.value;
}
}
which is always putting the 3rd checkbox in the request parameter even
though its not checked. If i remove all ajax related attributes (i.e.
<s:head, <s:form.. ) the parameters are going right and the validations are
happening fine.
any ideas where i am going wrong/ is any body else is also getting the same
behavior?
--
View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14555088.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: wrong request parameters sent
Posted by ravi_eze <ra...@yahoo.com>.
i somehow feel checkboxes are not properly handled in struts 2.x any
controversies???
ravi_eze wrote:
>
> hi,
>
> i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;
> validate=true). I am trying to get the validation done by ajax and when i
> un-check all boxes or check some of the boxes i see that always c3 is
> being set in request parameter.
>
> when i tried to debug i found the following statement in
> validationClient.js which could be a cause of this behavior:
>
> var vc = this;
> var form = input.form;
> var params = new Object();
> for (var i = 0; i < form.elements.length; i++) {
> var e = form.elements[i];
> if (e.name != null && e.name != '') {
> params[e.name] = e.value;
> }
> }
>
> which is always putting the 3rd checkbox in the request parameter even
> though its not checked. If i remove all ajax related attributes (i.e.
> <s:head, <s:form.. ) the parameters are going right and the validations
> are happening fine.
>
> any ideas where i am going wrong/ is any body else is also getting the
> same behavior?
>
>
--
View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14558085.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: wrong request parameters sent
Posted by ravi_eze <ra...@yahoo.com>.
hi,
the issue seems to be fixed. It seems like a problem with the xhtml theme
thats not using .js files properly. i corrected the validation.js in xhtml
and ajax folders, validationClilent.js and created a corrected theme
(http://www.vitarara.org/cms/struts_2_cookbook/creating_a_theme : was vital
in helping me for steps:
http://thelittlefellow.blogspot.com/2008/01/eureka-eureka-got-soln-ajax-validations.html).
Now the ajax validations are happening fine.
I am posting a reply as it may be a help to some one who is looking for an
soln to the problem :)
hope this helps.
cheers,
ravi
ravi_eze wrote:
>
> hi,
>
> when i replace the provided code with:
>
> for (var i = 0; i < form.elements.length; i++) {
> var e = form.elements[i];
> if (e.name != null && e.name != '') {
> if(e.type =='checkbox'){
> if(e.checked==true)
> params[e.name] = e.value;
> }else{
> params[e.name] = e.value;
> }
> }
> the correct request parameters are being sent and are also getting
> correctly validated. Now i am facing a new problem: If there is a single
> checkbox then i see field errors being displayed, but if there are
> multiple checkboxes then i dont see any field errors. I strongly believe
> that i am going wrong some where... any help would be appreciated.
>
> after some debugging i found that an if condition ( if
> (form.elements[fieldName].touched) {
> 12 for (var i = 0; i < errors.fieldErrors[fieldName].length; i++) {
> 13 addError(form.elements[fieldName], errors.fieldErrors[fieldName][i]);
> 14 }
> 15 }) of validations.js failing for multiple checkboxes which is causing
> the problem.
>
> i believe that there is some mistake with configuration. any help?
>
>
>
> ravi_eze wrote:
>>
>> hi,
>>
>> i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;
>> validate=true). I am trying to get the validation done by ajax and when i
>> un-check all boxes or check some of the boxes i see that always c3 is
>> being set in request parameter.
>>
>> when i tried to debug i found the following statement in
>> validationClient.js which could be a cause of this behavior:
>>
>> var vc = this;
>> var form = input.form;
>> var params = new Object();
>> for (var i = 0; i < form.elements.length; i++) {
>> var e = form.elements[i];
>> if (e.name != null && e.name != '') {
>> params[e.name] = e.value;
>> }
>> }
>>
>> which is always putting the 3rd checkbox in the request parameter even
>> though its not checked. If i remove all ajax related attributes (i.e.
>> <s:head, <s:form.. ) the parameters are going right and the validations
>> are happening fine.
>>
>> any ideas where i am going wrong/ is any body else is also getting the
>> same behavior?
>>
>>
>
>
--
View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14591721.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: wrong request parameters sent
Posted by ravi_eze <ra...@yahoo.com>.
hi,
when i replace the provided code with:
for (var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if (e.name != null && e.name != '') {
if(e.type =='checkbox'){
if(e.checked==true)
params[e.name] = e.value;
}else{
params[e.name] = e.value;
}
}
the correct request parameters are being sent and are also getting correctly
validated. Now i am facing a new problem: If there is a single checkbox then
i see field errors being displayed, but if there are multiple checkboxes
then i dont see any field errors. I strongly believe that i am going wrong
some where... any help would be appreciated.
after some debugging i found that an if condition ( if
(form.elements[fieldName].touched) {
12 for (var i = 0; i < errors.fieldErrors[fieldName].length; i++) {
13 addError(form.elements[fieldName], errors.fieldErrors[fieldName][i]);
14 }
15 }) of validations.js failing for multiple checkboxes which is causing the
problem.
i believe that there is some mistake with configuration. any help?
ravi_eze wrote:
>
> hi,
>
> i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;
> validate=true). I am trying to get the validation done by ajax and when i
> un-check all boxes or check some of the boxes i see that always c3 is
> being set in request parameter.
>
> when i tried to debug i found the following statement in
> validationClient.js which could be a cause of this behavior:
>
> var vc = this;
> var form = input.form;
> var params = new Object();
> for (var i = 0; i < form.elements.length; i++) {
> var e = form.elements[i];
> if (e.name != null && e.name != '') {
> params[e.name] = e.value;
> }
> }
>
> which is always putting the 3rd checkbox in the request parameter even
> though its not checked. If i remove all ajax related attributes (i.e.
> <s:head, <s:form.. ) the parameters are going right and the validations
> are happening fine.
>
> any ideas where i am going wrong/ is any body else is also getting the
> same behavior?
>
>
--
View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14557923.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: wrong request parameters sent
Posted by ravi_eze <ra...@yahoo.com>.
yaa i am presetting the checkbox.
any how i got the solution, may b a workaround one:i wrote a reset
interceptor which would always reset the checkbox vairable of the action
class when the jsp page is submitted. now if the checkbox is not selected
the value remains reset.
mgainty wrote:
>
>
> are you pre-setting the value or fieldValue attributes for s:checkbox
> please display code in your jspMartin
> ______________________________________________Disclaimer and
> confidentiality noteEverything in this e-mail and any attachments relates
> to the official business of Sender. This transmission is of a confidential
> nature and Sender does not endorse distribution to any party other than
> intended recipient. Sender does not necessarily endorse content contained
> within this transmission.> Date: Mon, 31 Dec 2007 21:48:12 -0800> From:
> ravi_eze@yahoo.com> To: user@struts.apache.org> Subject: Re: wrong request
> parameters sent> > > hi any help?> > > > ravi_eze wrote:> > > > hi,> > > >
> i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;> >
> validate=true). I am trying to get the validation done by ajax and when i>
> > un-check all boxes or check some of the boxes i see that always c3 is> >
> being set in request parameter.> > > > when i tried to debug i found the
> following statement in> > validationClient.js which could be a cause of
> this behavior:> > > > var vc = this;> > var form = input.form;> > var
> params = new Object();> > for (var i = 0; i < form.elements.length; i++)
> {> > var e = form.elements[i];> > if (e.name != null && e.name != '') {> >
> params[e.name] = e.value;> > }> > }> > > > which is always putting the 3rd
> checkbox in the request parameter even> > though its not checked. If i
> remove all ajax related attributes (i.e.> > <s:head, <s:form.. ) the
> parameters are going right and the validations> > are happening fine. > >
> > > any ideas where i am going wrong/ is any body else is also getting
> the> > same behavior?> > > > > > -- > View this message in context:
> http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14564745.html>
> Sent from the Struts - User mailing list archive at Nabble.com.> > >
> ---------------------------------------------------------------------> To
> unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional
> commands, e-mail: user-help@struts.apache.org>
> _________________________________________________________________
> Don't get caught with egg on your face. Play Chicktionary!
> http://club.live.com/chicktionary.aspx?icid=chick_wlhmtextlink1_dec
>
--
View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14631571.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: wrong request parameters sent
Posted by Martin Gainty <mg...@hotmail.com>.
are you pre-setting the value or fieldValue attributes for s:checkbox
please display code in your jspMartin ______________________________________________Disclaimer and confidentiality noteEverything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.> Date: Mon, 31 Dec 2007 21:48:12 -0800> From: ravi_eze@yahoo.com> To: user@struts.apache.org> Subject: Re: wrong request parameters sent> > > hi any help?> > > > ravi_eze wrote:> > > > hi,> > > > i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;> > validate=true). I am trying to get the validation done by ajax and when i> > un-check all boxes or check some of the boxes i see that always c3 is> > being set in request parameter.> > > > when i tried to debug i found the following statement in> > validationClient.js which could be a cause of this behavior:> > > > var vc = this;> > var form = input.form;> > var params = new Object();> > for (var i = 0; i < form.elements.length; i++) {> > var e = form.elements[i];> > if (e.name != null && e.name != '') {> > params[e.name] = e.value;> > }> > }> > > > which is always putting the 3rd checkbox in the request parameter even> > though its not checked. If i remove all ajax related attributes (i.e.> > <s:head, <s:form.. ) the parameters are going right and the validations> > are happening fine. > > > > any ideas where i am going wrong/ is any body else is also getting the> > same behavior?> > > > > > -- > View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14564745.html> Sent from the Struts - User mailing list archive at Nabble.com.> > > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org>
_________________________________________________________________
Don't get caught with egg on your face. Play Chicktionary!
http://club.live.com/chicktionary.aspx?icid=chick_wlhmtextlink1_dec
Re: wrong request parameters sent
Posted by ravi_eze <ra...@yahoo.com>.
hi any help?
ravi_eze wrote:
>
> hi,
>
> i have 3 checkboxes(c1,c2,c3) enclosed in a form (theme: ajax;
> validate=true). I am trying to get the validation done by ajax and when i
> un-check all boxes or check some of the boxes i see that always c3 is
> being set in request parameter.
>
> when i tried to debug i found the following statement in
> validationClient.js which could be a cause of this behavior:
>
> var vc = this;
> var form = input.form;
> var params = new Object();
> for (var i = 0; i < form.elements.length; i++) {
> var e = form.elements[i];
> if (e.name != null && e.name != '') {
> params[e.name] = e.value;
> }
> }
>
> which is always putting the 3rd checkbox in the request parameter even
> though its not checked. If i remove all ajax related attributes (i.e.
> <s:head, <s:form.. ) the parameters are going right and the validations
> are happening fine.
>
> any ideas where i am going wrong/ is any body else is also getting the
> same behavior?
>
>
--
View this message in context: http://www.nabble.com/wrong-request-parameters-sent-tp14555088p14564745.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org