0 Replies Latest reply on Jul 26, 2007 8:47 AM by dkane

    Problem : Javascript-access to fields bound to component pro

    dkane

      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