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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JSTL - iterating through lists (thanks Giblet) :)

  • 14-11-2007 4:09pm
    #1
    Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭


    Im having trouble with lists in JSTL. I've created a rudimentary ordering system with a class hierarchy to suit. A sample hierarchy would be


    Order.class
    |- CustomerDetails.class
    |- PersonalDetails.class
    |-AddressList.class
    |- Address.class
    |- DeliveryAddress.class (sub-class of Address)
    |- BillingAddress.class (sub-class of Address)
    ... etc

    I've created a very simple OrderList class which just extends List (or ArrayList?). Now here's my problem. So I've created a jsp page to print out all orders from the database, Im using JDBC, with JSTL.
    <jsp:useBean id="admin" class="admin.AdminBean" scope="request" />
    

    AdminBean looks like this (just some helper utilities):
    public class AdminBean implements Serializable {
        
        private List orderList;
        
       /** Creates a new instance of AdminBean */
        public AdminBean() {
               this.orderList = getAllOrders();
        }
        
        public List getAllOrders(){
            return new ResultSets().getAllOrders();
        }
        
        public Order getOrder(int id){
            return new ResultSets().getOrder(id);
        }
    }
    

    So you would think that by doing:
    <c:forEach items="${admin.orderList}" var="order">
    </c:forEach>
    

    I could access the elements of this list (objects of class Order), and display the properties of them .

    But, I cant :(

    any thoughts? Do I need to use a ListIterator class?


Comments

  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    I'm surprised it has not thrown an error around 'admin.orderList"

    what this is saying is that using http://java.sun.com/j2se/1.4.2/docs/api/java/beans/Introspector.html

    it looks for a method called 'getOrderList'

    you have getAllOrders() .. so rename this or use
    <c:forEach items="${admin.allOrders}" var="order">


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Grr :)

    Yeah you should be using it like this

    type varName

    public type getVarName()
    {
    return type;
    }

    in your class.


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


    Im officially a dufus :rolleyes:

    thank you all..


Advertisement