File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript - Arraylist

 
Luke Zechariah
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help, I am trying to accomplish 2 things:

1. I am having a list of objects, how do I get the values into the javascript. Suppose I have 5 rows, if I check on the 3rd checkbox, how do I send the values to javascript.
2. I also want to check only one check box at a time, how do I accomplish, ie. if I check the left one, the right one needs to be unchecked automatically.


Example:


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This is the second post of yours today that I've moved to the Struts forum. For more information, please read this.
 
Luke Zechariah
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry sheriff.
 
Er. Rohit Sharma
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per my understanding your jsp will some what look like this :

checkbox property1 property2 property3 property4 checkbox.

Are you provinding distinct id's to each row so that the row can be differentiated from other row.
Or you can also provide different id's to each property of jsp.
If you are succeded in doing this then all you have to do is.. document.getElementById(unique id).value;
if you get the id then you can disable the other checkbox by setting its value to false.
 
Luke Zechariah
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rohit,

No I am not providing distinct id to each row. The jsp does not allow me to assign id's, it is giving me error How can I achieve that functionality. Please let me know.

Here is what I have written:

<td><html:multibox id="acpt" property="arIndexVal" onclick="populateList(this, 'A')" >
<bean:write name="item" property="acceptValues" />
</html:multibox></td>

It is giving errors when I write the id="acpt".

Thanks,
Lk.
 
Rohit Sharad Sharma
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use styleId in place of id.
 
Luke Zechariah
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rohit, it is working.

I have 2 more questions:

1. What is the equivalent of checked="checked" in multibox because when the page loads all the check boxes are checked. I want them to be unchecked.

2. Ok I got the value to the javascript. Appended it with a string, now how do I pass it back to the form and add it to the javabean. Is it possible. All I want to know is which checkbox I choose, the left one or the right one.
 
Rohit Sharad Sharma
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Luke you can have a look at struts api , there you would be able to find each tag associated with multibox. Try and have a look.

And for setting the value back to bean use document.forms[0].property.value = your value;
and for submitting use document.form.submit();
Do take care your jsp should hold a property name against the value you are submitting and if not use hidden fields as a value holder.
 
Luke Zechariah
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rohit,

I found a way how to keep the checkboxes unchecked while displaying. We need to define the reset method in the form as below:

In the action file call the function:
concurrentCaseInfoForm.reset(mapping, request);


I have another question: please see below code:
JSP:


The notes field at the bottom is a html:text field, so if I change anything in the text field on the jsp, it should store in the form. But when called in the action I am getting a null value. In the action I am calling it as:




I am getting the output having null objects for the bean.

Please let me know, hope I am clear with my question i.e. How do I store the values in the bean if there is any change on the jsp.

Thanks,
Lk.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic