Observing links in label-html-text

Hi,

i got following idea but do not have an idea how to implement properly.

I would like to show html-text with links in an label-field. If some link is clicked in the html text i would like to become informed about it by a listener. A click should not result in opening a new web site, but i would like to start some processes in the vaadin UI.

Text shown in vaadin label may look like:
"
Dear user, if you click this
link
then a new help dialog will be opened.
But if you click that
link
, then the current dialog will be closed.
To log out, click here:
logout
.
"

For now i do not have an idea how to implement that stuff.
Any ideas are welcome.

Thanks florian

[u]

[/u][u]

[/u]

I think i found a way. Have to register js functions.


		JavaScript.getCurrent().addFunction("com.example.view.open",
				new JavaScriptFunction() {
					@Override
					public void call(JSONArray arguments) throws JSONException {
						String application = arguments.getString(0);
					}
				});

		JavaScript.getCurrent().addFunction("com.example.signoff",
				new JavaScriptFunction() {
					@Override
					public void call(JSONArray arguments) throws JSONException {
						// do signoff
					}
				});

		label.setValue("Click this <a href='javascript:com.example.view.open(\"org.example.view.help\");'>Link</a> to open view. <br>"
				+ "Or that <a href='javascript:com.example.signoff();'>Link</a> to signoff.");
		label.setContentMode(ContentMode.HTML);

Might that approach work properly at all?

Best Florian

Hi!

For navigation inside labels with HTML content - jumping between the different views - similar to a wiki we use following listener.

addUriFragmentChangedListener()


 
				getPage().addUriFragmentChangedListener(
						new UriFragmentChangedListener() {
							public void uriFragmentChanged(
									UriFragmentChangedEvent source) {
								String frg = source.getUriFragment(); 								

                                // do something with the information								
                                domainComponent.getSharedComponents().getTree().selectByFragment(frg);
							}
						});

Hi Peter,

thanks a lot for the hint.

I will investigate how to integrate the fragments. We are using vaaclipse and have to process complex events. Maybe i can pass all required information by fragment to control the things that have been done.

Thanks a lot,
Florian

Hi!
I forgot to give you the original link:
https://vaadin.com/wiki/-/wiki/Main/Using%20URI%20fragments