Jignesh Kapadia <[EMAIL PROTECTED]> wrote on 08/22/2004 
10:37:24 PM:

> Jim,
>      Thanks for you reply. But I really don't want to clear all my 
> check boxes.
>

Jignesh, 

Don't forget that the reset() does its thing before the formbean gets 
populated. So, if your formbean property contains values, then the form 
will be populated with them. Setting all checkboxes to false during the 
reset() resolves an HTML processing issue. There is a *lot* about this in 
the archives. 

 
>                 When I display my list for the first time I want to 
> show the checkboxes checked or unchecked depending on the boolean 
> value of one of the attribute of iterating object.
>

I have lost track at which point you are actually stuck on. Although you 
say above what you *want* to show on your first page, I thought you had 
done this successfully. 

> Say my page displays first 25 records. I have "Next" button on 
> screen to view next 25 records and so on. I check some boxes on the 
> first screen and click the "Next " button. 
>              On second screen I check some more records. On this 
> screen I have a "Previous" button to go back to first 25 records. 
> When I click "Previous" button then it will take me to the first 
> screen and it should remember my previous changes and not showing 
> screen with all records unchecked.(which happens in normal behaviour
> due to Reset method of form where we set checkbox property to false.)

A question for you is, does everything work correctly without the paging 
added in? If you display all the data rows on your first page in one long 
page, then change your checkbox values and submit, does your second page 
list out only the checked items that were submitted (if that is in fact 
your ultimate goal)? Once that is working, then you know you're doing the 
checkboxes right. Then add in the paging. Unless you are saving your 
true/false field data to a (formbean) property in the session, naturally 
the data gets lost going from page to page ( from request to request). 

> 
> How do I achieve the above?

I would not do this with pure Struts tags, I'd use the Display Tag library 

http://sourceforge.net/projects/displaytag

It works very nicely with Struts. I haven't used this library for what you 
require, but I believe that others have (rows containing checkboxes and 
paging).

> 
> Also we are using Dynaforms here. Can I still have the form class 
> with reset method?

Yes, you can subclass any type of action formbean to add to its methods.

Hope that helps,
Susan Bradeen

> 
> This is little bit different then normal use of check box in struts.
> Can you please guide me here.
> 
> Thanks and Appreciate your help,
> Jignesh 
> 
> 
> 
> 
> 
> Jim Barrows <[EMAIL PROTECTED]> wrote:
> 
> 
> > -----Original Message-----
> > From: Jignesh Kapadia [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, August 19, 2004 5:19 PM
> > To: Struts Users Mailing List
> > Subject: Re: dealing with check boxes
> > 
> > 
> > Anuj,
> > Thanks for you reply. But My concern is as follows.
> > 
> > e.g. 
> > 
> > I display these records with checkbox on my JSP as follows
> > > property="Name of the property">
> > 
> > 
> > .... 
> > 
> > 
> > In this case "list" is id on which is going to iterate. 
> > chkflag is the boolean property of an object contained in the 
> > list(can be collection or arraylist). depending on this it is 
> > going to decide whether the checkbox should be checked or not.
> > 
> > Now How do I capture these changes which I do on the 
> > screen(checking and unchecking of check boxes) in my Action 
> > class so that it can be store the changes and display them 
> > when I come back to the same screen.
> > 
> > Let me know if still it is not clear.
> 
> Read the tutorials and you'll get a better idea of how to do this.
> Make sure that you have the reset method changing all your 
> checkboxes to false. That's a key piece most people miss.
> As with every other field in a struts form, you don't have to do 
> anything, except as I mentioned above.
> If you aren't using a form, then the browser only sends those boxes 
> that are checked (iirc). Which means all kinds of fun will ensue.
> 
> > 
> > Thanks,
> > Jignesh
> > 
> > [EMAIL PROTECTED] wrote:
> > 
> > 
> > Jignesh,
> > 
> > I think your problem is not related to checkbox or multibox 
> > but to maintain a
> > list of modified records. To keep it simple I would suggest 
> > that you maintain a
> > Collection (Map, HashMap, List, etc.) of the modified records 
> > (which were
> > checked or unchecked) in the session. I think you can 
> > identify the records that
> > are modified on each page so just put them in the collection 
> > and put the
> > collection in session so that you have it for all the pages. 
> > Update your list
> > that you display in the jsp to include the checked state from 
> > this collection if
> > the record is modified while you move back and forth pages.
> > 
> > In your submit action you want to display the checked 
> > records, so filter and
> > display the records in your collection that have checked=true.
> > 
> > Finally update the records in your collection to the 
> > database. If I understand
> > correctly you want to update the checked state (checked and 
> > unchecked records).
> > 
> > I hope that helps.
> > Anuj


_____________________________________________________________________________
Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services 
powered by MessageLabs. 
_____________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to