Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JSTL (again).. :(

Options
  • 10-12-2007 11:05am
    #1
    Registered Users 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 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