Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Convert html hyperlinks to Anchors

$
0
0
I have a html master report generated by BIRT engine. It is displayed in a tab. When any link on this html clicked, I have to display a detailed report in a new tab.

The master html page contains the hyperlinks generated by BIRT bypassing the SmartGWT frame. I am looking into replacing the links with Anchors so I can capture the click event and process within the app.

GWT HTMLPanel has a method to replace an element inside html code "addAndReplaceElement".

How can I do the same in SmartGWT ?



public ReportsHTMLPanel(String title, String html) {
this.setWidth("80%");
setTitle(title);

//HTMLFlow htmlFlow = new HTMLFlow();
HTMLPane htmlFlow = new HTMLPane();
htmlFlow.setContents(html);
htmlFlow.setPadding(20);
htmlFlow.setAlign(Alignment.CENTER);
NodeList<Element> anchors = htmlFlow.getElement().getElementsByTagName("a");
for ( int i = 0 ; i < anchors.getLength() ; i++ ) {
Element a = anchors.getItem(i);
Anchor link = new Anchor(a.getInnerHTML());
link.addClickHandler(new ClickHandler() {
@Override
public void onClick(com.google.gwt.event.dom.client.ClickEvent event) {
SC.say("Html clicked!! " + event);
}
});
// htmlFlow.addAndReplaceElement(link, a); //this is not possible in SmartGWT.
}

this.setLayoutAlign(Alignment.CENTER);
addMember(htmlFlow);
}

Viewing all articles
Browse latest Browse all 4756

Trending Articles