开发者

JQuery dialog to show list of the items to be selected

开发者 https://www.devze.com 2023-03-28 22:13 出处:网络
I am using spring framework 3 in my application. I have list of items to be shown in the dialog using JQuery. This dialog opens on click of link in the jsp page. These items need to be shown in check

I am using spring framework 3 in my application. I have list of items to be shown in the dialog using JQuery. This dialog opens on click of link in the jsp page. These items need to be shown in check box list. User can select these items which I need to capture on the page. The item list is dynamic and I can access it using the list(model attribute) on the JSP page. I have code to show jquery dialog but I am stuck at how to show check box list in it. Please suggest some examples to implement this. Below is the code I am using Test.jsp

<script type="text/javascript">
$(document).ready(function() {
        $('#diseaseGroup_dialog').hide();
    }
</script>
..
..
<form:radiobutton id="showdialog" path="nextAction" value="showdialog" label="show dialog" 
    onclick="javascript: showDiseaseGroupDialog('${dataRequestFormDTO}');"/></span></div>
<div id="diseaseGroup_dialog" title="Select Appropriate Disease Group">
    <table id="diseaseGroup_dialog_content" class="display">
        <tbody style="text-align:left">
            <tr>
                <td>Disease group list</td>
            </tr>
        </tbody>
    </table>
</div>
..
开发者_如何转开发..

Common.js

function showDiseaseGroupDialog(dataRequestFormDTO){
    $('#diseaseGroup_dialog').dialog({
        height: 340,
        width: 660,
        minWidth: 650,
        modal: true,
        open: function(event, ui) {
            $('#diseaseGroup_dialog_content').append(" I have added this when it opened");
        }
    });
    $('#diseaseGroup_dialog').show();
}

Java beans are passed as Model attribute.

DataRequestFormDTO.java
public class DataRequestFormDTO{
    private String[] selectedDiseaseGroups;
    private Map<String, DiseaseGroupDTO> availableDiseaseGroups;

    public String[] getSelectedDiseaseGroups() {
        return selectedDiseaseGroups;
    }

    public void setSelectedDiseaseGroups(String[] selectedDiseaseGroups) {
        this.selectedDiseaseGroups = selectedDiseaseGroups;
    }

    public Map<String, DiseaseGroupDTO> getAvailableDiseaseGroups() {
        return availableDiseaseGroups;
    }

    public void setAvailableDiseaseGroups(
            Map<String, DiseaseGroupDTO> availableDiseaseGroups) {
        this.availableDiseaseGroups = availableDiseaseGroups;
    }
}

public class DiseaseGroupDTO {

    private String id;
    private String name;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消