accessing widgets inside a GWT element

Posted by flyingcrab on Stack Overflow See other posts from Stack Overflow or by flyingcrab
Published on 2010-03-17T19:52:47Z Indexed on 2010/03/17 20:01 UTC
Read the original article Hit count: 314

Filed under:
|

I want to access the text elements inside this textbox in GWT from the main method (where I call it like this)

DialogBox aBox =  newCandidatePop.buildNewElecPopup();
    aBox.center();
    aBox.getWidget();

    MiscUiTools.newCandidateHandler(aBox.firstName, aBox.surName);

in newCandidateHandler i want to attach a click handler to the two text boxes

However, the above doesnt quite work - I cant get access to the aBox.firstName elements because they are static methods -- I am wondering what is best practice, how would you code something like this up?

static TextBox firstName = new TextBox();
    static TextBox surName = new TextBox();
    static DialogBox box;

//  public newCandidatePop() {
//      box = buildNewElecPopup();
//  }

    static public DialogBox buildNewElecPopup() {

        DialogBox box = new DialogBox();
        box.setAutoHideEnabled(true);

        box.setText("Add a New Candidate");
        box.setAnimationEnabled(true);
        box.setGlassEnabled(true);

        Grid dialogGrid = new Grid(2, 3);
        dialogGrid.setPixelSize(250 , 125);
        dialogGrid.setCellPadding(10);
        dialogGrid.setWidget(0, 0, new HTML("<strong>First Name</strong>"));
        dialogGrid.setWidget(0, 1, firstName);

        dialogGrid.setWidget(1, 0, new HTML("<strong>Surname</strong>"));
        dialogGrid.setWidget(1, 1, surName);

        box.add(dialogGrid);

    return box;
    }

© Stack Overflow or respective owner

Related posts about gwt

Related posts about java