Hi,
Yesterday we got an issue in the MyFaces issue tracker saying that the
following peace of code should append paramName=paramValue as request
parameter to the ajax call (see [1]):
<h:inputText>
<f:param name="paramName" value="paramValue" />
<f:ajax />
</h:inputText>
The reason why the developer thinks this should work is because it
also works for h:commandXxx.
IMO it is clear why this should work for h:commandXxx: A UICommand
always triggers a new request (ajax or normal) and thus it should
support adding request parameters via f:param (this fact is also
stated in the spec). But a UIInput component isn't supposed to
generate a new request (at least not a normal request) and thus should
not support f:param.
Can anyone confirm this behavior for JSF 2.0 and 2.1 or did I miss something?
However, thinking about the fact that f:param was introduced before
JSF had any ajax support, it kinda does make sense to adopt it for
f:ajax, because now _every_ component can trigger a new (ajax) request
and thus should be able to add request parameters. Note that pre JSF
2.0 this was only true for UICommand.
Furthermore I looked at the spec javascript documentation of
jsf.ajax.request() and found out that there is already a way to add
request parameters to the ajax request: The options element supports a
"params" parameter: params - object containing parameters to include
in the request. Thus it is already possible to do it, but you have to
use the native javascript function instead of f:ajax.
So maybe the above example should work or maybe also something like
this should work:
<h:input...>
<f:ajax>
<f:param name="name1" param="param1" />
</f:ajax>
</h:input...>
WDYT?
Regards,
Jakob
[1]
https://issues.apache.org/jira/browse/MYFACES-3012
--
Jakob Korherr
blog:
http://www.jakobk.com
twitter:
http://twitter.com/jakobkorherr
work:
http://www.irian.at