0

In our application we get an ugly exception (parser) when having a string that contains a character like &.

For now we replace these characters using StringEscapeUtils.escapeXml(aLabel). Is this the proper way because the label in our tableView shows the escaped character instead of a clean &

Thanks, Vincent

3 Answers3

0

The '&' character is used for the mnemonics in SWT/RAP/Tabris. They are usually used to mark a character in a menu or button with an underline for keyboard navigation. On the Tabris clients for iOS and Android we don't display mnemonics, as we don't have a keyboard navigation as on the desktop - but they should cause no problems if they are set.

So, where does this exception happen? On the server, the Android or iOS client?

Jordi
  • 617
  • 6
  • 10
0

Jordi, the exception happens in the server in the method getColumnText.

public String getColumnText( Object element, int columnIndex ) {
      return text;
}

The exception happens when the text is a string containing '&' like in "Billy & Jean"

This is the exception:

Exception occurred

java.lang.IllegalArgumentException: Failed to parse markup text at    org.eclipse.swt.internal.widgets.MarkupValidator.validate(MarkupValidator.java:60)    at org.eclipse.swt.widgets.TreeItem.setText(TreeItem.java:978)  at org.eclipse.jface.viewers.TreeViewerRow.setText(TreeViewerRow.java:176) at org.eclipse.jface.viewers.ViewerCell.setText(ViewerCell.java:162) at org.eclipse.jface.viewers.TableColumnViewerLabelProvider.update(TableColumnViewerLabelProvider.java:70)  at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:155)    at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:935)   at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:103)     at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:130)     at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:177)
0

The exception you see does not come form tabris. It comes from RAP. I assume you are using tree/table.setData( RWT.MARKUP_ENABLED, Boolean.TRUE ); right?

When using markup only a subset of HTML is allowed, see http://download.eclipse.org/rt/rap/doc/2.2/guide/reference/api/org/eclipse/rap/rwt/RWT.html#MARKUP_ENABLED

So, when you are using markup and you want to have an & character you need to use it's entity: &

But please note: Basic markup is only supported in Tabris with version 1.4 (release 2014, June 26th)

Holger
  • 437
  • 2
  • 4