hi guys,

I would like to get some help about getElementById() method. My
problem is that getElementById method return with null in my case.

I have a "header" section in my index.htm file. When my web
application starts, at first I load header content in this frame. This
header contains two important labels for show full name of user and
company.

Before login procedure content of these two label are empty ("").
After login procedure is success, I want to update content of fullname
and companyname fields but when I try to get references to fields (I
use getElementById method) I get null value.

Here are my snippets of codes.

I have an index.html with some frame:
<body>
    <div id="myapp-frame-header"></div>
    <div id="myapp-frame-menu"></div>
    <div id="myapp-frame-main"></div>
    <div id="myapp-frame-statusBar"></div>
...

And I made a HeaderPage.java composite class:
public class HeaderPage extends Composite
{
    private HorizontalPanel mainPanel = new HorizontalPanel();
    private Label fullnameLabel = new Label();
    private Label companyLabel = new Label();
    ...

    public HeaderPage()
    {...}

    public void render()
    {
        ...
        fullnameLabel.getElement().setId("headerPage_fullnameLabel");
        ...
        companyLabel.getElement().setId("headerPage_companyLabel");
        ...
        mainPanel.add(fullnameLabel);
        mainPanel.add(companyLabel);

        // all composites must call initWidget() in their constructors
        initWidget(mainPanel);
    }


content of MyAppEntryPoint.java:
public void onModuleLoad()
{
    HeaderPage headerPage = new HeaderPage();
    headerPage.render();
    RootPanel.get("myapp-frame-header").add(headerPage);
    ...
}

After login procedure I use this code in another composite class
(example in LoginPage.java):
    String id = "headerPage_fullnameLabel";
    Element element = DOM.getElementById(id);
    //Element element = Document.get().getElementById(id);

    element.setInnerText(fullName);


but value of element is always null. I do not know what is wrong in my
code.

Please help me.

thx, Arnold

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to