|
Re: two questions about custom widget? [message #1239602 is a reply to message #1237240] |
Tue, 04 February 2014 15:19 |
Tim Buschtoens Messages: 396 Registered: July 2009 |
Senior Member |
|
|
Hello.
> 1,how to load and apply CSS with custom class( .myClass {...}) to custom
> widgets ?
If you talk about the custom theming support (i.g. RWT.CUSTOM_VARIANT),
we currently do not have public API for that.
If you want to simply include CSS files with your custom widget to load
directly into the browser, you need to register them as a resource (just
like the JS file) and attach them to the documents head at runtime.
There are a number of solutions for that, e.g.:
http://www.codeproject.com/Articles/591062/How-to-add-JavaScript-and-CSS-f
Take care not to add the same CSS file twice. If you are creating a
browser widget based custom widget you can also generate your html at
runtime and add it into the head then.
> 2,with browser-based widgets, how to pass json to javascript function?
> In my code below, I try to execute javascript function with json param,
> but not work.
>
> StringBuffer script = new StringBuffer();
> script.append( "init(JSON.parse(");
> script.append(json);
> script.append("));" );
> BrowserUtil.evaluate(browser, script.toString(), new
> BrowserCallback() {
> @Override
> public void evaluationSucceeded(Object result) {
> System.out.println("javascript run succeed!");
> }
> @Override
> public void evaluationFailed(Exception exception) {
> System.out.println("javascript run failed!");
> }
> });
Your JSON string is likely already parsed by putting it in the
"evaluate" method. Unless you are actually escaped your JSON into a
JavaScript string you can (must) skip the "JSON.parse" call.
Greetings,
Tim
--
Tim Buschtöns
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Powered by
FUDForum. Page generated in 0.03913 seconds