Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make an image rerender when its value(src) changes using AJAX.

 
Zafar Hakim
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem:
I Have a jsf component which is basically made of html Table. Each cell contains an image. On click of the image I want to change the image using AJAX. I am using Ajax4jsf from RichFaces and I am able to call a jsFunction which will be invoking a action(method) from the bean class. In the action method I decide depending on some condition which image to show. I am changing the image value in the object HTMLGraphicImage ( from which I am displaying the table, provided by RichFaces ) which is a member of the bean. Now I want to see this is reflected at the client. How do we rerender the image here when image source changes?

Code in action method looks something like this:
*********************************************************
...
...
hgImage= (a bean).getHgImage;

hgImage.setValue(imgSrc); // imgSrc changed
...
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
if(ajaxContext != null && ajaxContext.isAjaxRequest()) {

// WANT to Add the image with id "hgImage.getId()" to the list that are to be re-rendered.
}
*********************************************************

Any help is highly appreciated.

Regards,
Zafar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic