<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Joe Walker - jaxer tag</title>
  <link>http://directwebremoting.org/blog/joe/tags/jaxer/</link>
  <description>Thoughts on Web Development</description>
  <language>en</language>
  <copyright>Joe Walker</copyright>
  <lastBuildDate>Wed, 19 Nov 2008 13:17:20 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>DWR + Aptana Jaxer</title>
    <link>http://directwebremoting.org/blog/joe/2008/03/04/dwr_aptana_jaxer.html</link>
    
      
        <description>
          &lt;p&gt;I&#039;ve been working with the guys from &lt;a href=&#034;http://www.aptana.com/&#034;&gt;Aptana&lt;/a&gt; for the past week or so on adapting &lt;a href=&#034;http://getahead.org/dwr&#034;&gt;DWR&lt;/a&gt; to be a remoting layer for &lt;a href=&#034;http://www.aptana.com/jaxer/&#034;&gt;Jaxer&lt;/a&gt;.&lt;/p&gt;

&lt;p style=&#034;float:right&#034;&gt;&lt;a href=&#034;http://www.aptana.com/jaxer/&#034;&gt;&lt;img src=&#034;http://getahead.org/images/jaxer-pageflow.png&#034; alt=&#034;jaxer page flow&#034; title=&#034;Jaxer&#034; border=&#034;0&#034;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jaxer is a way to run JavaScript on the server. But it&#039;s not just JavaScript as an alternative to Java/Ruby/PHP/etc. Jaxer is Mozilla, on the server, with it&#039;s face ripped off and replaced by a snorkel to serialize the DOM to a web browser. &lt;a href=&#034;http://ejohn.org/blog/server-side-javascript-with-jaxer/&#034;&gt;John has a great introduction&lt;/a&gt;, or there&#039;s the &lt;a href=&#034;http://ajaxian.com/archives/audible-ajax-episode-24-aptana-jaxer-talk&#034;&gt;podcast that Ajaxian did&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The vision with DWR was always to say: We&#039;ve got Javascript in the browser, and Java on the server - lets connect them in the best possible way. This leads to the migration of view logic from the server to the client. But it&#039;s not safe to move it all; Validation is part of view logic, but that needs to be done on the server. With Jaxer you can specify scripts to be &lt;code&gt;runat=&#034;server&#034;&lt;/code&gt; or &lt;code&gt;runat=&#034;both&#034;&lt;/code&gt; to allow validation or other logic to be run in both places.&lt;/p&gt;

&lt;p&gt;Some of the changes that we&#039;ve made to DWR will only help you if you are using DWR inside Jaxer, but others could be generally useful.&lt;/p&gt;

&lt;p&gt;There are 2 basic changes. DWR on the Internet needs to make sure that the Internet only touches the code that you want it to touch. DWR in Jaxer doesn&#039;t have this problem because it&#039;s not accessible from the Internet, so we can do away with almost all configuration. Secondly latency inside a server-room is tiny compared with the net, which makes synchronous XHR viable.&lt;/p&gt;

&lt;p&gt;So as it stands at the moment in development, you can use DWR inside Jaxer like this (clearly this is subject to change):&lt;/p&gt;

&lt;pre&gt;
&amp;lt;&lt;span style=&#039;color:#800;&#039;&gt;script&lt;/span&gt; &lt;span style=&#039;color:#880;&#039;&gt;type&lt;/span&gt;=&lt;span style=&#039;color:#080;&#039;&gt;&#039;text/javascript&#039;&lt;/span&gt; &lt;span style=&#039;color:#880;&#039;&gt;runat&lt;/span&gt;=&lt;span style=&#039;color:#080;&#039;&gt;&#034;server&#034;&lt;/span&gt;&amp;gt;
Jaxer.dwr.pathToDwrServlet = &lt;span style=&#039;color:#080;&#039;&gt;&#034;http://localhost:8080/demoServer/dwr&#034;&lt;/span&gt;;
Jaxer.dwr.require(&lt;span style=&#039;color:#080;&#039;&gt;&#034;util&#034;&lt;/span&gt;, &lt;span style=&#039;color:#080;&#039;&gt;&#034;new/org.example.Demo&#034;&lt;/span&gt;);

&lt;span style=&#039;color:#00A;&#039;&gt;function&lt;/span&gt; loadServer() {
  &lt;span style=&#039;color:#00A;&#039;&gt;var&lt;/span&gt; data = Demo.getData();
  dwr.util.setValue(&lt;span style=&#039;color:#080;&#039;&gt;&#039;fillFromServer&#039;&lt;/span&gt;, data);
}
&amp;lt;/&lt;span style=&#039;color:#800;&#039;&gt;script&lt;/span&gt;&amp;gt;
&lt;/pre&gt;

&lt;p&gt;There are a number of benefits that come out of this even if you&#039;re not using Jaxer:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In dwr.xml you needed to specify javascript=&#039;ScriptName&#039;. If (as is common) ScriptName == Class.getShortName then you can just drop the attribute, it will default properly.&lt;/li&gt;
&lt;li&gt;Cross domain remoting is now automatically detected, and scriptTag remoting is used if needed.&lt;/li&gt;
&lt;li&gt;There is a new init-param &#039;useAbsolutePaths&#039; which might help people with trouble remapping DWR&#039;s location.&lt;/li&gt;
&lt;li&gt;All URLs are now reconfigurable.&lt;/li&gt;
&lt;li&gt;If you are using DWR in synchronous mode (which I don&#039;t recommend on the Internet) then you can use returned data in the normal way without needing a callback.&lt;/li&gt;
&lt;/ul&gt;

        </description>
      
      
    
    
    
    <comments>http://directwebremoting.org/blog/joe/2008/03/04/dwr_aptana_jaxer.html#comments</comments>
    <guid isPermaLink="true">http://directwebremoting.org/blog/joe/2008/03/04/dwr_aptana_jaxer.html</guid>
    <pubDate>Tue, 04 Mar 2008 14:29:07 GMT</pubDate>
  </item>
  
  </channel>
</rss>
