Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » error occurred when adding markup to grid!
error occurred when adding markup to grid! [message #1394606] Sat, 05 July 2014 15:34 Go to next message
Song David is currently offline Song DavidFriend
Messages: 191
Registered: April 2011
Senior Member
Hi, I try to add a markup image click event to grid, but error occurred and the code snippets as below,

private String getTag(){
		StringBuffer builder = new StringBuffer();
		builder.append("<a href=\"graphic_info");
		builder.append("\" target=\"_rwt\" style=\"text-decoration:none;\">");
		builder.append(createImageTag("Graphic Info", graphicBtn));
		builder.append("</a> ");
		builder.append("<a href=\"broken_info");
		builder.append("\" target=\"_rwt\" style=\"text-decoration:none;\">");
		builder.append(createImageTag("Broked Info", brokedBtn));
		builder.append("</a> ");
		return builder.toString();
	}


grid.addSelectionListener( new SelectionAdapter() {
			  public void widgetSelected( SelectionEvent event ) {
			    if( event.detail == RWT.HYPERLINK ) {
			    	if("graphic_info".equals(event.text)){
			    	  ...
			    	}else if("broken_info".equals(event.text)){
                                  ...
			    	}
			    }
			  }
		});



and the error code is
2014-07-05 23:19:16.188:WARN:oejs.ServletHandler:ERROR:  /
java.lang.UnsupportedOperationException: Not a number: null
	at org.eclipse.rap.json.JsonValue.asInt(JsonValue.java:304)
	at org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.readIndex(GridOperationHandler.java:253)
	at org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.handleNotifySelection(GridOperationHandler.java:182)
	at org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.handleNotify(GridOperationHandler.java:69)
	at org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.handleNotify(GridOperationHandler.java:1)
	at org.eclipse.rap.rwt.internal.protocol.ControlOperationHandler.handleNotify(ControlOperationHandler.java:1)
	at org.eclipse.rap.rwt.internal.protocol.WidgetOperationHandler.handleNotify(WidgetOperationHandler.java:51)
	at org.eclipse.rap.rwt.internal.protocol.ProtocolUtil.handleOperation(ProtocolUtil.java:70)
	at org.eclipse.rap.rwt.internal.lifecycle.AbstractWidgetLCA.readData(AbstractWidgetLCA.java:53)
	at org.eclipse.nebula.widgets.grid.internal.gridkit.GridLCA.readData(GridLCA.java:106)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA$3.doVisit(DisplayLCA.java:142)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor$AllWidgetTreeVisitor.visit(WidgetTreeVisitor.java:40)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:52)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA.visitWidgets(DisplayLCA.java:147)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA.readData(DisplayLCA.java:66)
	at org.eclipse.rap.rwt.internal.lifecycle.ReadData.execute(ReadData.java:27)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.continueLifeCycle(RWTLifeCycle.java:150)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.sleep(RWTLifeCycle.java:230)
	at org.eclipse.swt.widgets.Display.sleep(Display.java:1253)
	at org.eclipse.rap.rwt.application.AbstractEntryPoint.createUI(AbstractEntryPoint.java:63)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:172)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:284)
	at java.lang.Thread.run(Unknown Source)
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:105)
Re: error occurred when adding markup to grid! [message #1396589 is a reply to message #1394606] Tue, 08 July 2014 14:16 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 387
Registered: July 2009
Senior Member
Hi.

I can not reproduce the issue with RAP 2.3.0. Which RAP version are you
using? Which exact browser?

Greetings,
Tim

Am 05.07.2014 17:34, schrieb Song David:
> Hi, I try to add a markup image click event to grid, but error occurred
> and the code snippets as below,
>
> private String getTag(){
> StringBuffer builder = new StringBuffer();
> builder.append("<a href=\"graphic_info");
> builder.append("\" target=\"_rwt\"
> style=\"text-decoration:none;\">");
> builder.append(createImageTag("Graphic Info", graphicBtn));
> builder.append("</a> ");
> builder.append("<a href=\"broken_info");
> builder.append("\" target=\"_rwt\"
> style=\"text-decoration:none;\">");
> builder.append(createImageTag("Broked Info", brokedBtn));
> builder.append("</a> ");
> return builder.toString();
> }
>
>
> grid.addSelectionListener( new SelectionAdapter() {
> public void widgetSelected( SelectionEvent event ) {
> if( event.detail == RWT.HYPERLINK ) {
> if("graphic_info".equals(event.text)){
> ...
> }else if("broken_info".equals(event.text)){
> ...
> }
> }
> }
> });
>
>
> and the error code is
>
> 2014-07-05 23:19:16.188:WARN:oejs.ServletHandler:ERROR: /
> java.lang.UnsupportedOperationException: Not a number: null
> at org.eclipse.rap.json.JsonValue.asInt(JsonValue.java:304)
> at
> org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.readIndex(GridOperationHandler.java:253)
>
> at
> org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.handleNotifySelection(GridOperationHandler.java:182)
>
> at
> org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.handleNotify(GridOperationHandler.java:69)
>
> at
> org.eclipse.nebula.widgets.grid.internal.gridkit.GridOperationHandler.handleNotify(GridOperationHandler.java:1)
>
> at
> org.eclipse.rap.rwt.internal.protocol.ControlOperationHandler.handleNotify(ControlOperationHandler.java:1)
>
> at
> org.eclipse.rap.rwt.internal.protocol.WidgetOperationHandler.handleNotify(WidgetOperationHandler.java:51)
>
> at
> org.eclipse.rap.rwt.internal.protocol.ProtocolUtil.handleOperation(ProtocolUtil.java:70)
>
> at
> org.eclipse.rap.rwt.internal.lifecycle.AbstractWidgetLCA.readData(AbstractWidgetLCA.java:53)
>
> at
> org.eclipse.nebula.widgets.grid.internal.gridkit.GridLCA.readData(GridLCA.java:106)
>
> at
> org.eclipse.swt.internal.widgets.displaykit.DisplayLCA$3.doVisit(DisplayLCA.java:142)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor$AllWidgetTreeVisitor.visit(WidgetTreeVisitor.java:40)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:52)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.handleChildren(WidgetTreeVisitor.java:127)
>
> at
> org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
>
> at
> org.eclipse.swt.internal.widgets.displaykit.DisplayLCA.visitWidgets(DisplayLCA.java:147)
>
> at
> org.eclipse.swt.internal.widgets.displaykit.DisplayLCA.readData(DisplayLCA.java:66)
>
> at
> org.eclipse.rap.rwt.internal.lifecycle.ReadData.execute(ReadData.java:27)
> at
> org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.continueLifeCycle(RWTLifeCycle.java:150)
>
> at
> org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.sleep(RWTLifeCycle.java:230)
>
> at org.eclipse.swt.widgets.Display.sleep(Display.java:1253)
> at
> org.eclipse.rap.rwt.application.AbstractEntryPoint.createUI(AbstractEntryPoint.java:63)
>
> at
> org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:172)
>
> at
> org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:284)
>
> at java.lang.Thread.run(Unknown Source)
> at
> org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:105)
>

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: error occurred when adding markup to grid! [message #1396895 is a reply to message #1396589] Tue, 08 July 2014 23:50 Go to previous message
Song David is currently offline Song DavidFriend
Messages: 191
Registered: April 2011
Senior Member
Hi Tim,

My RAP version is 2.3.0 and I tested on IE 10, Firefox 30 and Chrome 35, and I met the same error.
Thanks

private void createGrid(final Composite parent) {
		grid = new Grid(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		grid.setData( RWT.MARKUP_ENABLED, Boolean.TRUE );
		grid.setData(RWT.FIXED_COLUMNS, 2);
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(SWT.DEFAULT, 460).grab(true, false).applyTo(grid);
		
		grid.setHeaderVisible( true );
		grid.setLinesVisible( true );
		
		grid.addSelectionListener( new SelectionAdapter() {
			  public void widgetSelected( SelectionEvent event ) {
				  
			    if( event.detail == RWT.HYPERLINK ) {
			    	if("graphic_info".equals(event.text)){
			    		...					
			    	}else if("broken_info".equals(event.text)){
			    		...
			    	}
			    }
			  }
		});
		
		createColumn( grid, null, "Workshop", 80, SWT.CENTER );
		createColumn( grid, null, "Machine", 80, SWT.CENTER );
		createColumn( grid, null, "Worker", 100, SWT.CENTER );
		createColumn( grid, null, "Line", 80, SWT.CENTER );
		createColumn( grid, null, "Time", 100, SWT.CENTER );
		
		
	}

	private GridColumn createColumn( Grid grid, GridColumnGroup group, String name, int width, int style ){
		GridColumn column;
		if( group == null ) {
			column = new GridColumn( grid, style );
		} else {
			column = new GridColumn( group, style );
		}
		column.setText( name );
		column.setWidth( width );
		return column;
	}
	
	
	
	private void queryReport(){
		grid.removeAll();
		
		GridColumnGroup group = new GridColumnGroup(grid, SWT.CENTER);
    	group.setText("Output(kg)");
		for(int i=1;i<6;i++){
			createColumn(grid, group, String.valueOf(i) + "Level", 100, SWT.CENTER);
		}
	}
	
	
	private void setInput(){
		grid.removeAll();
		GridItem gridItem = new GridItem( grid, SWT.NONE );
		gridItem.setText(getTag());
		for(int i=1; i<10;i++){
			gridItem.setText(i,String.valueOf(i));//workshop name
		}
	}
	
	private String getTag(){
		StringBuffer builder = new StringBuffer();
		builder.append("<a href=\"broken_info");
		builder.append("\" target=\"_rwt\" style=\"text-decoration:none;\">");
		builder.append(createImageTag("Broken Count", breakCountBtn));
		builder.append("</a> ");
		builder.append("<a href=\"graphic_info");
		builder.append("\" target=\"_rwt\" style=\"text-decoration:none;\">");
		builder.append(createImageTag("Line Info", breakLineBtn));
		builder.append("</a> ");
		return builder.toString();
	}
	
	private String createImageTag(String title, String url) {
		return "<img src='" + url
				+ "' width='16' height='16' style='padding-right:5px;border:none' title='" + title + "'/>";
	}
	
	private void registerImages() {
		try {
			breakLineBtn = registerImage("resources/twister_break.png");
			breakCountBtn = registerImage("resources/twister_bcount.png");
		} catch (IOException exception) {
			throw new RuntimeException("Failed to register images", exception);
		}
	}
	
	private static String registerImage(String resourceName) throws IOException {
		ResourceManager resourceManager = RWT.getResourceManager();
		if (!resourceManager.isRegistered(resourceName)) {
			InputStream inputStream = CLASSLOADER.getResourceAsStream(resourceName);
			if (inputStream == null) {
				throw new RuntimeException("Resource not found");
			}
			try {
				resourceManager.register(resourceName, inputStream);
			} finally {
				inputStream.close();
			}
		}
		return resourceManager.getLocation(resourceName);
	}

[Updated on: Wed, 09 July 2014 00:00]

Report message to a moderator

Previous Topic:Behavior of the URLLauncher service on different Browsers
Next Topic:Use "RAP Target Platform" as deployment platform or run an extra application server?
Goto Forum:
  


Current Time: Fri Feb 27 17:01:27 GMT 2015

Powered by FUDForum. Page generated in 0.02067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software