> Thanks for your help :)
You're welcome
> It would be nice to get back to a gwt solution, rather then having
> mess bits of native.
Well, DOM is a GWT class, so I consider my solution to be pure GWT :)
Plus the widget handling the History change will be also pure GWT
> My widget already extends DialogBox;
> Replaceing my;
>
> this.setHTML("<div class=\"captiontext\"> - Post a new review - </
> div><a href=\"#\"><div onclick=\"closeDialog()\" class=\"closeimage
> \"></div></a>");
>
> line with;
>
> Element td = getCellElement(0, 1);
> DOM.appendChild(td, caption.getElement());
> adopt(caption);
> caption.setStyleName("Caption");
> caption.addMouseListener(this);
>
> However, results in a message telling my caption is not
> visible...presumably because its Private in the DialogBox class?
I was just showing you how the caption is originally attached to the
DialogBox, not telling you to replace your code with that, precisely
because caption is private and you can't refer to it. As my second
step suggested, you have to hack away the original caption with DOM
calls. Here's the code that will remove the caption (GWT 1.5.3):
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Label;
public class CaptionRemover implements EntryPoint {
public void onModuleLoad() {
DialogBox box = new DialogBox();
box.setText("caption");
box.setWidget(new Label("contents"));
box.center();
Element dialogTopCenter = (Element) box.getElement
().getElementsByTagName("table").getItem(0).getElementsByTagName
("tr").getItem(0).getElementsByTagName("td").getItem(1);
Element captionElement = (Element)
dialogTopCenter.getFirstChildElement().getFirstChildElement();
GWT.log(dialogTopCenter.getString(), null);
GWT.log(captionElement.getString(), null);
DOM.removeChild((Element) captionElement.getParentElement(),
captionElement);
}
}
> To be honest, I'm not even sure if I could add a widget to the panel
> without resulting to native html+javascript it would solve my core
> problem;
I'm sure it would. Now that you have removed the caption you can
create an Image that adds a HistoryToken onClick and add it with DOM
calls inside the extended class
Image image = new Image("url");
image.addClickListener(//call the History.addToken here);
Element td = getCellElement(0, 1);
DOM.appendChild(td, image.getElement());
adopt(caption);
caption.setStyleName("Caption");
caption.addMouseListener(this);
Voilà ! It should work or at least give you enough inspiration to make
it work. Frankly, I don't think I can be more specific without coming
to your workplace and coding it for you.
Cheers,
Salvador