Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 21407 invoked from network); 28 Jul 2006 21:42:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Jul 2006 21:42:08 -0000 Received: (qmail 6416 invoked by uid 500); 28 Jul 2006 21:41:58 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 6369 invoked by uid 500); 28 Jul 2006 21:41:58 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 6356 invoked by uid 99); 28 Jul 2006 21:41:58 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jul 2006 14:41:58 -0700 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [206.190.48.208] (HELO web52605.mail.yahoo.com) (206.190.48.208) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 28 Jul 2006 14:41:57 -0700 Received: (qmail 508 invoked by uid 60001); 28 Jul 2006 21:41:36 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=rx8z9umAq1MGtivaH2PzjtQ3rA7vh+sC6o7NWUxvQnYUletx/0TZjrH9qDCEQfsCmf6wD4wywbcyckgB7TcRT+qJIxGRaPUfuPTcqVQhyVPhCQIL2gbK/eHAMieZzdE3nW2L7vDVa+3Q5giIlr07U6yZmToiWcD50j/5/fuurAw= ; Message-ID: <20060728214136.506.qmail@web52605.mail.yahoo.com> Received: from [65.246.156.126] by web52605.mail.yahoo.com via HTTP; Fri, 28 Jul 2006 14:41:36 PDT Date: Fri, 28 Jul 2006 14:41:36 -0700 (PDT) From: Caroline Jen Subject: Pagination and Memorizing Marked Checkboxes To: user@struts.apache.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I display a List of objects. Because the List can be very long, I use a pagination tag library to display my long list 10 at a time. This taglib is not a front-end one. The taglib makes a trip to the back end to retrieve the next 10 records from the database when the next pagination link is clicked. Each object is with a checkbox attached. and this is the way I code it: [code] [/code] Clients may navigate page by page to mark certain checkboxes in each page. And I have to make sure that all marked checkboxes are kept in memory when clients finally click on the 'Submit' button. The way that I code my form may not be right: [code] ..... ..... public class SelectUsersForm extends ActionForm { private Map selectedUserFieldMap = new HashMap(); private String[] selectedUsers = new String[0]; private String[] selectedUserIDs; public SelectedUserField getSelectedUsers( int index ) { SelectedUserField selectedUserField = ( SelectedUserField )selectedUserFieldMap.get( new Integer( index ) ); if ( selectedUserField == null ) { selectedUserField = new SelectedUserField(); selectedUserFieldMap.put( new Integer( index ), selectedUserField ); } return selectedUserField; } // Convenience method to get a list of selected user IDs. public String[] getSelectedUserIDs() { List theUserIDList = new ArrayList(); Iterator i = selectedUserFieldMap.values().iterator(); while( i.hasNext() ) { SelectedUserField selectedUserField = ( SelectedUserField ) i.next(); if ( selectedUserField.isSelected() ) { theUserIDList.add( selectedUserField.getId() ); } } return ( String[] )theUserIDList.toArray( new String[theUserIDList.size()] ); } public void reset( ActionMapping mapping, HttpServletRequest request) { selectedUsers = new String[0]; selectedUserIDs = new String[0]; } } [/code] and the SelectedUserField.java is like: [code] package gov.cbp.ace.st.tf.web.admin.form; import java.sql.Timestamp; public class SelectedUserField { private boolean selected = false; private Long id; public Long getId() { return id; } public void setId( Long newValue ) { id = newValue; } public boolean isSelected() { return selected; } public void setSelected( boolean newValue ) { selected = newValue; } } [/code] __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org