Re: call average inside eval()
On 27 juin, 00:12, bhomass wrote: > I am using a native method to call eval() on a valid javascript > statement. > > private String[] evalscript(String javascript, String format){ > return evalJavascript(javascript, > format).toString().split(","); > } > > private native Object evalJavascript(String javascript, String > format)/*-{ > > result = eval(javascript); > > return result; > > } > > This works generally. But I also need to use custom javascript > functions like average()l > > function average() > { > var items = average.arguments.length > var sum = 0 > for (i = 0; i < items;i++) > { > sum += average.arguments[i] > } > return (sum/items) > > } > > I can put this average() as another native method inside the same > class. but I can't figure out how to get eval to look it up. > > do I have to spell out the whole gwt naming convention > th...@myclass::average()(); ? You'd probably have to put the function in the global scope (window.average = function() { ... }; note window, not $wnd here). -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: call average inside eval()
Nice! 2010/6/26 bhomass > I am using a native method to call eval() on a valid javascript > statement. > >private String[] evalscript(String javascript, String format){ >return evalJavascript(javascript, > format).toString().split(","); >} > > >private native Object evalJavascript(String javascript, String > format)/*-{ > >result = eval(javascript); > >return result; > > } > > This works generally. But I also need to use custom javascript > functions like average()l > > function average() > { > var items = average.arguments.length > var sum = 0 > for (i = 0; i < items;i++) > { > sum += average.arguments[i] > } > return (sum/items) > } > > I can put this average() as another native method inside the same > class. but I can't figure out how to get eval to look it up. > > do I have to spell out the whole gwt naming convention > th...@myclass::average()(); ? > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
call average inside eval()
I am using a native method to call eval() on a valid javascript statement. private String[] evalscript(String javascript, String format){ return evalJavascript(javascript, format).toString().split(","); } private native Object evalJavascript(String javascript, String format)/*-{ result = eval(javascript); return result; } This works generally. But I also need to use custom javascript functions like average()l function average() { var items = average.arguments.length var sum = 0 for (i = 0; i < items;i++) { sum += average.arguments[i] } return (sum/items) } I can put this average() as another native method inside the same class. but I can't figure out how to get eval to look it up. do I have to spell out the whole gwt naming convention th...@myclass::average()(); ? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.