Thursday, December 2, 2010

Observe (Hyper) Links in Texts to call JAVA methods

Hello everyone,

I've been searching quit a lot for a solution to this problem but all
I found wasn't 100% satisfactorily:

I use RPCs in my GWT project to get some texts like

String text = " ...bla bla <a href='#ID123'>open me</a>
blablalb ....";

Those strings will be loaded into the content of a HTMLPane like this:

contentHTMLPane = new HTMLPane();
contentHTMLPane.setContents(text);

And the user can see the new content after the RPC. What I need is the
following:

When the user clicks on <a href='#ID123'>open me</a> it should call
the method:

public void openConent(String id){
...
}

...of course with the ID of the Link. The openContent method is
present in the class which processes the text and so on.

So I have to observe the "user clicks on a hyperlink" event somehow.
Somehow like:

(pseudocode)

if(eventHyperlinkOccurs) {

this.openConent(event.getURLofLink);

}


All I've found is this: http://googlewebtoolkit.blogspot.com/2008/07/getting-to-really-know-gwt-part-1-jsni.html
which tells me that it's possible to call JAVA methods with JS
methods. This solution is OK but I've been wondering if there is a
"smaller" solution with events/observers?

Thanks in advance!


--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment