| 
| Custom widget [message #43930] | Wed, 29 August 2007 14:11  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: giuliapo.gmail.com 
 Hi all.
 
 I'm in the middle of a custom widget. And I'm trying to pass an
 Integer[][] from java to javascript using the LCA class.
 
 I have managed to pass a String, an int and Integer[].
 
 But what I really need is to pass an Integer [][].
 
 I'm using the same method for the several types that I managed to pass
 in the LCA class. It is like this:
 
 writer.set(ChartLCA.PROP_ADDRESS, ChartLCA.JS_PROP_ADDRESS,
 Object)c.getInt());
 
 the getInt() returns the supposed Integer[][].
 
 Any ideas? Anyone needs more information?
 
 Thank you all for the time.
 |  |  |  | 
| 
| Re: Custom widget [message #43999 is a reply to message #43930] | Thu, 30 August 2007 15:12  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: rherrmann.innoopract.com 
 Bruno,
 
 the JSWriter methods currently only handle one-dimensional arrays. You
 would have to construct the two-dimensional array by yourself. The code
 snippet below shows how this would look like.
 
 static void set( JSWriter writer,
 String functionName,
 Integer[][] array )
 throws IOException
 {
 StringBuffer buffer = new StringBuffer();
 buffer.append( "[" );
 for( int i = 0; i < array.length; i++ ) {
 buffer.append( "[" );
 for( int k = 0; k < array[ i ].length; k++ ) {
 Integer value = array[ i ][ k ];
 buffer.append( value );
 if( k < array[ i ].length - 1 ) {
 buffer.append( "," );
 }
 }
 buffer.append( "]" );
 if( i < array.length - 1 ) {
 buffer.append( "," );
 }
 }
 buffer.append( "]" );
 // wrap in JSVar to prevent JSWriter from quoting the string
 Object[] args = new Object[] { new JSVar( buffer.toString() ) };
 writer.call( functionName, args );
 }
 
 Please note that you still would have to determine if the integer array
 has changed and thus writing the JavaScript code is necessary at all.
 
 HTH
 Rüdiger
 
 
 Bruno Vieira wrote:
 > Hi all.
 >
 > I'm in the middle of a custom widget. And I'm trying to pass an
 > Integer[][] from java to javascript using the LCA class.
 >
 > I have managed to pass a String, an int and Integer[].
 >
 > But what I really need is to pass an Integer [][].
 >
 > I'm using the same method for the several types that I managed to pass
 > in the LCA class. It is like this:
 >
 > writer.set(ChartLCA.PROP_ADDRESS, ChartLCA.JS_PROP_ADDRESS,
 > Object)c.getInt());
 >
 > the getInt() returns the supposed Integer[][].
 >
 > Any ideas? Anyone needs more information?
 >
 > Thank you all for the time.
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03303 seconds