This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSF and the fly likes How to make an image rerender when its value(src) changes using AJAX. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to make an image rerender when its value(src) changes using AJAX." Watch "How to make an image rerender when its value(src) changes using AJAX." New topic
Author

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

Zafar Hakim
Greenhorn

Joined: Nov 04, 2008
Posts: 6
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
 
Consider Paul's rocket mass heater.
 
subject: How to make an image rerender when its value(src) changes using AJAX.