Programming Tutorials

(追記) (追記ここまで)

Using Multibox in Struts

By: Ivan Lim in Struts Tutorials on 2007年09月22日 [フレーム]

Multibox is a collection of checkbox. When a single checkbox exists, it should be mapped to a Boolean. Such condition does not apply to collection of checkboxes. Here we map it to a String array

  1. Recall that Checkbox cannot exist outside a form. Hence start by defining a form to handle the
    checkboxes around the search display list as follows (Simplified for clarity):

    <html:form action="/manageCustomerList">

    <c:if test='${not empty CUSTOMER_SUMMARY_OBJECTS}'>
    ..
    <html-el:multibox property="idSelections">
    <c:out value='${customer.id}'/>
    </html-el:multibox>

    ..
    </c:if>
    </html:form>
  2. Define ManageCustomersForm to hold the checkbox information and initialize the string array
    as follows.

    public class ManageCustomersForm extends ActionForm {
    private String[] idSelections;
    //getters and setters
    public ManageCustomersForm() {
    init();
    }
    protected void init() {
    idSelections = new String[] { "" };
    }
    ..
    }
  3. Create a ManageCustomersAction to handle it in the package struts.example.search. Leave its execute() method empty.
  4. Add an ActionMapping in struts-config.xml. to associate /manageCustomerList.do with
    ManageCustomersAction and ManageCustomersForm Build Deploy and See how the page displays at this point. This should give you a clear picture of using multibox.



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /