Dynamically binding lists with Spring's form tag

后端 未结 1 1056
误落风尘
误落风尘 2021-02-03 11:48

I have a command object FaxForm and it holds a list of FaxStatus objects inside a faxStatusList property.

public class F         


        
相关标签:
1条回答
  • 2021-02-03 12:07

    Spring form tags has a checkboxes tag. You can use it as follows to do the binding automatically:

    <form:checkboxes items="${faxStatusList}" path="faxStatusList" itemLabel="name" itemValue="id" delimiter="<br/>" onclick="yourOnClickMethodIfYouNeed(this);"/>
    

    The above snippet will display a list of checkbox items delimited with the br tag. Any changes made to the state of the checkboxes will be reflected appropriately in your FaxForm. faxStatusList object.

    0 讨论(0)
提交回复
热议问题