473,382 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

javascript to java migeration

10
i am passing a javascript array object in the hidden field on submit, and appending
this object to a bean class method. when i retrieve it back, the array elements
are coming as a single string.
i want it as a array of elements so that i can iterate through it.

can any 1 help me out...............?
Mar 5 '08 #1
5 1119
BigDaddyLH
1,216 Expert 1GB
i am passing a javascript array object in the hidden field on submit, and appending
this object to a bean class method. when i retrieve it back, the array elements
are coming as a single string.
i want it as a array of elements so that i can iterate through it.

can any 1 help me out...............?
I don't know JavaScript. Post a typical string as you receive it in Java and we can give better suggestions. My initial guess would be that String split method should be sufficient to parse it, but let's see a couple examples first.

http://java.sun.com/javase/6/docs/ap...a.lang.String)
Mar 5 '08 #2
sai26
10
I don't know JavaScript. Post a typical string as you receive it in Java and we can give better suggestions. My initial guess would be that String split method should be sufficient to parse it, but let's see a couple examples first.

http://java.sun.com/javase/6/docs/ap...a.lang.String)
lets say i have a array instance -> aa
frm javascript i send it as :
document.formName.action = "URL&arry="+aa;
document.formName.submit();
-------------
in java class i set it in java bean as :
private String[] arr;
public void setArray(String[] arr) {
this.arr = arr;
}
public String[] getArray() {
return arr;
}
------------
so when i retrieve it, it is comming as a single string with comma saperated values. e.g a,b,c.....
cant i get it in the array format e.g arr[0]=a,arr[1]=b ect
Mar 7 '08 #3
sukatoa
539 512MB
lets say i have a array instance -> aa
frm javascript i send it as :
document.formName.action = "URL&arry="+aa;
document.formName.submit();
-------------
in java class i set it in java bean as :
private String[] arr;
public void setArray(String[] arr) {
this.arr = arr;
}
public String[] getArray() {
return arr;
}
------------
so when i retrieve it, it is comming as a single string with comma saperated values. e.g a,b,c.....
cant i get it in the array format e.g arr[0]=a,arr[1]=b ect
This is new to me...
But, if you can manage the received array in that kind of format (a,b,c....)

You can implement a function or method in java (correct me if im wrong)
that would extract the received data format to what kind of result you are expecting....

Then, pass it to the function that should receive the expected format...


Guessing,
Sukatoa
Mar 7 '08 #4
sai26
10
This is new to me...
But, if you can manage the received array in that kind of format (a,b,c....)

You can implement a function or method in java (correct me if im wrong)
that would extract the received data format to what kind of result you are expecting....

Then, pass it to the function that should receive the expected format...


Guessing,
Sukatoa
hmm.... so u mean to use the split on the data and get it in form of array
Mar 7 '08 #5
BigDaddyLH
1,216 Expert 1GB
hmm.... so u mean to use the split on the data and get it in form of array
Are you familiar with the existence of Java API documentation?

http://java.sun.com/javase/6/docs/api/

demo:

Expand|Select|Wrap|Line Numbers
  1. public class Split {
  2.     public static void main(String[] args) {
  3.         String data = "a,bb,ccc,dd,e";
  4.         String[] tokens = data.split(",");
  5.         for(String token : tokens) {
  6.             System.out.format("token=[%s]%n", token);
  7.         }
  8.     }
  9. }
I find it a good idea when I don't understand a method to stop, and write a little code to play with it.
Mar 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Frank | last post by:
Hey all, I can't seem to get javascript running in my XSL document. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"...
6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
10
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
9
by: MStepansky | last post by:
Whats the difference between Javascript and Java3D? I mean can Javascript do like Java3D can? Or is Java3D on top of Javascript (the core, if thats what it is)? Then I should learn Javascript...
10
by: VictorG | last post by:
Hello, I am new to JS and am trying to add some HTML into a JS function. So that when called the script as well as the HTML will be invoked. Is there some type of embed mechanism, sort of the...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
33
by: Simon Brooke | last post by:
I'm working on a system which uses Google maps. I want the user to see a map of more or less where (s)he is in the world when (s)he first comes to the system. So the obvious thing seemed to be to...
2
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.