Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321295 - [Link] Hyperlink produces script error if anchor tag (<a>) is missing
Summary: [Link] Hyperlink produces script error if anchor tag (<a>) is missing
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.4 M2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: sr131
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-30 03:50 EDT by Andre Weber CLA
Modified: 2010-08-31 10:19 EDT (History)
2 users (show)

See Also:


Attachments
Snippet to reproduce (1.34 KB, text/plain)
2010-08-30 05:11 EDT, Ralf Sternberg CLA
no flags Details
Patch against RAP 1.3 (1.80 KB, patch)
2010-08-30 10:00 EDT, Ralf Sternberg CLA
no flags Details | Diff
Updated patch against RAP 1.3 (2.01 KB, patch)
2010-08-30 11:58 EDT, Ralf Sternberg CLA
ivan: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Weber CLA 2010-07-30 03:50:58 EDT
Build Identifier: Eclipse 20090920-1017 RAP 1.3.0.20100615-1704

While trying to set a new text to the Link widget using Link.setText(), an error occurs if the passed text has no anchor tag (<a>).
In our environment, the anchor refrence is not used since we just interested in the event sent by the SelectionListener which is attached to the link.

Note: Other platforms than PC/WinXP not tested.

Reproducible: Always

Steps to Reproduce:
1. Setup a Link widget with a SelectionListener.
2. Set a text surrounded by an anchor tag (<a> without any parameter).
3. During a request, set a text that isn't surrounded by an anchor tag (in order to have the link displayed not underlined)
4. The following error occurs and is displayed in the browser:

Could not evaluate javascript response:

TypeError: hyperlinks[this._currentFocusedLink] is undefined

var wm = org.eclipse.swt.WidgetManager.getInstance();var w = wm.findWidgetById( "w595" );w.dispose();var w = wm.findWidgetById( "w596" );w.dispose();var req = org.eclipse.swt.Request.getInstance();req.setRequestCounter( "74" );var w = wm.findWidgetById( "w67" );w.setEnabled( false );var w = wm.findWidgetById( "w69" );w.clear();w.addText( "Fehlergruppen bearbeiten" );w.applyText();var w = wm.findWidgetById( "w198" );w.setVisibility( false );var w = wm.findWidgetById( "w199" );w.setVisibility( false );w.clear();w.addLink( "Fehler bearbeiten", 0 );w.applyText();var w = wm.findWidgetById( "w483" );w.setVisibility( true );var w = wm.findWidgetById( "w582" );w.setVisibility( false );var w = wm.findWidgetById( "w584" );w.setItemMetrics( 0, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 1, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 2, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 3, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 4, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 5, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 6, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 7, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 8, 0, 0, 0, 0, 0, 0 );w.setItemMetrics( 9, 0, 0, 0, 0, 0, 0 );w.updateRows();w.setItemCount( 0 );var w = wm.findWidgetById( "w610" );w.setSpace( 459, 6, 6, 20 );wm.setToolTip( w, "" );w.setLabel( "" );var w = wm.findWidgetById( "w2" );w.setActiveControl( wm.findWidgetById( "w542" ) );org.eclipse.swt.WidgetManager.getInstance().focus( "w542" );org.eclipse.swt.FontSizeCalculation.measureStrings( [ [ 32479971, "Fehler löschen", [ "Tahoma" ], 12, false, false, -1 ] ] );
Comment 1 Ralf Sternberg CLA 2010-08-02 09:03:18 EDT
I wasn't able to reproduce this problem so far. Could you please add a snippet?
Comment 2 Ralf Sternberg CLA 2010-08-30 05:11:53 EDT
Created attachment 177707 [details]
Snippet to reproduce

I was able to reproduce this problem with the attached snippet.
Steps to reproduce:
1. click on the link
2. click on the "restore" button
3. see this error message in the firebug console:
  hyperlinks[this._currentFocusedLink] is undefined
  in: hyperlinks[ this._currentFocusedLink ].blur();
Comment 3 Ralf Sternberg CLA 2010-08-30 10:00:35 EDT
Created attachment 177728 [details]
Patch against RAP 1.3

Attached a patch that fixes the problem for RAP 1.3
Comment 4 Ivan Furnadjiev CLA 2010-08-30 10:16:30 EDT
Ralf, I think that resetting this._currentFocusedLink to -1 in Link.js#clear() is better. What do you think?
Comment 5 Ralf Sternberg CLA 2010-08-30 11:54:35 EDT
(In reply to comment #4)
> Ralf, I think that resetting this._currentFocusedLink to -1 in Link.js#clear()
> is better. What do you think?

Good point. I agree that the focus index should be reset to -1 in clear().
But since I saw those range checks in _onKeyPress, i wanted to be on the safe side for the service release.
Comment 6 Ralf Sternberg CLA 2010-08-30 11:58:12 EDT
Created attachment 177746 [details]
Updated patch against RAP 1.3

This patch resets the focus index to -1 in clear() as suggested in comment #4 AND adds range checks in _setFocusedLink()
Comment 7 Ralf Sternberg CLA 2010-08-30 12:30:27 EDT
Fixed in CVS HEAD. The problem was caused by the field _currentFocusedLink being out of range in Link.js, _setFocusedLink().
Comment 8 Ivan Furnadjiev CLA 2010-08-31 10:19:25 EDT
Applied last patch to maintenance 1.3 branch.