There ya go!  I knew you'd see my problem ;-)

So I could have a form that contains:

  String[] checkedItemsRender; // Rendered collection
  String[] checkedItemsSubmit; // Submitted collection
  LabelValueBean[] pageItems; // data/id to show in form

Then the form takes the checkedItemsRender and creates hidden fields in the form for 
each "value" contained in this array.  Then using multibox, the checkedItemsSubmit 
array creates checked/unchecked boxes using the value from the pageItems collection 
and prints out the label from the pageItems collection too.

When the form gets submitted, I have a String[] checkedItemsRender that have only the 
rendered collection of checked values, String[] checkedItemsSubmit that have only the 
submitted checked data items and the pageItems is of no importance since it is used 
only for display purposes.

During each submission (regardless if its to save the current page or jump to a 
particular page (prev/next)), the logic would then be:
  Add items from checkedItemsSubmit String[] that do not already exist in 
checkedItemsRender and then remove from checkedItemsRender those which do not exist in 
checkedItemsS.  The result would be in checkedItemsRender and checkedItemsSubmit can 
be cleared as it is no longer of importance.
I can then start the process over again but each time, I just need to make sure that 
whatever values are in checkedItemsRender are replicated into checkedItemsSubmit prior 
to rendering the form in my JSP.  

The great thing about the above is that if I want to handle all the above logic in a 
seperate form outside my "session-scoped" search form I can and this form can be 
request/session scoped and in either case it will work and behave the same.  Will work 
and lend itself very well to our application since we use this functionality for a lot 
of popup listboxes the user can select from and close.

Let me know if you see any holes in this because I haven't tested it but sounds like 
it might work ;-)
  ----- Original Message ----- 
  From: [EMAIL PROTECTED] 
  To: Struts Users Mailing List 
  Sent: Wednesday, June 16, 2004 4:35 PM
  Subject: Re: Resultsets and multi-check forms



  Ah ha.  I think I just understood the real problem; each subsequent submission of 
the form wipes out the current collection of selected checkboxes.  If that's your 
problem, then I believe you're going to have to modify the way you're modelling the 
collection of as well as the behavior of the accessor/mutator.  In Teds example, the 
Multibox is backed by a String[], however, you're probably going to have to back it 
with a Collection, allowing you to grow/shrink as your user selects/deselects. 

  Dennis 




        Dennis Graham/EvergreenFunds 
        06/16/2004 04:22 PM 
       To "Struts Users Mailing List" <[EMAIL PROTECTED]>  
              cc  
              Subject Re: Resultsets and multi-check formsLink 

              

       


  Sounds like you're describing a struts Multibox: 
  http://jakarta.apache.org/struts/userGuide/struts-html.html#multibox 

  Ted Husted has a nice intro here: 
  http://www.jguru.com/faq/view.jsp?EID=925277 

  Dennis 
    


        "Chris Cranford" <[EMAIL PROTECTED]> 
        06/16/2004 04:06 PM Please respond to
              "Struts Users Mailing List" <[EMAIL PROTECTED]> 


       To "Struts Users Mailing List" <[EMAIL PROTECTED]>  
              cc  
              Subject Re: Resultsets and multi-check forms 

              

       



  Sort-of Yes.

  We never really "persist" what is selected to any layer beyond the form because 
we're only gathering attributes that which are provided to our "search" action once 
all the selectable attributes.

  So from a technical use-case perspective I understand that:

  1. Form session scoped for simplicity with collection of record_ids (initially empty)
  2. Go to database to get records (!-10) since page requested is initially 1
  3. Skip preselection step since record_ids collection.size() == 0
  4. Render Form

  5. User selects items 1 and 3 and submits form via next page link
  6. Since record_ids collection size() == 0, populate collection with selections 1 
and 3.
  7. Go to database to get records (11-20) since page requested is 2
  8. Loop through collection to preselect -- again nothing done here
  9. Render Form

  10. User selects 15 and submits via next page link.

  Here is where I get tripped up because in this case I would just need to add 15 to 
the selection array in my form, but technically it is possible then that once they 
view results 21-30, hit prev page I should show 15 as selected.  If they unselect 15 
and either dont select anything or select another record, how do I track this?

  Maybe I'm creating my form incorrectly using the wrong type of tag to manage my 
selection list/boxes.  Sorry, just been up too long without sleep and this is probably 
something very trivial that I'm overlooking.

  Thanks in advance!
   ----- Original Message ----- 
   From: [EMAIL PROTECTED] 
   To: Struts Users Mailing List 
   Sent: Wednesday, June 16, 2004 3:42 PM
   Subject: Re: Resultsets and multi-check forms



   You might want to re-present the problem.  When I read your email, it seemed like 
you were describing a typical use-case: 

   1. Get data from a persistent store 
   2. Populate form.  If attribute indicates "selected", preselect checkbox 
   3. Render form (allowing user to edit) 
   4. Persist edits. 

   Dennis 



         "Chris Cranford" <[EMAIL PROTECTED]> 
         06/16/2004 03:35 PM Please respond to
               "Struts Users Mailing List" <[EMAIL PROTECTED]> 


        To <[EMAIL PROTECTED]>  
               cc  
               Subject Re: Resultsets and multi-check forms 

               

        



   I haven't seen any comments on this .. any ideas?

   > To broaden the prior discussion on resultset caching, I'd like to also
   ping
   > the group on the concept of being able to have this "resultset" of data
   and
   > paging through it but extendeding it to where a checkbox exists for each
   > viewable record.  I need to be able to pre-select values from a database
   > ahead of time based on past settings and permit them to page through the
   > resultset setting all their new values to finally accepting those and
   > writing them back to the database when the user hits the "Save" button.




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





  ------------------------------------------------------------------------------


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





------------------------------------------------------------------------------


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

Reply via email to