<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Spikes Of Nothingness - action tag</title>
  <link>http://weblog.flop.ca/tags/action/</link>
  <description>Florin T.PATRASCU&#039;s blog</description>
  <language>en</language>
  <copyright>Florin T.PATRASCU</copyright>
  <lastBuildDate>Sat, 12 May 2012 02:12:08 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>JRuby actions in JPublish</title>
    <link>http://weblog.flop.ca/2007/07/17/1184705235053.html</link>
    
      
        <description>
          &lt;p&gt;  &lt;/p&gt;
As some of you already know, &lt;a href=&#034;http://code.google.com/p/jpublish/&#034;&gt;JPublish&lt;/a&gt; can execute &lt;a href=&#034;http://code.google.com/p/jpublish/wiki/Actions&#034;&gt;actions&lt;/a&gt; written in &lt;a href=&#034;http://jruby.codehaus.org/&#034;&gt;JRuby&lt;/a&gt;. This is all possible through the magic of the &lt;a href=&#034;http://www.headius.com/jrubywiki/index.php/Java_Integration&#034;&gt;BSF&lt;/a&gt; :)&lt;br /&gt;
&lt;br /&gt;
I received a lot of questions about how can a JRuby Action use the java objects available in the &lt;a href=&#034;http://code.google.com/p/jpublish/wiki/Context&#034;&gt;JPublishContext&lt;/a&gt;?&lt;br /&gt;
&lt;br /&gt;
There&#039;s nothing simpler than that, in JPublish is easy :) Below is the body of a JRuby Action which will print a message to the designated console log and will populate the page context with the variable &amp;quot;hello&amp;quot;. The variable &amp;quot;hello&amp;quot; will be accessible to Velocity or Freemarker during the post action execution rendering process.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;font color=&#034;#333399&#034;&gt;&lt;em&gt;&lt;strong&gt;&lt;font color=&#034;#000000&#034;&gt;HelloJRuby.rb&lt;/font&gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
require &#039;java&#039;&lt;br /&gt;
$syslog.info(&amp;quot;&lt;/font&gt;&lt;font color=&#034;#333399&#034;&gt;HelloJRuby&lt;/font&gt;&lt;font color=&#034;#333399&#034;&gt;.rb action ...&amp;quot;)&lt;br /&gt;
$context.put(&amp;quot;hello&amp;quot;, &amp;quot;Hello World!&amp;quot;)&lt;br /&gt;
&lt;/font&gt;&lt;/blockquote&gt;&lt;br /&gt;
Simple, eh? Use the dollar sign in front of the variables you expect to find in the context.&lt;br /&gt;
&lt;br /&gt;
Also, there is a recent web site with a lot of JRuby news and tips, check it out in case you&#039;re interested. Is called &lt;a href=&#034;http://www.jrubyinside.com/&#034;&gt;JRuby Inside&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Cheers!
        </description>
      
      
    
    
    
    <category>Ruby</category>
    
    <category>Java</category>
    
    <comments>http://weblog.flop.ca/2007/07/17/1184705235053.html#comments</comments>
    <guid isPermaLink="true">http://weblog.flop.ca/2007/07/17/1184705235053.html</guid>
    <pubDate>Tue, 17 Jul 2007 20:47:15 GMT</pubDate>
  </item>
  
  </channel>
</rss>

