<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Source Rebels&#187; Javascript</title>
	<atom:link href="http://www.sourcerebels.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sourcerebels.com/blog</link>
	<description>Por Edu Rodríguez Castillo</description>
	<lastBuildDate>Sat, 03 Jul 2010 06:03:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Simple Javascript call from Java / Llamada simple a Javascript desde Java</title>
		<link>http://www.sourcerebels.com/blog/simple-javascript-call-from-java-llamada-simple-a-javascript-desde-java/</link>
		<comments>http://www.sourcerebels.com/blog/simple-javascript-call-from-java-llamada-simple-a-javascript-desde-java/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:45:14 +0000</pubDate>
		<dc:creator>Edu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.sourcerebels.com/blog/?p=235</guid>
		<description><![CDATA[Simple call / Llamada simple: 1 2 3 4 5 6 7 8 9 10 11 try &#123; ScriptEngineManager factory = new ScriptEngineManager&#40;&#41;; ScriptEngine engine = factory.getEngineByName&#40;&#34;JavaScript&#34;&#41;; &#160; //Simple call to println javascript function engine.eval&#40;&#34;println('Texto JavaScript')&#34;&#41;; &#160; &#125; catch &#40;ScriptException ex&#41; &#123; &#160; //Do something &#125; Calling a function / Llamando a una función: 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Simple call / Llamada simple:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
	ScriptEngineManager factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ScriptEngineManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	ScriptEngine engine <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getEngineByName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JavaScript&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Simple call to println javascript function </span>
	engine.<span style="color: #006633;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;println('Texto JavaScript')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ScriptException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Do something</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Calling a function / Llamando a una función:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	ScriptEngineManager factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ScriptEngineManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	ScriptEngine engine <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getEngineByName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JavaScript&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	engine.<span style="color: #006633;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;function amessagefunction(atext){ return 'The secret message is ' + atext;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Invocable invocable <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Invocable<span style="color: #009900;">&#41;</span> engine<span style="color: #339933;">;</span>
	<span style="color: #003399;">Object</span> object <span style="color: #339933;">=</span> invocable.<span style="color: #006633;">invokeFunction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;amessagefunction&quot;</span>, <span style="color: #0000ff;">&quot;abc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">NoSuchMethodException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Do something</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ScriptException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Something is wrong, perhaps</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sourcerebels.com/blog/simple-javascript-call-from-java-llamada-simple-a-javascript-desde-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
