You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "me (JIRA)" <de...@myfaces.apache.org> on 2007/03/22 13:18:32 UTC

[jira] Commented: (MYFACES-141) accessing properties of an extended "List"

    [ https://issues.apache.org/jira/browse/MYFACES-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12483122 ] 

me commented on MYFACES-141:
----------------------------

I should think this issue is a good/useful and needed functionality and strongly suggest to reopen it
(as long as it's not an spec issue as Heath Borders-Wing suspects).

I found a number of pages on the web where developers want to extend a List and access its extended properties on jsf pages.

I personally would like to use it at least to make a List's size()  method available on a jsf/jsp page
e.g. for displaying/hiding list paginators for lists:

the extended List class:
public class BeanVector<E> extends Vector<E> {
...
    public Integer getSize() {
        return new Integer(this.size());
    }
}

used like:
public class SampeBean {
    public BeanVector getMyList() {...}
}

and accordingly in the jsf page:

<t:dataTable	id="someId"
    value="#{sampleBean.myList}" var="myItem" 
   ...
</t:datatable>
<t:dataScroller id="otherId"  for="someId"
    rendered="#{sampleBean.myList.size > 15}"
    fastStep="15"  paginator="true"
    ...			
</t:dataScroller>

I mean this makes sense,
or am I getting something very wrong and there are other, better ways to implement something like this example?

(of course i could add an additional getter  sampleBean like sampleBean.getMyListSize() : int  
but i think this would not be really nice OOP...)

so any proposals or solutions?

> accessing properties of an extended "List"
> ------------------------------------------
>
>                 Key: MYFACES-141
>                 URL: https://issues.apache.org/jira/browse/MYFACES-141
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.0.9m9
>         Environment: JBoss 4.0.1sp1, my-faces-1.0.9
>            Reporter: Joerg Flammiger
>
> If a class "MyList" extends the class "ArrayList" and the class "MyList" has various getter and setter methods, then it is not possible to access such properties in the jsp/jsf page. an example expression is: #{sampleBean.testList.testValue} . the expression resolver think "testValue" is an index; therefore, it tries to convert "testValue" to an integer, which will fail. In my opinion, "testValue" should refer to the implemented methods "getTestValue" and "setTestValue".
> You will get the following exception:
> 2005-03-21 15:58:12,312 ERROR [org.apache.myfaces.el.ValueBindingImpl] Cannot get value for expression '#{sampleBean.testList.testValue}'
> javax.faces.el.ReferenceSyntaxException: Cannot convert index to int for base mypackage.MyList and index maxItems
> 	at org.apache.myfaces.el.ELParserHelper.coerceToIntegerWrapper(ELParserHelper.java:418)
> 	at org.apache.myfaces.el.ELParserHelper.toIndex(ELParserHelper.java:440)
> 	at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:541)
> 	at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
> 	at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:441)
> 	at javax.faces.component.UIOutput.getValue(UIOutput.java:75)
> 	at org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:293)
> 	at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:159)
> 	at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:77)
> 	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:332)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.