Search code examples
javascriptjavajxbrowser

using DOMFormControlElement set value dynamically


I'm using JxBrowser with a Java program executing an index.html file as a GUI to enter and display values.

I'd like to update one HTML form dynamically from my java app, using code below:

browser.addLoadListener(new LoadAdapter() {
   @Override
   public void onFinishLoadingFrame(FinishLoadingEvent event) {
      if (event.isMainFrame()) {
        DOMDocument document = event.getBrowser().getDocument();
        DOMFormControlElement element = 
                    (DOMFormControlElement) document.findElement(By.id("textArea"));
        DOMFormControlElement textArea = (DOMFormControlElement) element;
        DOMEventType.OnChange;  
        if (!MessagefromCSM.equals("CSM request pending")) {
            textArea.setValue(MessagefromCSM);
        }
     }
   }
});     

this works perfectly when launching, string value from MessagefromCSM is correclty displayed, but remains static. is there anyway to update textArea at will?

thanks for any hint,

Olivier


Solution

  • Hello finally worked it out...

      final DOMDocument document = browser.getDocument();
      ((DOMFormControlElement) document.findElement(By.id("textArea"))).setValue(MessagefromCSM);
    

    called where appropriated

    I can close it now, Olivier