Is it expected behaviour for an EL arithmetic expression to always return a
Long?

Yes.  Or a Double if the value cannot be represented as a Long.



On 5/31/07, gazlm <[EMAIL PROTECTED]> wrote:

I have a problem with type conversions when using updateActionListener to set
an int property in a backing bean...

I'm using a bean which has properties pageNum and numPages, and I have
command links that refresh the page, with an updateActionListener changing
the value of the pageNum property.

If I use the updateActionListener like this:

<t:updateActionListener property="#{bean.pageNum}" value="0" />

then I have no problems, but if I try to do something like this:

<t:updateActionListener property="#{bean.pageNum}" value="#{bean.pageNum+1}"
/>

then I get an exception:

javax.faces.el.EvaluationException: Exception setting property helloCount of
base with class demo.GetNameBean, caused by an argument type mismatch. The
full stack trace is attached below.

From debugging through the code while running, it seems that when I do any
arithmetic in a JSF EL expression, the result is a Long, which can't be used
as an argument when the required type is int.

If I change my bean to accept a Long instead of an int, the problem goes
away, but that doesn't seem ideal to me...

Does anyone else have this problem?
Is it expected behaviour for an EL arithmetic expression to always return a
Long?

Cheers.

ERROR [[/testMyFaces].[Faces Servlet]:http-8080-Processor25] -
Servlet.service() for servlet Faces Servlet threw exception
javax.faces.el.EvaluationException: Exception setting property pageNum of
base with class com.gaz.Bean
        at
org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:185)
        at
org.apache.myfaces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:275)
        at
org.apache.myfaces.custom.updateactionlistener.UpdateActionListener.processAction(UpdateActionListener.java:156)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:48)
        at
javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:484)
        at javax.faces.component.UICommand.broadcast(UICommand.java:75)
        at 
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
        at 
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
        at
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
        at
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: javax.faces.el.EvaluationException: Bean: com.gaz.Bean, property:
pageNum
        at
org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:410)
        at
org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:173)
        ... 27 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:406)
        ... 28 more

--
View this message in context: 
http://www.nabble.com/argument-type-mismatch-when-setting-property-with-updateActionListener-tf3846565.html#a10894017
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Reply via email to