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 11:34  |
Eclipse User |
|
|
|
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 #1396895 is a reply to message #1396589] |
Tue, 08 July 2014 19:50  |
Eclipse User |
|
|
|
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: Tue, 08 July 2014 20:00] by Moderator
|
|
|
Goto Forum:
Current Time: Sat Aug 30 14:35:45 EDT 2025
Powered by FUDForum. Page generated in 0.03268 seconds
|