How to emulated onclick Ajax request from Javascript?
benjes Jun 11, 2008 7:42 AMHi,
I hope someone of you can help me with this.
I have a rich:dataTable which can have multiple pages. The user can navigate between the elements (links) in the table with the keyboard (I am using keypressed for that). In fact the user won't have a mouse so everything has to be controlled by the keyboard. When you press down the focus is moved to the next element, when you press up it is moved to the previous element.
I want to things:
When a link in a table gets the focus it should execute the link (as in onclick)
When the user gets to the last element in a page and presses down the next table page should be shown (as if you would use a rich:datascroller).
So far I simply used the same Javascript calls Ajax4J was creating on the fly for the action event (onclick)
e.g. for starting an AJAX request when getting the focus
<a4j:commandLink ... onkeypress="#{stationEntry.keyHandleCommand}" onfocus=" A4J.AJAX.Submit('_viewRoot','#{StationListManager.formID}',this,{'parameters':{'#{stationEntry.componentId}' : '#{stationEntry.componentId}'},'eventsQueue':'foo', 'actionUrl':'/EPG/pages/epg.seam?javax.portlet.faces.DirectLink=true'}); }" id="#{StationListManager.entryID}" action="#{stationsHome.selectStation(stationEntry.station)}" reRender="NowNext,VideoID"> </a4j:commandLink>
The A4J.AJAX.Submit is the same Ajax4J creates at runtime for the 'action' parameter .
For emulating a rich:datascroller I use
A4J.AJAX.Submit('_viewRoot','SLM_Form0',e,{'ignoreDupResponses':true,'oncomplete':function(request,event,data){setNextFocus()}, 'parameters':{'SLM_Form0:SLMscrollerID':'next'} ,'eventsQueue':'SLM_Form0:SLMscrollerID','actionUrl':'/EPG/pages/epg.seam?javax.portlet.faces.DirectLink=true'} );in my keypress handler.
This used to work fine with RichFaces 3.1 but now I moved to RichFaces 3.2 and it changed.
Now the datascroller creates Javascript code like:
Event.fire(this, 'rich:datascroller:onscroll', {'page': 'next'});
Does anyone know how I can solve this problem without having to hardcode the javascript code Ajax4J would generate on the fly?
I am fairly new to RichFaces/Seam so every help is welcome.
Thank you
Immo