Probably simple -- need to add links to page [message #885867] |
Wed, 13 June 2012 18:47 |
Sean Gilley Messages: 14 Registered: April 2012 |
Junior Member |
|
|
This is probably extremely simple, and I'm just not finding the reference I need.
I've got a working RAP application. I need to add two links to the page, one of which will open a new window/tab, the other of which will just replace the current page.
Ideally, I'd like to add the links as buttons, but if not, I'll take simply placing them at the upper left of the display area as links. Either way is fine, as long as it works. (If buttons, they can go with the existing set of buttons at the upper right.)
(As I've said before, I haven't done OO programming for about ten years, so rusty only begins to describe those skills. So the simpler and more complete the answer the better.)
Thanks,
Sean.
|
|
|
Re: Probably simple -- need to add links to page [message #886091 is a reply to message #885867] |
Thu, 14 June 2012 08:19 |
|
Hi Sean,
There are two different ways to add a link to a RAP UI. The first (and
simplest) is to use the new Markup support to add a plain HTML link to a
Label:
Label label = new Label( page, SWT.NONE );
label.setData( RWT.MARKUP_ENABLED, Boolean.TRUE );
label.setText( "<a href=\"http://xkcd.com/\"
target=\"_blank\">Plain Link</a>" );
The other is to open an external browser window programmatically, e.g.
on a button click. This method involves an additional request and the
new window/tab will be suppressed by pop-up blockers:
Button button = new Button( page, SWT.PUSH );
button.setText( "External Browser" );
button.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e ) {
int browserStyle = ExternalBrowser.LOCATION_BAR |
ExternalBrowser.NAVIGATION_BAR;
ExternalBrowser.open( "google", "http://xkcd.com/", browserStyle );
}
} );
HTH, Ralf
--
Ralf Sternberg
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01811 seconds