Link to home
Start Free TrialLog in
Avatar of saikumarstl
saikumarstl

asked on

I wanted to display address,city,state,zip,phone basing on location property 'group'.

I wanted to display address,city,state,zip,phone basing on location property 'group'.
Currenlty, I was able to display address,city,state,zip,phone irrespecitve of the group. But I wanted to
sort basing on group and wanted to display in the folloing format. Can you please correct the following code
in struts. I wanted to iterate through 'locationList' and sort by group code(codes are like 01, 02, 03 etc.,).

Group 05
-----------
Address                 City        State ZIP      Contact Phone   Group
144 E. Baltic Ave     St. Louis  MO  63132  314-444-4425    05
300 Page Avenue    Olivette    MO  63011  314-409-4453   05
44 N. Kingshighway  St. Louis  MO  63311  314-422-0434   05

--------------------------------------------------------------------------------

Group 04
-----------
Address                   City         State  ZIP     Contact Phone  Group
300 Old Hwy 21        Dothan     AL    14677  444-698-7896   04
344 Butler Hill Rd.     Andalusia  AL   15609  444-877-1234   04

--------------------------------------------------------------------------------
<logic:iterate name="locationList"  id="location" scope="request">
       <tr height="24">
        <td class="branchCell" align="center">          
        <bean:write name="location" property="group"/>
        </td>
        <td class="branchCell">
          <bean:write name="location" property="address"/>
        </td>
        <td class="branchCell">
          <bean:write name="location" property="city"/>
        </td>
        <td class="branchCell">
          <bean:write name="location" property="stateProv.desc"/>
        </td>
        <td class="branchCell">
          <bean:write name="location" property="zipCode"/>
        </td>
        <td class="branchCell">
          <bean:write name="location" property="contactPhone"/>
        </td>
       </tr>
      </logic:iterate>
Avatar of bloodredsun
bloodredsun
Flag of Australia image

I assume that you are getting your data out of a database. If so, you should do the sorting in your select statement by using the "order by" keyword. This also has the benefit iof requiring no re-writing of your JSP.

If you can't then you need to do your sorting in the actionForm as there is no way I know to easily sort the results from the actionform usign either the struts logic tags or the JSTL c:forEach tag which is now the prefered method of logic in a Struts app. So you would need to write a sorting method in your actionForm when you return the groups
Avatar of saikumarstl
saikumarstl

ASKER

I would like to do this using struts logic tags. Can any one provide me the sample code how to do this.
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agreed