This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Passing Two Dimensional Array through Ajax to Java(Action) in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing Two Dimensional Array through Ajax to Java(Action) in Struts" Watch "Passing Two Dimensional Array through Ajax to Java(Action) in Struts" New topic
Author

Passing Two Dimensional Array through Ajax to Java(Action) in Struts

Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
Hi I have already tried with some code successfully but it is of single value of true false type('Y'/'N'), but with the following code



just vanishes the field stating the following tomcat log error.
>

next problem is that when I try to assign some value like "Objective Numeric Answer", each word is taken for each txtArrOuter[k] as above.
If I try to assign value like "ObjectiveNumericAnswer" single word, it takes the whole word and repeats just three times and gives the error as above.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Your query is incorrect. Assuming the encoding works, you'll end up with something like this value for query:
In other words, you're missing the & between the parameters.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
Thank's I have lost in vain all my valuable times without rectifying it. I will come back after trying you.
Thank's again.
Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
I have missed the ampersand in the posting not in My code.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Well, it would help if you PostRealCode.
Can you show the query string as it is both sent and received?
Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
>
Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
alert came as in

log as in tomcat from action class.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Chitta Ranjan Mishra wrote:ON_getHdnObjectiveNumericalIdArr()[1][1]: 0java.lang.ArrayIndexOutOfBoundsException: 1

OK, so the problem is in getHdnObjectiveNumericalIdArr. That makes me believe the problem lies in the handling of hdnObjectiveNumericalIdArr. So I check that part of your query:
In line 2 I see hdnObjectiveNumericalIdArr with value 0%2C0txtObjectiveNumerical=MultiChoiceAnswer. In line 4 I again see hdnObjectiveNumericalIdArr, this time with value 0%2C0. I think you've made a little mistake here.
Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
Hi,
the first thing is I don't want to put any default value. But if I do not put any value in to it as in code bellow and marked in comments as"//value put here unnecessarily", then the ArrayIndexOutOfBoundsException comes for all the values in a whole.


The values "0%2C0" are taken from no where in the block bellow the commented line as "//else if(gblQueCat == "ON")" (from the prepareUrl() method of the whole js code). Except for the case all other blocks where no such error occurs. So the changed format in that block is because of this error.
>
Chitta Ranjan Mishra
Greenhorn

Joined: Apr 15, 2008
Posts: 12
Thanks a lot I have got the error. The variable defined to assigned default is same as array variable.

BUT

I am still confused Can I use the code without using any default value?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing Two Dimensional Array through Ajax to Java(Action) in Struts
 
Similar Threads
Struts 2 and auto population of HTML tables
Sun Cirtification
TreeMap question#1
Object Required error in Javascript.
Page section does not update after call of a4j:support in IE 9