-
1. Re: RF4: a4j:jsFunction and a4j:param
bleathem Aug 26, 2013 2:56 PM (in response to alexanndre.granier)Alexandre Granier wrote:
It works but the index is the one of the last request...
In what phase are you observing that the index is stale? Can you inspect the browser headers of the POST to see if it is POSTing the expected value?
-
2. Re: RF4: a4j:jsFunction and a4j:param
alexanndre.granier Aug 27, 2013 12:08 PM (in response to bleathem)Thanks Brian,
If you talk about jsf phase, it is during the invoke application phase
here is the trace:
INFO: PWC1412: WebModule[null] ServletContext.log():before INVOKE_APPLICATION 5
INFO: action 0
INFO: PWC1412: WebModule[null] ServletContext.log():after INVOKE_APPLICATION 5
here is the post values after one click on the second node, param1 is good in the post:
- j_idt6:j_idt6
- javax.faces.ViewState:2398871897211749917:8963538410607719053
- javax.faces.source:j_idt6:j_idt7
- javax.faces.partial.execute:j_idt6:j_idt7 @component
- javax.faces.partial.render:@component
- param1:1
- org.richfaces.ajax.component:j_idt6:j_idt7
- j_idt6:j_idt7:j_idt6:j_idt7
- rfExt:null
- AJAX:EVENTS_COUNT:1
- javax.faces.partial.ajax:true
does it help ?
-
3. Re: RF4: a4j:jsFunction and a4j:param
bleathem Aug 27, 2013 4:44 PM (in response to alexanndre.granier)I created an Arquillian Warp test to verify the behaviour:
https://github.com/richfaces/richfaces/commit/96b4fc65337e8dee99e55b1adf44261e3ef5b59b#L1R112
Notice how before the INVOKE_APPLICATION phase the bean property is not set, but after the INVOKE_APPLICATION phase the bean property is set. This is consistent with your report that it is not set *at some point* during the INVOKE_APPLICATION phase.
The reason for this is that the r:param (a4j:param) component is decoded as an ActionListener, see:
In your example above, your ActionListener is simply executed prior to the r:param ActionListener.
An alternative means of accomplishing your goal would be to use a javascript click listener to set the value of a hidden input, and execute that input with your ajax request. This would apply the value to your backing bean in the UPDATE_MODEL_VALUES phase, prior to the INVOKE_APPLICATION.
-
4. Re: Re: RF4: a4j:jsFunction and a4j:param
alexanndre.granier Aug 28, 2013 5:13 AM (in response to bleathem)Ok, I use this trick:
<a4j:jsFunction name="func" actionListener="#{myBean.action}" render="@form" execute="@form"/> <h:inputHidden id="param1" value="#{myBean.idx}"/> <a4j:repeat value="#{myBean.nodes}" var="node" rowKeyVar="key" rows="30"> <a4j:outputPanel id="panel" layout="block" onclick="jQuery(#{rich:element('form:param1')}).val(#{key});func();"> <h:outputText value="#{node.label} key: #{key}"/> </a4j:outputPanel> </a4j:repeat>
I had to use the "execute" attribute to process the inputHidden.
thx for your help
-
5. Re: RF4: a4j:jsFunction and a4j:param
bleathem Aug 28, 2013 4:56 PM (in response to alexanndre.granier)Note, this issue is tracked via the jira:
with the recommend workaround of using the action attribute of the jsFunction, rather than the actionListener.