Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

ajax onclick event on h:commandLink  RSS feed

Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using jsf of the following implementation, which I have found under META-INF of jsf-ibm.jar. From this how can I make out version of jsf whether 1.1 or 2 ?

Specification-Title: Java Server Faces
Implementation-Title: JSF Widget Library (JWL) - Base
Implementation-Version: JWL v3_1_5
Implementation-Vendor: IBM
Build-Version: 20100201_1250
Build-Date: February 1 2010

I have a datatable and data rows inside the table. I am trying to edit a particular row using a h:commandLink with an ajax call.

I see that the entire page is still refreshing inspite of adding ajax behaviour, where only the particular datatable which has been embedded inside panelgroup alone has to be refreshed. Gone through some forums, which say that onclick is not supported for some versions of jsf. If it is the same case with me, is there any alternative to achieve this onclick which triggers ajax call.

I have given code snippet below.



<h:panelGroup id="group1">

<hx:columnEx width="3%">
<f:facet name="header">
<h:outputText styleClass="outputTextGridColumnHeader" value=""></h:outputText>

<h:commandLink styleClass="commandLink" type="submit" immediate="true"
action="#{custommap.editRow}" id="editMap">

<div align="center"><h:graphicImage value="#{msg.imgUpdate}"
width="16" height="16" styleClass="graphicImage"
<f:param value="#{varcusMapDetailsList.crMapEntId}" name="editId"
<hx:behavior event="onclick" id="behavior3" targetAction="group1" behaviorAction="get"></hx:behavior>



<hx:ajaxRefreshSubmit id="ajaxRefreshRequest1" target="group1"></hx:ajaxRefreshSubmit>


Suresh Midde
Posts: 20572
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The best way to work with a row in a datatable is not to pass it as a parameter like the view is calling a function (Views should not contain logic), but to use a plain old JSF action method and let the action locate the row using the table's datamodel wrapper object.

JSF 1.x did not support AJAX. The only way to get AJAX support in JSF1 was to either do it manually or to use one of the extension tagsets that came with AJAX functionality as part of the tagset. I'm not familiar enough with the "hx" extension set to advise on that part, however.

Onclick is a Javascript characteristic and ALL JSF versions support it on the "h" core tags. I would also be surprised to hear that any extension that bound to Javascript events didn't handle "onclick".

"immediate="true"" does not mean "AJAX", it means "when this form is submitted, don't submit the data in the form, just fire the action".

Also, we have a useful button labelled "Code" in our message editor. You can use it to generate tags that will format Java code, XML, and other pre-formatted text. It makes them easier to read.
pie. tiny ad:
global solutions you can do at home or in your backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!