wood burning stoves 2.0*
The moose likes Struts and the fly likes Html form to form bean mapping, multiple checkboxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Html form to form bean mapping, multiple checkboxes" Watch "Html form to form bean mapping, multiple checkboxes" New topic
Author

Html form to form bean mapping, multiple checkboxes

Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
Hello,

I have an html form and need to map it to a form object to be sent to action. The html form is like:
  • There are multiple rows.
  • Each row has a checkbox in the first column.
  • Second column has a name
  • Third column has a list of checkboxes


  • It is like a normal form that lists a series of records and certain operations can be performed upon multiple records, depending upon which rows have been checked.

    A unique ID is associated to each row.

    Here is what I've thought:
    The value of checkbox in first column can be the ID and this can be mapped to an array in the form bean.
    The checkboxes in column 3 can have same name, say chkAttr for all rows, and value as "ID_1", "ID_2" etc.
    This can be mapped to a String [] chkAttr in form bean.

    In this way I'll have to write a logic to get the values pertaining to a particular ID from chkAttr[].

    This is one approach. Is there a better way?

    PS: I don't know Struts, just saw the application flow and applying logic.

    Regards


    Experience and talent are independent of age
    Himanshu Kansal
    Ranch Hand

    Joined: Jul 05, 2009
    Posts: 257
    Does anyone have any comments on this?

    I would like to know how forms of this type are mapped in struts. I know how to do it best in plain JSPs.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Html form to form bean mapping, multiple checkboxes
     
    Similar Threads
    Deleting a row dynamically
    Loading DB data when web app context initialized
    Best option to update only selected rows form Struts2
    Maintain table checkboxes state after sorting
    how to delete the rows which are checked