This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes using logic:iterate index with html:multibox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using logic:iterate index with html:multibox" Watch "using logic:iterate index with html:multibox" New topic
Author

using logic:iterate index with html:multibox

Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

hi all,

Can I use logic:iterate's indexId to give a index number to the all values we are using in html:multibox .

in other words, the senario is like this.



where selectedItems is declared as a String array in form bean.
As code say orderid,publication and edition comming from back end of mediaorder class.

now the problem is i want to print the selected values through checkboxes in some other jsps.

please help me.

regards,
rahul
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Here's one possible solution: Change the JSP so that only orderid is used as the value of the multibox, provided orderid will uniquely identify the order. When the form is submitted, you will then have a String array containing order Ids. At that point, you can query the database to get the rest of the information for each order, populate an order POJO for each, and create an ArrayList of order POJOs that can be used in other JSPs.

Yes, I know you already queried the database to get this information before, but if you've coded your model layer efficiently and are using a well-tuned database, re-getting the information from the database will be fast and will not significantly affect your response time.


Merrill
Consultant, Sima Solutions
Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

Mr. Merrill Higginson,

Using String array I can print the selected values in different pages.
But after putting into string array how can we retrive them as we put them into it. in other words, if i want to print coloumns like orderid publication, edition then this string array can not solve this problems, i guess. And if we want add the data in the back end for the selectd values, then it would become very difficult to solve it.

So is there any solution for this.

regards,
rahul


Originally posted by Merrill Higginson:
Here's one possible solution: Change the JSP so that only orderid is used as the value of the multibox, provided orderid will uniquely identify the order. When the form is submitted, you will then have a String array containing order Ids. At that point, you can query the database to get the rest of the information for each order, populate an order POJO for each, and create an ArrayList of order POJOs that can be used in other JSPs.

Yes, I know you already queried the database to get this information before, but if you've coded your model layer efficiently and are using a well-tuned database, re-getting the information from the database will be fast and will not significantly affect your response time.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Rauhl Roy:
Using String array I can print the selected values in different pages.
But after putting into string array how can we retrive them as we put them into it.

If the values are of a fixed length, you can use the String class's substring method to separate the values from a single string into multiple strings. If the values are not of a fixed length, you could put some sort of separator character between each value. Then when it's time to display the values separately, use the separator character to tell where one value ends and the other begins.

Originally posted by Rauhl Roy:
And if we want add the data in the back end for the selectd values, then it would become very difficult to solve it.

I'm not suggesting you add any data in the back end. I'm simply suggesting that you retrieve the data that's already there in the back end again, rather than trying to pass it through a composite string.

While parsing through this composite string will work, it seems really awkward and "kludgy" to me, and I wouldn't call it very good Object Oriented design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using logic:iterate index with html:multibox