[jboss-user] [JBoss Seam] - Problem : Javascript-access to fields bound to component pro

dkane do-not-reply at jboss.com
Thu Jul 26 08:47:17 EDT 2007


An overview : 

h:graphicImage element has dynamic "url" parameter that is the property of Seam component. 
When image is rerendered (this happens frequently in response to various actions on the same page), I need to execute some additional Javascript code. This code needs to "know" the number of properties of the same Seam component . Properties changes as often as image URL, i.e. should be re-read right before Javascript execution. 

So I have included Javascript function as "onchange" event handler of h:graphicImage. Then I need to read Seam component properties from JavaScript. The first and obvious idea to do that was Remoting. But why send more HTTP requests when updated component is already in context ? So I added hidden fields and tied them to properties of interest. And, JavaScript code grabs these values via document.getElementById("fieldId").value ; 

But now - the problem : 
"onchange" event handler of h:graphicImage is being invoked, when hidden field values are not yet updated with new values of the component. So I have previous incorrect state of properties. 
Further re-running the same script from button (when page is fully rendered) gives correct results. 

I an thinking in two possible ways now : 

1) Add some timeout before running the script (dirty and not reliable solution)

2) Use basically another approach - looking forward to your advices ..

Thank you 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067796#4067796

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067796



More information about the jboss-user mailing list