Set html field from GWT?
I have a GWT application that need to set html field from java code(GWT) i tried this but element is always null
  Element element = Document.get().getElementById("elementID");
               if (element != null)
               {
                  GWT.log("found element with id:" + "elementID");
                  // some code....
               }
Project structure:
|---Main.html: page that loads compiled module
|---page.html: the page that need to be updated from GWT
So my question, is it possible to set field in page.html from GWT code, if so how??
Note: page.html is show after clicking anchor defined like this:Anchor anchor = new Anchor( "message", false, "page.html", "_blank");
EDIT: Page.html:
    <html>
    <head>
      <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/j开发者_高级运维query-ui.css" rel="stylesheet" type="text/css"/>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
     </head>
    <body  style="font-size:62.5%;">
    <div align="center" width="100%" height="80%">
      <table height="80%" width="40%">
      <tr valign="bottom">
     <td align="center">
    <div id="progressbar"></div>
      </td>
      <td><a id="cancel" href="#"><img src="close_icon_x.png" height="32px" width="32px"/></a></td>
      </tr>
      <tr><td valign="top"><div  id ="elementID"></div>
      </td><td></td></tr>
    </table>
    </div>
    </body>
    </html>
Main.html:
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <script type="text/javascript" language="javascript" src="project/MyProject.nocache.js"></script>
        <link media="all" type="text/css" 
        href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css" rel="stylesheet"> 
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" 
        type="text/javascript" charset="utf-8"></script> 
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js" 
        type="text/javascript" charset="utf-8"></script> 
        <link type="text/css" rel="stylesheet" href="Style.css">
  </head>
                                         -->
  <body>
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>
  </body>
</html>
I think the solution is similar to one in this post: GWT: DOM.getElementById doesn't work!
Indeed Riley is correct, where did you define the elementId ?
You can set the field. The problem solution is in why you do get a null pointer.
UPDATE: Are you sure the actual page.html code has been rendered before the invocation of getElementID else you will always get Null.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论