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 ?
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:
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 <CustReleaseDetailsForm>lst_collist = new ArrayList<CustReleaseDetailsForm>();
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("");
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 :-
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 set1 = new java.util.ArrayList();
HashMap map = new HashMap();
CustReleaseDetailsForm custDetForm = new CustReleaseDetailsForm();
set1.add(map);
model.put("relDetails", set1);
Please reply guys.....I am eagerly wating the reply.....
Any help would be appreciated.....
Thanks,
Uday
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:
<display:table name="sessionScope.someMap" export="true" id="tmpId"
class="dataTable" defaultorder="ascending" cellspacing="1" >
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>();
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);
//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 :-
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....
I am still struck with the same problem...
I am awaiting your reply...
Does any one has any suggestions..
Hi, I am facing the same problem. Please let me know if you were able to
resolve the issue.
Thanks
Pankaj