access java object in javascript
<p>I am using spring framework. I am passing java bean object as model attribute to JSP. On JSP I am calling a javascript function passing this java bean object. I need to access memebers of this object inside the javascript. below is the code snippet</p>

<pre><code>Test.jsp
..
..
&lt;form:radiobutton id="showdialog" path="nextAction" value="showdialog" label="show dialog" 
    onclick="javascript: showDiseaseGroupDialog('${dataRequestFormDTO}');"/&gt;&lt;/span&gt;&lt;/div&gt;
..
..

Common.js
function showDiseaseGroupDialog(dataRequestFormDTO){

    alert("DG:"+dataRequestFormDTO.selectedDiseaseGroup);
    for(var diseaseGroupDTO in dataRequestFormDTO.availableDiseaseGroups.values){
        alert(diseaseGroupDTO.name);
    }
}

DataRequestFormDTO.java
public class DataRequestFormDTO{
    private String selectedDiseaseGroup;
    private Map&lt;String, DiseaseGroupDTO&gt; availableDiseaseGroups;

    public String getSelectedDiseaseGroup() {
        return selectedDiseaseGroups;
    }

    public void setSelectedDiseaseGroup(String selectedDiseaseGroup) {
        this.selectedDiseaseGroup = selectedDiseaseGroup;
    }

    public Map&lt;String, DiseaseGroupDTO&gt; getAvailableDiseaseGroups() {
        return availableDiseaseGroups;
    }

    public void setAvailableDiseaseGroups(
            Map&lt;String, DiseaseGroupDTO&gt; 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;
    }

}
</code></pre>

<p>Problem is I am getting error in showDiseaseGroupDialog function. First alert displays "DG:undefined" and javascript error "availableDiseaseGroups is undefined".</p>

<p>I want to understand </p>

<ol>
<li><p>Why java bean members are not accessible in javascript? Though in jsp I can print the same values.</p></li>
<li><p>how hashmap/arraylist can access in javascript?</p></li>
</ol>
