This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.
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.
Joined: Aug 20, 2003
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
Joined: Feb 08, 2006
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.
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)
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
Anyway I had the same problem you did, and I was able to solve it this way:
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.