Miles to go …

August 24, 2007

jMaki, PHP and GlassFish – again using Caucho Quercus

Filed under: web2.0 — arungupta @ 6:00 am

jMaki is a light-weight framework for build Web 2.0 applications. It provides support for multiple languages – Java (1, 2, 3, 4, 5, 6) , PHP, Ruby (1, 2), Phobos (1). The numbers in parentheses indicate the entries that I’ve created showing jMaki support for that language. As evident, I’ve not created a single entry for PHP yet. This entry is going to change that :)

This entry shows how to deploy a jMaki-enabled PHP web application in GlassFish. It builds upon an earlier entry that showed how to deploy a simple PHP application in GlassFish.

  1. PHP-enable GlassFish and verify it’s working correctly following these steps.
  2. Build, Install and Run a simple jMaki/PHP sample
    1. Download and Unzip the contents of jMaki/PHP release (0.9.7.2 as of this writing). This creates "jmaki-php-0.9.7.2\jmaki-php" in the current directory.
    2. Go to "jmaki-php-0.9.7.2\jmaki-php\core" and invoke "ant". This creates "dist\jmaki-core.zip".
    3. Unzip the contents of "jmaki-core.zip" under the "web" directory of the project created in the link followed from first step.
    4. Redeploy your project and your first jMaki widget in a PHP page deployed on GlassFish is now available at "http://localhost:8080/hellophp/jmaki-core/index.php".

      If you look at "index.php" in the IDE, the page contains the following code fragments:

      <?php addWidget("hello"); ?>

      <?php addWidget( array( "name" => "hello2",
                              "args" => "{name: 'Duke'}")
      ); ?>

      If you look at the source code of the generated page, the PHP code is converted to JavaScript code as shown below:

      <link type='text/css' rel='stylesheet' href='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello/component.css'></link>
      <script type='text/javascript' src='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello/component.js'></script>
      <script type='text/javascript'>
        jmaki.addWidget({uuid:"hello_2",
                         name:"hello",
                         widgetDir:"http://localhost:8080:8080/hellophp/jmaki/resources/hello",
                         script:"http://localhost:8080:8080/hellophp/jmaki/resources/hello/component.js"});
      </script>

      and

      <link type='text/css' rel='stylesheet' href='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2/component.css'></link>
      <script type='text/javascript' src='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2/component.js'></script>
        <div id="hello2_3" class="hello2"></div>
        <script type='text/javascript'>
        jmaki.addWidget({uuid:"hello2_3",
                         name:"hello2",
                         widgetDir:"http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2",
                         args: {name: 'Duke'},
                         script:"http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2/component.js"});
      </script>

      Notice the JavaScript code shows the host + port as "localhost:8080:8080". This issue is followed here.

  3. Build, Install and Run a slightly advanced sample.
    1. Go to "jmaki-php-0.9.7.2\jmaki-php\samples\loadtable" and invoke "ant". This creates "dist\jmaki-loadtable-php-0.9.7.2.zip".
    2. Unzip the contents of this zip file under the "web" directory of your project.
    3. Redeploy you project and the sample is now deployed at "http://localhost:8080/hellophp/web/jmaki-loadtable/index.php".

      This sample shows a Dojo DataTable loading static data. The code fragment to add the widget to the page is:

      <?php
        addWidget('dojo.table', null, null, null, "tabledata.json");
      ?>

      You can look at the generated source using "View Source". A nice twi
      st to try is to dynamically load the data from a database using JPA as shown here.

None of the samples that use XMLHttpProxy (rssData, cl-mashup and mapit) will work because I could not find XSLT extension for Quercus. This issue is followed here. Other users have asked similar question with no clear answer.

Technorati: jmaki php glassfish web2.0 caucho quercus

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. PHP in GlassFish using Caucho Quercus
  2. TOTD #20: How to create a new jMaki widget ?
  3. GlassFish Interview with Ian Skerrett at EclipseCon 2009
  4. jMaki publish/subscribe and debugging
  5. jMaki on Rails For Dummies

1 Comment »

  1. [Trackback] The first ever The Rich Web Experience 2007 just got over and I enjoyed participating in the conference. This conference is part of No Fluff Just Stuff Symposium series and truly lived up to it’s name and these are…

    Comment by Arun Gupta's Blog — September 8, 2007 @ 7:08 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress