-
1. Re: Richfaces 4 datatable rowclick is not hitting the listener method
healeyb Oct 26, 2011 5:44 AM (in response to haukegulich)1 of 1 people found this helpfulHello Hauke, I think you need to add rich:dataTable var="light" onrowclick="selectRow('#{light.id}')", then
your jsFunction needs to be like this:
<a4j:jsFunction name="selectRow" actionListener="#{userBean.myListener" ...>
<a4j:param name="currentRow" assignTo="#{userBean.selectedRowId}"/>
</a4j:jsFunction>
I don't know if it's ok to have the jsFunction nested inside the datatable, or if it needs to be outside, but
it's easily tested.
One thing to consider is whether you can use the M2 release, I am using that and row selection works in
the normal way without the need for a4j:jsFunction.
Regards,
Brendan.
-
2. Re: Richfaces 4 datatable rowclick is not hitting the listener method
haukegulich Oct 26, 2011 6:24 AM (in response to healeyb)Hello Brendan,
thanks for your answer. This helped me a lot and I figured it out.
So what I did is to create a a4j:jsFunction tag outside (before) the rich:datatable. I think it can be anywhere, but I am not sure (I didn't try that).
And on my rich:dataTable I added the attribute onrowclick and called the js function and pass them the rowkey or in my example the database ID of the corresponding row.
{code:xml}
<a4j:jsFunction name="selectLight" render="lightList" actionListener="#{control.actionListener}>
<a4j:param name="param1" assignTo="#{control.xxx}" />
</a4j:jsFunction>
<rich:dataTable value="#{control.lightList}" onrowclick="selectLight(#{rowKey})" rowKeyVar="rowKey" var="light" width="100%" id="lightList" columns="5" columnClasses="lightTableWidthNarrow,lightTableWidthLarge,lightTableWidthLarge,lightTableWidthNarrow,lightTableWidthLarge">
{code}
The only problem seems to be right now, that the listener will be executed before the setter of xxx is called.
For the sake of completeness I will print out the listener method as well
{code}
public void actionListener(ActionEvent event){ System.out.println("VALUE OF XXX : " + xxx); } {code}
So one way to do a work-a-round here is the execute the business logic on server side to start them from the setter-method. This isn't very nice, but I will play around with that and come back if I figure out a better way. Maybe somebody has an idea?
Maybe one way is with the ActionEvent object. Can I read the param value?
Many greetings,
Hauke
-
3. Re: Richfaces 4 datatable rowclick is not hitting the listener method
healeyb Oct 26, 2011 7:10 AM (in response to haukegulich)Hauke, I already came across this problem. You need to use a4j:jsFunction action=, instead of
actionListener=. I logged this here: https://issues.jboss.org/browse/RF-11446, perhaps add a vote
if you'd like it corrected. As there is a workaround I don't know how much priority it will receive,
it's just that finding out that there's a workaround can take a days work.
Regards,
Brendan.
-
4. Re: Richfaces 4 datatable rowclick is not hitting the listener method
haukegulich Oct 26, 2011 7:46 AM (in response to healeyb)Brendan,
thanks for your help. Now it works but this is really strange and now really consequent.
But anyway, this way it is working.
Thanks,
Hauke