Menu

Display Tag with Hash Map Not Working

Help
uday36
2009-06-24
2012-10-09
  • uday36

    uday36 - 2009-06-24

    Hello Friends,

    I am facing trouble using Hash Map with Display Tag.
    I have build a Hashmap whose key will contain Date and value would contain a List.
    Then I have put this Map into a List.
    Now In the view, I want to display Map key(i.e Date) as Header of the column and Map value (i.e List in my case) as rows in that column.

    Does Any one has idea of the Display tag syntax to be used ?

    Thanx

    Here is my .jsp code snippet:-

    <display:table name="relDetails" id="items" requestURI ="custReleaseDetails.htm" uid ="releaseDetails" class="allTableStyle1" >

    <display:column property="column_Con" title=" " />

    <core:forEach var="cl" items="${relDetails}" >

    <display:column property="${key}" title="${value}" />

    </core:forEach>

    </display:table>

    Code snippet in the Controller class :-

    List&lt;CustReleaseDetailsForm&gt; lstFormcustDetails = new ArrayList&lt;CustReleaseDetailsForm&gt;();
    

    List set1 = new java.util.ArrayList();

    HashMap map = new HashMap();

    CustReleaseDetailsForm custDetForm = new CustReleaseDetailsForm();

            if(i==0)
            {
        Date a = new Date(2009,01,01);
         custDetForm.setQty1(50);
            custDetForm.setQty2(50);
            custDetForm.setQty3(50);
            custDetForm.setQty4(50);
                        lstFormcustDetails.add(custDetForm);
    
    map.put(a, lstFormcustDetails);
    

    set1.add(map);
    model.put("relDetails", set1);

     
    • uday36

      uday36 - 2009-07-03

      Please reply guys.....I am eagerly wating the reply.....
      Any help would be appreciated.....

      Thanks,
      Uday

       
    • wecansolveit.org

      I have never used Map, but let me get back to you later tomorrow with map. But with any datasource (map, list,...) you should be able to work on multiple lists, with one giving your the title name and the other giving you the property or key of the list or map respectively as follows:

          &lt;bean:define id=&quot;someMapId&quot; name=&quot;formBeanName&quot;
              property=&quot;mapProperty&quot; type=&quot;java.util.Map&quot;&gt;
          &lt;/bean:define&gt;
      

      <display:table name="sessionScope.someMap" export="true" id="tmpId"
      class="dataTable" defaultorder="ascending" cellspacing="1" >

          &lt;logic:iterate id=&quot;someListId&quot; name=&quot;formBeanName&quot;
              property=&quot;listPropertyToIterate&quot; type=&quot;database.ListObject&quot; indexId=&quot;indexId&quot;&gt;
      
              &lt;display:column
                  title=&quot;&lt;%= someListId.getFieldLabel() %&gt;&quot;
                  property=&quot;&lt;%= someListId.getFieldNameToBeLookedUpInMap or get property Name%&gt;&quot;
                  /&gt;
          &lt;/logic:iterate&gt;
      
      &lt;/display:table&gt;
      
       
      • uday36

        uday36 - 2009-06-26

        Thanks for ur Reply Chikkubhai...

        But I am still not clear with the HashMap syntax to be used...

        public Map<String, Object> referenceData(HttpServletRequest request) {
        Map<String, Object> model = new HashMap<String, Object>();

        List<CustReleaseDetailsForm> lstFormcustDetails = new ArrayList<CustReleaseDetailsForm>();

            List &lt;CustReleaseDetailsForm&gt;lst_collist = new ArrayList&lt;CustReleaseDetailsForm&gt;();
        

        HashMap map = new HashMap();

        for(int i = 0; i < 6; i++) {

        CustReleaseDetailsForm custDetForm = new CustReleaseDetailsForm();

        if(i==0)
        {
        custDetForm.setColumn_Con("");
        Date a = new Date(2009,01,01);
        custDetForm.setDemandQty(50);
        custDetForm.setCommitQty(50);
        custDetForm.setMajStock(-10);
        custDetForm.setMinStock(10);
        custDetForm.setOverStock(50);
        lstFormcustDetails.add(custDetForm);

        map.put(a, lstFormcustDetails);
        
        }
        if(i==1)
            {
        custDetForm.setColumn_Con(&quot;&quot;);
        Date b = new Date(2009,02,01);
        custDetForm.setDemandQty(50);
        custDetForm.setCommitQty(50);
        custDetForm.setMajStock(-10);
        custDetForm.setMinStock(10);
        custDetForm.setOverStock(50);
        lstFormcustDetails.add(custDetForm);
        
        map.put(b, lstFormcustDetails);
        

        //Note currently I am hardcoding the values to be displayed...But in actual these values will be coming from the database.

        }

        Now I want to get these values displayed in tabular format as below :-

               01/01/2009    01/02/2009  And so on....
        

        DemandQty 50 50
        CommitQty 50 50
        MajStock -10 -10
        MinStock 10 10
        OverStock 50 50

        .JSP File Code Snippet:-

        <display:table name="relDetails" id="items" requestURI ="custIt.htm" class="allTableStyle1" >

        <display:column property="column_Con" title=" " />

        <core:forEach var="cl" items="${relDetails}" >

        <display:column property="${c1}" title="${c1}/>

        </core:forEach>

        </display:table>

        I am confused with what should be the property and title attriburte of display:column tag....

         
    • uday36

      uday36 - 2009-07-01

      I am still struck with the same problem...
      I am awaiting your reply...
      Does any one has any suggestions..

       
  • pankaj jain

    pankaj jain - 2009-11-18

    Hi, I am facing the same problem. Please let me know if you were able to
    resolve the issue.

    Thanks
    Pankaj

     

Log in to post a comment.

MongoDB Logo MongoDB