JSP not accessing inner class attributes

softechnics
softechnics used Ask the Experts™
on
I'm getting an error trying to access class attributes passed from my java class to my jsp page. Here's what I'm doing. Do you see the error of my ways?

Briefly, in Java Class 'TransferService':

public class TransferService
{
      private ArrayList<HistoryLineItem> historyList;

      public final ArrayList<HistoryLineItem> getAllItemsScanned(

            <Query several TransferCount records, then loop through them>

            ArrayList historyList = new ArrayList<HistoryLineItem>();

            for (TransferCount transferCount : q) {

                  HistoryLineItem hli = new HistoryLineItem();
                              
                  hli.transferCountId = transferCount.getTransferCountId();
                  hli.productNum = transferCount.getProductNum();
                  hli.seq = transferCount.getSeq();
                  hli.qty = transferCount.getQty();

                  historyList.add (hli);
            }

            return this.historyList;
      }

      public final class HistoryLineItem {
            
            public int transferCountId;
            public String productNum;
            public BigDecimal qty;
            public short seq;
      }
}


In my JSP, keeping it simple:


      <c:forEach var="thisItem" items="${scannedHistoryList}" varStatus="row">
            <srps:Control TargetName="TransferHistoryList[${row.index}][1]" Text="${thisItem.qty}" />
      </c:forEach>


When executed, I get the following runtime error:


SEVERE: Servlet.service() for servlet SoftRetailMobileServer threw exception
javax.el.PropertyNotFoundException: Property 'qty' not found on type com.softechnics.softretail.common.TransferService$HistoryLineItem
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Does the HistoryLineItem class have a getter method ?

public BigDecimal getQty(){
                                            return qty;
}

Commented:
I suggest to make the properties of the class HistoryLineItem private and provide getters and setters for each of them. (see JavaBeans specification)

Author

Commented:
I already tried both of those approaches. The result was the same

I'll redo them.

Author

Commented:
Don't know what happened, but when I put the getter/setters back in, it now works. I might have made the getters/setters 'protected' before. Now they are 'public'. I believe that's the only difference.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial