0

I have to display a column Netsales using display tag, when i was define this netsales in bean tag and getting value through scriptlet i got net sales of string type, thus i am not getting sorting for this column appropriate in my display table. how can i change it to number type?

<body>
<%String strCurrency=(String)session.getAttribute("strCurrency");%>
<fieldset><legend>Overall Outstanding</legend>
<bean:define id="NetSales"><bean:write name="NetSales" format="#,##,##0.00"/></bean:define>
<bean:define id="TotalBal"><bean:write name="TotalBal" format="#,##,##0.00"/></bean:define>

<display:table id="customerList" name="CustomerList" requestURI="" export="true" frame="true">
<display:caption style="font-weight:bold;text-align:left;padding-left:7px;line-height:25px;display:none;" >Overall Outstanding</display:caption>
<bean:define id="custno"><bean:write name="customerList" property="custNo" /></bean:define>
<bean:define id="netSales"><bean:write name="customerList" property="netSales" format="#,##,##0.00"/></bean:define>
<bean:define id="openBal"><bean:write name="customerList" property="openBal" format="#,##,##0.00"/></bean:define>

<display:column property="custName" title="Customer Name" sortable="true"  class="l" headerClass="hl"/>
<display:column property="city" title="City" sortable="true" class="l" headerClass="hl"/>
<display:column title="Net Sales" media="html" sortable="true" class="r" headerClass="hr" sortName="NetSales"><%=netSales %></display:column>
<display:column property="netSales" media="xml csv pdf excel"  format="{0,number, #,##,##0.00}" class="r" headerClass="hr" />
<display:column title="Total Balance" media="html" sortable="true"  class="r" headerClass="hr"><%=strCurrency %><%=openBal %></display:column>
<display:column property="openBal" media="xml csv pdf excel"  format="{0,number, #,##,##0.00}" class="r" headerClass="hr"/>
<display:footer media="html">
<tr>
<td colspan="3" align="right">&nbsp;</td>
<td class="r"><%=strCurrency %><%=NetSales%></td>
<td class="r"><%=strCurrency %><%=TotalBal%></td>
</tr>
</display:footer>
</display:table>
</fieldset>
</body>

1 Answer 1

0

In bean:write, format attribute is converting the value to the string. If you want to make sorting on int, you have write something like this

<display:column title="Net Sales" media="html" sortable="true" class="r" headerClass="hr" sortName="NetSales">
   <bean:write name="NetSales" format="#,##,##0.00"/>
 </display:column>
2
  • to @Naved : NetSales have number of values , but here values are overwrited. Jan 24, 2013 at 7:22
  • then I am not sure how you are using <bean:write> on "NetSales". Because format will work on property of the bean and not on whole bean
    – Naved
    Jan 24, 2013 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.