[jboss-user] [JBoss Seam] - Re: Argh! Attribute access

pbrewer_uk do-not-reply at jboss.com
Fri Mar 2 10:36:04 EST 2007


For anyone else that runs into this problem - it occurs because it is not permitted to call a method of a List implementation - you can only access its index. The following example will fail with the error mentioned previously.

E.g. SummingList.java

  | public class SummingList extends ArrayList<Integer> {
  |   ...
  |   public Long getSum() {
  |     Long sum = 0L ;
  |     for (Integer value : this) {
  |       if (value != null) {
  |         sum += value ;
  |       }
  |     }
  |     return sum ;
  |   }
  |   ...
  | }
  | 

SummingList.xhtml

  |   ...
  |   <h:outputText value ="#{summingList.sum}" />
  |   ...
  | 

The workaround is to move the extra functionality to outside the list, e.g.

  | public class SummingList {
  | 
  |   public void setList(List<Integer> list) {...}
  |   public List<Integer> getList() {...}
  | 
  |   public Long getSum() {...}
  | 
  | }
  | 


This looks like a facelets bug/ strange implementation choice to me:

LegacyELContext.java extract:

  | /* Line 137*/        if((base instanceof List) || base.getClass().isArray())
  | /* Line 138*/            return getPropertyResolver().getValue(base, Integer.parseInt(property.toString()));
  | 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024664#4024664

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024664



More information about the jboss-user mailing list