I am having problems with multiple DisplayTag-el tables on the one html page. Or rather, I am having problems when there are 'n' numbers of tables. I can quite easily create two staticly named tables using uid="row1" for the first table and uid="row2" for a second table and so on.
However, I currently have a forEach loop around my display tag tables and I am struggling with how I can generate unique uids and then reference them:
For example each loop generates a unique id in 'prop2' and then displays the table using the following:
<display-el:column title="Code" sortable="true" headerClass="sortable">
<c:out value=" * What to do here " />
</display-el:column>
<display-el:column title="Description" sortable="true" headerClass="sortable" >
<c:out value=" What to do here *" />
</display-el:column>
</display-el:table>
</ajax:displayTag>
Please see the "* What to do here ***" flags? Previously I just had uid="row1" and then used 'row1.code', 'row.description' etc to reference the object fields.
Is it possible to use some other default name for the "current row", like <c:out value="${uid.code}" />
I've tried all sorts of things like <c:out value="${<%=prop2%>.code}" /> which don't work (nor did I expect that they would).
Any help would be greatly greatly appreciated. I am amazed at this project so far and it has solved so many of my other problems.
Kind regards,
David Molloy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have had some success thanks to both you and Yannick. Certainly, the property attribute works for some of the fields I am trying to display. However, others have some HTML decoration around them, such as dynamically coloring particular values etc. So the <c:out> tag would give me some facility to display this information without a table decorator (not sure how to use these as I haven't had to yet either). So I now have some fields referencing with properties and they work perfectly.
The other message from Yannick sorted me out for the other fields. Here is some "working" code (reason for quotes below):
<c:set var="rowstyle" value='student1' />
<% int count = 0; %>
The reason I say "working" is because it works to some extent. Each of the tables displays and looking at the source, they all have default divs, such as shown below:
All of the tables independently export correctly and they look great! When I sort the first table, it all works flawlessly. But when I try to sort any of the subsequent tables, they get overwritten with the data from the first table.
I'm not sure at all how to fix this - I had assumed that giving a unique id 'ajaxflag1', 'ajaxflag2', etc. would be enough - but this doesn't appear to be the case.
Many thanks for the help so far to get me here. Perhaps, I'm venturing into ajaxtags territory now though.
Has anyone successfully gotten multiple tables sorting and exporting using Ajaxtags?
Many thanks,
David Molloy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am having problems with multiple DisplayTag-el tables on the one html page. Or rather, I am having problems when there are 'n' numbers of tables. I can quite easily create two staticly named tables using uid="row1" for the first table and uid="row2" for a second table and so on.
However, I currently have a forEach loop around my display tag tables and I am struggling with how I can generate unique uids and then reference them:
For example each loop generates a unique id in 'prop2' and then displays the table using the following:
<ajax:displayTag id="<%= prop2 %>" ajaxFlag="displayAjax">
<display-el:table requestURI="broadsheet/broadsheet_programme_body.jsp" name="${student.broadsheetModuleResultsVector}" class="displaytag" defaultsort="2" defaultorder="ascending" export="true" uid="<%= prop2 %>" excludedParams="ajax">
<display-el:column title="Code" sortable="true" headerClass="sortable">
<c:out value=" * What to do here " />
</display-el:column>
<display-el:column title="Description" sortable="true" headerClass="sortable" >
<c:out value=" What to do here *" />
</display-el:column>
</display-el:table>
</ajax:displayTag>
Please see the "* What to do here ***" flags? Previously I just had uid="row1" and then used 'row1.code', 'row.description' etc to reference the object fields.
Is it possible to use some other default name for the "current row", like <c:out value="${uid.code}" />
I've tried all sorts of things like <c:out value="${<%=prop2%>.code}" /> which don't work (nor did I expect that they would).
Any help would be greatly greatly appreciated. I am amazed at this project so far and it has solved so many of my other problems.
Kind regards,
David Molloy
Do you have to use the <c:out> tag? If you could use the property attribute of the display-el:column you wouldn't need to reference the uid at all:
<display-el:table uid="<%= prop2 %>" >
<display-el:column property="code" title="Code" sortable="true"/>
<display-el:column property="description" title="Description" sortable="true"/>
</display-el:table>
should work unless I've missed something obvious.
Ed!
Hi,
I have had some success thanks to both you and Yannick. Certainly, the property attribute works for some of the fields I am trying to display. However, others have some HTML decoration around them, such as dynamically coloring particular values etc. So the <c:out> tag would give me some facility to display this information without a table decorator (not sure how to use these as I haven't had to yet either). So I now have some fields referencing with properties and they work perfectly.
The other message from Yannick sorted me out for the other fields. Here is some "working" code (reason for quotes below):
<c:set var="rowstyle" value='student1' />
<% int count = 0; %>
<c:forEach items='${studentResultInformation}' var='student' varStatus='status'>
<c:set var="tableid" value="${student.ID}" />
<% count++; %>
<ajax:displayTag id="<%= "ajaxflag" + count %>" ajaxFlag="<%= "ajaxflag" + count %>">
<display-el:table requestURI="broadsheet/broadsheet_programme_body.jsp" name="${student.broadsheetModuleResultsVector}" class="displaytag" defaultsort="2" defaultorder="ascending" export="true" uid="${tableid}" excludedParams="ajax">
<display-el:column title="Code" property="modCode" sortable="true" headerClass="sortable" />
<display-el:column title="Description" property="modDesc" sortable="true" headerClass="sortable" />
<c:forEach items='${student.yearsForWhichStudentHasModuleResults}' var='year' varStatus='ystatus'>
<display-el:column title="${year}" sortable="true" headerClass="sortable">
<c:choose>
<c:when test='${pageScope[tableid].yearMark[year].passed}'>
<a class="pass"><c:out value="${pageScope[tableid].yearMark[year].resmodoverallmark}" /></a>
</c:when>
<c:otherwise>
<a class="fail"><c:out value="${pageScope[tableid].yearMark[year].resmodoverallmark}" /></a>
</c:otherwise>
</c:choose>
</display-el:column>
</c:forEach>
</display-el:table>
</ajax:displayTag>
The reason I say "working" is because it works to some extent. Each of the tables displays and looking at the source, they all have default divs, such as shown below:
<div id='ajaxflag1'>
<table id="55141820" class="displaytag">
<thead><tr><th class="sortable">
<a href="javascript://nop/" onclick="new Ajax.Updater('ajaxflag1', 'broadsheet/broadsheet_programme_body.jsp?d-3833730-s=0&d-3833730-o=2&year=c&code=menn&displayAjax=true'); return false;">Code</a></th>
.... etc.
All of the tables independently export correctly and they look great! When I sort the first table, it all works flawlessly. But when I try to sort any of the subsequent tables, they get overwritten with the data from the first table.
I'm not sure at all how to fix this - I had assumed that giving a unique id 'ajaxflag1', 'ajaxflag2', etc. would be enough - but this doesn't appear to be the case.
Many thanks for the help so far to get me here. Perhaps, I'm venturing into ajaxtags territory now though.
Has anyone successfully gotten multiple tables sorting and exporting using Ajaxtags?
Many thanks,
David Molloy