Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array of Objects Paramater to Applet

 
Nitin Sharma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to send an array of objects( objects of type "Activity" which is a user -defined class) as a parameter to Applet But am not sure how to do it? can someone help?

Thanks
 
Norm Radder
Ranch Hand
Pie
Posts: 1032
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you calling the applet?
If by using the <APPLET tag then you pass values to it using <PARAM tags. Since <PARAM tags are created at HTML creation time, I don't see how this could be use to pass an array of objects.
If by calling if from another applet you'd use the getApplet/getApplets method of the AppletContext to get a reference to the applet that you could call with the array.

Where is the array of objects being created? If on a server before creating the HTML, you'll have to do your own "serialization" of the data into valid HTML characters before creating the <PARAM tags with that data.
[ June 25, 2008: Message edited by: Norm Radder ]
 
Nitin Sharma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am embeding the applet in a jsp and am passing parameters using the Param tag. I get the arrayof ojects from a session varaible.

What i am trying to do actually is
1) Try gettin an array of objects from the session and set it to an array

2) pass the array as a parameter

<param name="blahblah" value="<%=arayname%>">

When i retrieve i just hae a method called this.getParameter() that returns just a string..

I dont know how to retireve the array from the getParameter method?

Thanks
 
Norm Radder
Ranch Hand
Pie
Posts: 1032
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To pass a number of parameters similating an array you need to generate names by appending a suffix, such as 1, 2, 3, ... to the value that is used in the name= attribute of the <PARAM tag. EG
<param name=elem1 value=...>
<param name=elem2 value=...>
<param name=elem3 value=...>

Then in the applet, have a loop the builds the name by appending a digit, gets it, checks for null, processes it and continues. Something like the following;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic