RequestParameter versus <param>
trincao Aug 29, 2008 8:31 PMHi Seam experts!
I have a question for you.
What are the differences between using the @RequestParameter annotation and <param /> on pages.xml?
I know they are supposed to be the same, but I have detected some differences between them.
For instance:
Setting the <page /> tag on pages.xml it sets the serviceId variable via the setter
`
<page view-id="/service_show.xhtml" action="#{serviceSearch.doSetSelectedService}">
<param name="srvid" value="#{serviceSearch.serviceId}" />
<navigation>
<rule if-outcome="addComment">
<redirect view-id="/service_show.xhtml" />
</rule>
</navigation>
</page>
`
Whereas using @RequestParameter, the serviceId is set directly (not via the setter):
`
@RequestParameter(value = "srvid")
String serviceId;
`
Another difference is that when using @RequestParameter with the following form I get the exception bellow, whereas using <param /> it works fine.
It seems that when using @RequestParameter the variable is set later thant when using <param />.
`
<h:form id="addServiceCommentForm">
<h:inputTextarea id="comments" value="#{serviceSearch.newServiceComment.text}" />
<br />
<h:commandLink id="submit" value="Create" action="#{serviceSearch.createServiceComment}">
</h:commandLink>
</h:form>
`
What are there other differences? Have you got an idea why this is happening?
Thank you for your time.
Gonçalo
2008-08-29 19:08:54,764 FATAL [javax.enterprise.resource.webcontainer.jsf.application] java.lang.NumberFormatException: null
javax.faces.el.EvaluationException: java.lang.NumberFormatException: null
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
at javax.faces.component.UICommand.broadcast(UICommand.java:383)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
...
Caused by: java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Long.java:372)
at java.lang.Long.parseLong(Long.java:461)
at com.something.portal.web.ServiceSearchAction.createServiceComment(ServiceSearchAction.java:115)
I have a question for you.
What are the differences between using the @RequestParameter annotation and <param /> on pages.xml?
I know they are supposed to be the same, but I have detected some differences between them.
For instance:
Setting the <page /> tag on pages.xml it sets the serviceId variable via the setter
`
<page view-id="/service_show.xhtml" action="#{serviceSearch.doSetSelectedService}">
<param name="srvid" value="#{serviceSearch.serviceId}" />
<navigation>
<rule if-outcome="addComment">
<redirect view-id="/service_show.xhtml" />
</rule>
</navigation>
</page>
`
Whereas using @RequestParameter, the serviceId is set directly (not via the setter):
`
@RequestParameter(value = "srvid")
String serviceId;
`
Another difference is that when using @RequestParameter with the following form I get the exception bellow, whereas using <param /> it works fine.
It seems that when using @RequestParameter the variable is set later thant when using <param />.
`
<h:form id="addServiceCommentForm">
<h:inputTextarea id="comments" value="#{serviceSearch.newServiceComment.text}" />
<br />
<h:commandLink id="submit" value="Create" action="#{serviceSearch.createServiceComment}">
</h:commandLink>
</h:form>
`
What are there other differences? Have you got an idea why this is happening?
Thank you for your time.
Gonçalo
2008-08-29 19:08:54,764 FATAL [javax.enterprise.resource.webcontainer.jsf.application] java.lang.NumberFormatException: null
javax.faces.el.EvaluationException: java.lang.NumberFormatException: null
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
at javax.faces.component.UICommand.broadcast(UICommand.java:383)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
...
Caused by: java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Long.java:372)
at java.lang.Long.parseLong(Long.java:461)
at com.something.portal.web.ServiceSearchAction.createServiceComment(ServiceSearchAction.java:115)