I have a problem getting a dialog box to popup when I click on an
anchor. I looked at google source code but it still doesn't seem to be
working. What am I doing wrong? I don't think I need to send you all
the code, but if you want it, you have it. All of the following code
is called from a different class, a Java class that lies on the
server.

public Widget getDataCell() {
        final Image image = new Image();
        final HTML title = new HTML();
        final HTML datatext = new HTML();
        final Anchor link = new Anchor("More>>");
        final Grid dataCell = new Grid(2, 2);
        image.setUrl(imagepath);
        title.setHTML("<a class = \"title\" href = \"http://"; +
website + "\">"
                + name + "</a><br/>");
        if (data.length() >= 145)
            datatext.setHTML(data.substring(0, 145) + "... " + link);
        else
            datatext.setHTML(data + " " + link);
        dataCell.setWidget(0, 0, title);
        dataCell.setWidget(1, 0, image);
        dataCell.setWidget(1, 1, datatext);
        link.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                final DialogBox d = createDialogBox();
                d.show();
                d.center();
            }
        });
        return dataCell;
    }


// There probably IS something wrong in here VV but i don't think it
really matters because nothing I put in the ClickHandler works :/
    private DialogBox createDialogBox() {
        // Create a dialog box and set the caption text
        final DialogBox dialogBox = new DialogBox();
        dialogBox.ensureDebugId("cwDialogBox");
        dialogBox.setText("");

        // Create a table to layout the content
        VerticalPanel dialogContents = new VerticalPanel();
        dialogContents.setSpacing(4);
        dialogBox.setWidget(dialogContents);

        // Add some text to the top of the dialog
        HTML details = new HTML(name);
        dialogContents.add(details);
        dialogContents.setCellHorizontalAlignment(details,
                HasHorizontalAlignment.ALIGN_CENTER);

        // Add an image to the dialog
        Image image = new Image(imagepath);
        dialogContents.add(image);
        dialogContents.setCellHorizontalAlignment(image,
                HasHorizontalAlignment.ALIGN_CENTER);

        // Add a close button at the bottom of the dialog
        Button closeButton = new Button("Close", new ClickHandler() {
            public void onClick(ClickEvent event) {
                dialogBox.hide();
            }
        });
        dialogContents.add(closeButton);
        if (LocaleInfo.getCurrentLocale().isRTL()) {
            dialogContents.setCellHorizontalAlignment(closeButton,
                    HasHorizontalAlignment.ALIGN_LEFT);

        } else {
            dialogContents.setCellHorizontalAlignment(closeButton,
                    HasHorizontalAlignment.ALIGN_RIGHT);
        }

        // Return the dialog box
        return dialogBox;
    }
-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to