jMaki, PHP and GlassFish - again using Caucho Quercus

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 twist 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

Comments:

[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...

Posted by Arun Gupta's Blog on September 08, 2007 at 12:08 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today