Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

JSTL (again).. :(

  • 10-12-2007 11:05AM
    #1
    Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭


    Ok, I know this is the only thing I post about, but anyhow. Im stuck again. Have been frantically googling for the past few hours, and no joy. Basically, I have this class AddressList, which just contains address types (PersonalAddress, DeliveryAddress, BillingAddress), and can contain multiple instances of each. So the class looks like this
    public class AddressList extends ArrayList implements Serializable {
    
        /** Creates a new instance of AddressList */
        public AddressList() {
        }
        
    }
    

    Very simple. Yes? Ok, so here is the JSTL:
    <c:forEach items="${admin.order.customerDetails.addressList}" var="addresses">
    <c:choose>
    ...
    </c:choose>
    </c:forEach>
    

    which iterates through the objects in the AddressList, and returns one of the 3 objects. I basically need to check each object, and if its a PersonalAddress display certain fields, if its a DeliveryAddress display other fields, etc. I found this on google
    <c:if "${foo.class.name eq 'path.to.PersonalAddress'}">
    ...
    </c:if>
    
    which in theory works, but its how I get "foo" in this thats confusing me. As you can see AddressList just extends ArrayList, so should I be writing some sort of "getter" in this class to return an object?

    Thanks for the help in advance.

    Stephen


Comments

  • Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭smcelhinney


    Sorry! Found the solution , for anyone else who needs it
    <c:forEach items="${admin.order.customerDetails.addressList}" var="address">
    <c:choose>
    <c:when test="${address.class.name eq 'com.affinities.objects.address.PersonalAddress'}">
    Personal address
    ${address.addressLine1}
    </c:when>
    <c:when test="${address.class.name eq 'com.affinities.objects.address.DeliveryAddress'}">
    Delivery address
    ${address.addressLine1}
    </c:when>
    <c:otherwise />
    </c:choose> 
    </c:forEach>
    

    easy actually, I should just trust EL to do what I want it to do..


Advertisement