File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Display tag and Struts multibox tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Display tag and Struts multibox tag" Watch "Display tag and Struts multibox tag" New topic

Display tag and Struts multibox tag

Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
I am working on an application that uses Display Tag to render tables. In some of the tables, I am using the Struts tag "multibox" to render a list of options. I am having a problem with the checkboxs not holding the values after clicking the next page on the table.

Let me explain. Form example, if there are 100 records and the <pagesize> attribute -in the display tag decleration- set to "10", then there are 10 records shown at a time. When the user click on the little arrow on the top of the table, the table check out the next ten records.

Now, if I have a column of check boxes, when a user check some boxes and then click next arrow - to choose from the next values- the previous selection disappears.

How can I save the user selections?
Her are a snipet of the code from the JSP page

<display:table name="metadataList" export="true" id="row" requestURI="/" pagesize="10" class="display_tag">

<bean efine name="row" property="metadataId" id="metadataId"/>
<display:column sortable="false" title="Select" media="html">
<html:multibox name="PublishingForm" property="selectedMetadataIds" value="<%= String.valueOf(metadataId) %>" />

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Moved to the Struts forum.

[Asking smart questions] [About Bear] [Books by Bear]
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
anybody has any idea. I can't be the only one who wants to do this?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Many of us who hang out at this forum have a lot of experience with Struts, but I don't think there are many of us who use the display tag library. I'm guessing your problem has to do more with the display tag than it does with Struts.

I know this sounds like passing the buck, but I think you might have better luck getting an answer to this in a forum dedicated to the display tag library. Try this link.

Consultant, Sima Solutions
Eric Gero
Ranch Hand

Joined: Jul 20, 2005
Posts: 73
Originally posted by Merrill Higginson:
[qb]Many of us who hang out at this forum have a lot of experience with Struts, but I don't think there are many of us who use the display tag library.

What tag libraries do most people here use? I see there are different options out there, and would like to get up to speed on the best, most popular.

[ March 26, 2006: Message edited by: Eric Gero ]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Now that I re-read your question, it sounds similar to an issue that we had in my project a while back. We are not using the Display Tag library, but it is the same issue. I hate to admit that we pushed back and got the requirements simplified so that a user's selection did not have to persist across multiple pages. This was a page where an end user would select people to add to a group. The end user would have to select users on one page and click the add button, or click the "view all results" link where they could see all the users on a single page.

To implement this you would have to wrap your page in a html:form tag and submit the page when the user clicked one of the page links. I am not sure if it would be best to keep your ActionForm in session, to keep selections from previous pages in hidden fields on the jsp or to implement logic that would process the submitted set of selection and build a master list of all selected items and save that in session.

- Brent
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
Brent Sterling,
The problem is that display:tag paging function doesn't populate and sumbit the form fields. What I mean is, if you have input fields, ie. checkbox, which are associated with a form bean, and when I click on next page, a function provided by display:tag, the value of the fields are not sumbited. So, I can't catch them and save tham in let say a session object.

Thank you for replaying
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Yea, that is the basic reason that we got that requirement removed...we did not see an easy way to support that functionality within our paging and searching framework. We are using the "Pager Tab Library" and I don't think it really has support for submitting forms either. I am sure it is possible, but I am not sure how.

- Brent
Liju Cherian
Ranch Hand

Joined: Mar 17, 2006
Posts: 44

I'm not sure if u still have this problem persisting, or if my solution might help u; why don't u try keeping the form bean associated with that action into the session, by changing the entry in the struts-config.xml file's <action> tag.

Hope this helps.


"What's in a name? That which we call a rose by any other name would smell just as sweet."<br />(William Shakespeare, Romeo and Juliet, Act II, Scene II)
Mike Moser

Joined: Apr 10, 2006
Posts: 1
Hey I found a way to do this although the implementation is a bit choppy and my users are asking me to do this in another way. Before I get into my fix though I want to point out that the attribute in the tag can be set to your action and the display tag library has ways to add your column data to the request if you use the
Smart Linking

Anyway I had the same problem you did, and I was able to solve it this way:

One of the developers created a Selection class that is essentially wrapper class that adds a boolean value to a bean. I store a collection of MyObjectSelection beans in the ActionForm. The MyObject objects generally store a unique identifier so I can use that to build my checkbox name. Then I add a javascript onclick handler to the page so that it will take my identifer and submit the form with the identifier. I'm using DispatchActions so I have to set the action parameter to "update." The update method then toggles the selected value on the MyObjectSelection bean. Of course when I load the page I have to check the selected value first. Here is the JSP code:

I have a hidden form object called "selectedObj" but it isn't a Struts Form object. The update method finds the selectedObj value in the collection and just toggles the selected property.
I agree. Here's the link:
subject: Display tag and Struts multibox tag
It's not a secret anymore!