Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.

http://blogs.sun.com/arungupta/date/20080327 Thursday March 27, 2008

Slides & Demos for Rails/GlassFish/jMaki session at TSS JS


As reported earlier, I presented on "Rails powered by GlassFish and jMaki" yesterday at The Server Side Java Symposium - Las Vegas. The slides are available here. The demos shown in the talk are available at:

Would you like to know why use GlassFish for Rails deployment ? Rails powered by the GlassFish Application Server provides all the details. All the latest information about JRuby and GlassFish effort can be found at GlassFish JRuby wiki or JRuby wiki.

As announced earlier, Ruby Developer Center is a new page launched earlier today and provides all the resources to get started with Ruby, JRuby, Ruby-on-Rails @ Sun.

Check out some pictures from the event:



Technorati: conf theserverside tssjs lasvegas rubyonrails ruby jruby glassfish netbeans jmaki

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080325 Tuesday March 25, 2008

Rails powered by GlassFish & jMaki @ The Server Side Java Symposium, Las Vegas - Mar 26, 2008

If you want to learn more about:

  • How to use GlassFish as development & deployment platform for Rails applications ?
  • How GlassFish v3 Gem provides a "green" alternative to WEBrick & Mongrel ?
  • How to use NetBeans & jMaki plug-in to embed rich widgets in your Rails applications ?
Then you can learn all about it in The Server Side Java Symposium, Las Vegas. Here are the coordinates:

Date: Mar 26, 2008
Time: 2:30 - 3:30pm
Track: Language & Coding
Title: Rails powered by GlassFish & jMaki

A popular statement for Las Vegas is What happens in Vegas, Stays in Vegas! But I promise to share all the slides & demos with you so that you can enjoy at least the technical part of it ;-)

Another interesting session worth attending is How to use the Metro Web services stack to Build Fast, Scalable Services by Kohsuke on Mar 26 (Wed) from 4:10 - 5:15pm.

Technorati: conf theserverside tssjs lasvegas rubyonrails glassfish jmaki netbeans metro webservices

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080312 Wednesday March 12, 2008

jMaki on Rails - Reloaded for NetBeans 6.1 beta & Rails 2.0


NetBeans 6.1 Beta was released last week. Amongst the many improvements, one of them is the bundled JRuby 1.1 RC2 and Rails 2.0.2. The jMaki plugin used to work fine with Rails 1.2.3 but need to be updated because of changed file name extensions for the default generated views (".rhtml.erb" instead of ".rhtml"). With this release of NetBeans, jMaki plugin has been updated to work in this configuration as well.

This blog provide detailed steps to install jMaki plugin, create a simple Rails 2.0 application using NetBeans IDE and update the generated scaffold to use a Yahoo Data Table widget for displaying the data. It is an update to screencast #web8, lets get started!

  1. Install the jMaki plugin - In NetBeans IDE, go to "Tools", "Plugins". Select "jMaki Ajax support" and click on "Install" button as shown in the following figure:



    Follow the instructions to install the plugin. The IDE is restarted after a successful install.
  2. Create a new Rails project
    1. Create a new Rails project by selecting "File", "New Project..." and selecting "Ruby" and "Ruby on Rails Application". Take all the defaults as shown below:


      and click on "Next >".
    2. Choose "Specify Database Information Directly" and specify the database configuration information as shown below:


      and click on "Finish". You need to make sure MySQL server is running.
  3. Generate Scaffold and Database structures
    1. Right-click on the newly created project, select "Generate..." and enter the values as shown below:


      and click on "OK". This creates a scaffold and model that would allow us to perform CRUD operations on Title, Author, ISBN and Description for a Book.
    2. Create the datbase by invoking db:create target. This is done by right-selecting the project, select "Run Rake Task", "db" and then "create" as shown below:


    3. Create the database tables by running "db:migrate" using the similar steps described above - "Run Rake Task", "db", "migrate".
  4. Add and Configure jMaki widget
    1. In the project, expand "Views", "books" and double-click on "index.rtml.erb" to edit it. This page is used to display all the books from the database table in an HTML table. It also shows links to perform CRUD operations on each book item. From the jMaki Yahoo palette, drag-and-drop a "Yahoo Data Table" right after "</table>" tag. The generated fragment looks like:



    2. The default generated code fragment shows 4 columns in the table. Lets add a new column to display the CRUD operations link. Add the following fragment:

      { :actions => 'Action', :id => 'actions' }

      right after

      { :label => 'Description', :id => 'description'}

      You also need to add a comma "," after the Descrption column fragment. The updated code looks like:

    3. Add the following Ruby fragment right before "<%= jmaki_widget" generated code:

      <%
      @rows_data = []
      for book in @books
        @rows_data << { :id => book.id,
          :title => book.title,
          :author => book.author,
          :isbn => book.isbn,
          :description => book.description,
          :actions => link_to('Show', book) + ' ' + link_to('Edit', edit_book_path(book)) + ' ' + link_to('Destroy', book, :confirm => 'Are you sure?', :method => :delete)
        }
      end
      %>


      This fragment creates a JSON array, @row_data, in the format expected by Yahoo Data Table widget, after retrieving the values from the database. 
    4. Finally, instead of reading the static values for columns, use the newly created "@row_data" to populate the values. The code with all the changes looks like as shown below:

  5. Run the project
    1. The scaffold is now accessible at http://localhost:3000/books. This page in the browser looks like:


    2. After adding couple of entries, the page looks like:

Previous entries that shows how jMaki can be used with Ruby-on-Rails in NetBeans IDE can seen here.

Technorati: netbeans jmaki jruby ruby rubyonrails mysql

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080128 Monday January 28, 2008

GlassFish at WebGuild Web 2.0 Conference & Expo 2008 - Jan 29

Sun Microsystems is a sponsor of WebGuild's Web 2.0 Conference & Expo and you can meet me at Sun booth in the exhibitor hall. Register for a FREE exhibitor pass here.

Ask me about:

  • How GlassFish provides an easy-to-use and production-quality development and deployment environment for your "Web 2.0" applications ?
  • How NetBeans IDE provides a rich extensible platform to create such applications ?
  • What is jMaki and how it allows you to use best tools & libraries to create Rich Internet Applications ?
  • How GlassFish is a "green" alternative for deploying JRuby-on-Rails applications ?
  • How RESTful Web services can be easily generated using Jersey from a database table ?
  • Or anything else you want to know :)

I will be at the WebGuild's Web 2.0 Conference & Expo

Technorati: conf jmaki jruby netbeans glassfish rubyonrails jruby jersey

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080126 Saturday January 26, 2008

"Rails powered by GlassFish & jMaki" @ South Bay Ruby Meetup - Jan 29, 7pm

I'll be speaking on "Rails powered by GlassFish & jMaki" at South Bay Ruby Meetup on Jan 29 (Tuesday) @ 7pm. Read more details here.

You'll learn:

  • How GlassFish provides an easy-to-use and production-quality development and deployment environment for your JRuby-on-Rails applications ?
  • How GlassFish is a "green" alternative for deploying JRuby-on-Rails applications ?
  • What is GlassFish v3 Gem ?
  • How jMaki allows you to create visually appealing views for Rails applications ?
  • How NetBeans provide first-class support for creating Rails applications ?

Thanks to Bala for providing an opportunity to talk about our efforts! Let's keep an interactive dialog and learn from each other :)

Technorati: conf jruby rubyonrails glassfish netbeans meetup

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080124 Thursday January 24, 2008

RESTful representation of "sakila" using GlassFish and NetBeans IDE

"sakila" is the sample database shipped with MySQL (pronounced as my ess-kew-ell). In the context of Sun Microsystems announcing the agreement to acquire MySQL, I'd like to dedicate this entry to show how this sample database can be exposed as a RESTful Web service endpoint and deployed on GlassFish using Jersey Tooling Plugin (0.4.1 with Jersey 0.4) in NetBeans IDE.

Lets get started!

  1. Install MySQL & the sample database "sakila".
    1. Download and Install MySQL Community Server.
    2. Download sakila sample database.
    3. Install the database as described here.
    4. Start MySQL database by giving the command 'mysqld-nt --user root --console' in bin directory on Windows or './bin/mysqld_safe' from MySQL directory on Unix flavors.
  2. Create the Project & Database Connection
    1. In NetBeans IDE, create a new Web project and name it as "sakila". Choose "GlassFish v2" as the "Server:".
    2. In the "Services" tab of NetBeans IDE, expand "Drivers" and add MySQL Connector/J driver if it does not exist already.
    3. Create a new new database connection by right-clicking on "Drivers" and specifying the parameters as shown below:

  3. Create the Persistence Unit
    1. Right-click on the project and select "New", "Entity Classes from Database...". In "Data Source", select "New Data Source..." and specify the values as shown below:

    2. Click on "film" in "Available Tables" and click on "Add >" as shown below:



      Click on "Next >".
    3. Click on "Create Persistence Unit..." and take all the defaults as shown below:



      Click on "Create".
    4. Enter the package name as "sakila" as shown below:



      and click on "Finish".
    5. In the NetBeans project explorer, expand "Configuration Files" and open "persistence.xml". Specify the username and password by replacing <properties/> with the following fragment:

      <properties>
        <property name="toplink.jdbc.user" value="root"/>
        <property name="toplink.jdbc.password" value=""/>
      </properties>


      Make sure to match the username and password to your MySQL installation.
  4. Create RESTful Web service endpoint
    1. In NetBeans IDE, click on "Tools", "Plugins", "Available Plugins", "RESTful Web Services" and then click on "Install". This installs the Jersey Tooling Plugin in the IDE.
    2. Right-click on the project, select "New", "RESTful Web Services from Entity Classes...".
    3. Click on "Add >>", take all other defaults as shown below:



      click on "Next >", take all defaults and then "Finish".
  5. Test RESTful Web Services
    1. Right-click on the project and select "Test RESTful Web Services". The following web page is presented in the browser:

    2. Click on "films" and then on "Test" as shown below:



      Clicking on "Test" button or the URL "http://localhost:8080/sakila/resources/films/" shows the RESTful representation of the "Film" table. The default representation shows 10 records from the table where each entry returns the "id" of the film and a reference to the detailed entry.

      You can view more entries (say 40) by giving the URL "http://localhost:8080/sakila/resources/films/?max=40". Additional fields from the table can be displayed by adding getter methods to "converter.FilmRefConverter" class such as:

      @XmlElement
      public String getTitle() {
        return entity.getTitle();
      }


      to return the film title in addition to the fields already returned. The different columns in the table can be viewed by going to the "Services" tab, expanding the sakila database connection created earlier as shown below:



      The modified output (with film title included) looks as shown below:

Here are few more ideas for you to explore:

  • Create RESTful representations of other tables using the steps described above.
  • Display the data from different tables in a jMaki-wrapped Yahoo or Dojo data table as explained in TOTD #10.
  • Display the data retrieved from the database in a JSP page as described in Hello JPA World.
  • Create a CRUD application using jMaki Data Table as described in TOTD #15 or Screencast #Web10.

A JRuby-on-Rails application using MySQL is explained here. TOTD #9 explains how JDBC connection pooling in GlassFish can be used for a JRuby-on-Rails application using MySQL.

The key message here is MySQL can be very easily used with GlassFish and NetBeans IDE makes it possible! Once MySQL becomes part of Sun, this integration is going to be much more seamless for the betterment of community.

All the entries on this blog using MySQL can be found here. And last but not the least, Welcome aboard MySQL!

A NetBeans project with all the source code can be downloaded from here. You will still need to setup the database connection and need to make sure the correct version of Jersey plug-in as well :)

Technorati: glassfish netbeans jersey mysql sakila jpa jmaki rubyonrails

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070919 Wednesday September 19, 2007

Rails Conf Europe 2007 - Day 3

Day 3 started with reminders about RubyConf 2007 and upcoming Euruko. Marcel and Koz (from Rails core team) gave the keynote talking about the best practices for Rails (theRailsWay.com). Here are some of the tips they explained:

  • If a controller has more than 6 or 7 actions, and each action > 6-7 lines then there is something wrong. More details here.
  • Associations proxies are very handy, more details here.
  • Use named callbacks to improve maintainability and readability of the code. This also help improve clarity of thoughts. The value of expressive interfaces is important as the size of applications grow bigger. More details here.
  • Use with_scope to subset a model's collection - More details here.

The Sun booth was swamped today as well, just like yesterday. There were some great interactions and I do plan to follow up on them.

I missed the "Meet the JRuby team" BoF yesterday night. But I was very excited to know that Ola Bini made a statement in the bof that amongst all the free and fee-based Application Servers, GlassFish is the best. GlassFish V2 was released earlier this week and read all about it's capabilities here.

Craig and Nick's talk on Rails Hydra was SRO with even all the floor space occupied and was attended by DHH. Brian mesmerized the audience with NetBeans Ruby magic in his talk. There were lots of users who came by the booth afterwards and were very happy with the NetBeans Ruby support. All the presentations will be available here.

 

Andrea won the SunFire T-1000 Server, Congratulations! And Sharat gave out 5 copies of RESTful Web services books as well.

And the food of course was quite a blast, the desserts were completely outstanding!

We'll see you at another conference now.

Here are some useful entries (with numerous pointers on screencasts, blogs, tips & extensive feature sets) to get you started with JRuby on Rails, NetBeans IDE, GlassFish and jMaki:

The updated picture album is available at:

Technorati: conf railsconf railsconfeurope glassfish netbeans jmaki rubyonrails

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070918 Tuesday September 18, 2007

Rails Conf Europe 2007 - Day 2

Day 2 started with regular announcements and keynote by DHH. The demographic distribution of approximately 750 attendees was shown in the filler slides right before the keynote:

Germany 29% Sweden 3%
UK 17% Spain 3%
United States 11% Norway 3%
Denmark 7% Italy 2%
Netherlands 5% France 2%

The technical sessions and BoFs started today and the exhibit hall was opened as well. Sun booth was swamped and we showed "NetBeans Tooling for Ruby on Rails", "Rails and Software as a Service" and "Rails powered by jMaki and GlassFish".

The demo showed at "Rails powered by jMaki and GlassFish" is available here. And here are some other pointers mentioned in the booth:

GlassFish is an open-source, production-quality and Java EE 5 compatible Application Server. Here are some of the key benefits of GlassFish for Rails developers:

  • GlassFish allows existing Java EE applications and RoR apps in one container.
  • GlassFish provides high availability and clustering support integrated in the app server.
  • GlassFish provides database connection pooling that allows to reuse database connections.
  • Applications can be re-deployed on GlassFish without any need to re-start the server.
  • The development and deployment environment is exactly the same.

There are few others and they will be consolidated in an article later.

Both of Sun's talks today were well attended:

The lunch was quite a treat:

Here are some useful entries (with numerous pointers on screencasts, blogs, tips & extensive feature sets) to get you started with JRuby on Rails, NetBeans IDE, GlassFish and jMaki:

The updated picture album is available at:

Use the tag "railsconfeurope" to ensure your blog/photos are aggregated appropriately.

Technorati: conf railsconf railsconfeurope glassfish netbeans jmaki rubyonrails

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070917 Monday September 17, 2007

Rails Conf Europe 2007 - Day 1

Arrived in Berlin 2 days ago for Rails Conf Europe. Sun Microsystems is a diamond sponsor and you can meet me at the "Rails powered by jMaki and GlassFish" booth in the Exhibit Hall. You can read about overall Sun's presence here.

I realized in the morning that my Full Conference pass did not account for any of the tutorials. And all of them were completely sold out with approx 750 attendees flooding all the rooms. So there was no chance to even sneak in :( I decided to spend the time taking the city tour and visiting other places. Here are some tips for travelers to Europe (Berlin in particular):

  1. Before you start on the trip, it's a good idea to inform your Credit Card company and ATM provider about your upcoming trip. This will ensure that they do not unnecessarily block your card suspecting a fraudulent usage.
  2. The taxi driver was very excited knowing that we came from California. The reason for his excitement was Arnold Schwarzenegger - that a former European national became "Mr Masculine", then a movie super star and now the Governor of California :) I'll probably carry a cutting of Arnold from a local newspaper in my next visit.
  3. So far in my 2-days experience, European shopkeepers prefer (read "accept only") cash as opposed to the US where credit card is accepted everywhere, even in Kinko's for a one-pager :) So make sure to carry sufficient cash with you. Nobody has agreed to accept the credit card so far (Taxi Driver, City Tour, Grocery and even good restaurants).
  4. Some ATM machines in the US can accommodate a pin number greater than 4 digit numbers. ATM machines in Europe cannot handle that and my banker specifically confirmed that with me. It's recommended to reduce your pin number to 4 digits.
  5. How to convert $$ to Euros ? There are multiple ways but the best bet is to use the ATM machine at the airport. They provide a good conversion rate, most reliable and easily accessible. Check with your ATM card provider if they charge any fees for the international usage. For example, Wells Fargo charges $5 flat fee for international usage of their ATM card. Bank of America is a good alternative as it does not charge any transaction fees if you use any Deutsche Bank machine (which is prevalent) and of course BoA by itself is a much bigger network.
  6. Bathrooms/Restrooms are called as "Water Closet", typically marked with "WC", and that was a new learning for me right at the airport.
  7. The Berlin City runs "Berlin City Tour" hop-on-hop-off buses starting at 10:30am at an interval of 30 minutes and the last leaving at 4pm. In an approx 2 hour tour (without any hop off) they cover 11 touristy spots in the city. The weather was beautiful and we enjoyed the ride as the first thing in Berlin. The guide particularly made it interesting by sharing stories around the spots.
  8. The communication with locals is bit of an issue. Most of the people in public dealing can understand English somewhat but the likelihood of asking somebody on the roadside for directions and not able to communicate is very high. Be prepared to ask more than once and it'll work.
  9. Everybody in this city (Berlin) seems to smoke - quite a few actively and rest of them passively. Public smoking is quite prevalent and that was quite a change from back home.
  10. I did not find any water fountains in public places, not even outside the bathrooms. So carry your own water bottle.

And here is Berlin in pictures

Thanks to Joyent for hosting the beer bust. That's all for today! See you tomorrow at the booth :)

All my travel tips to Europe are aggregated here.

Technorati: conf railsconf railsconfeurope glassfish netbeans jmaki traveltips europe

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

Screencast #Web8: jMaki on Rails for Dummies - 2nd edition

The support for Rails in NetBeans IDE has improved considerably in the past few days. Greg and Ludo have been working on ramping up the jMaki NetBeans module as well. This screencast is an update to #web2 and shows how the development experience for creating a jMaki-enabled Rails application is drastically simplified.

The screencast shows how a jMaki-wrapped Yahoo and Dojo DataTable widget can be used to pull data from MySQL database using ActiveRecord in a Rails application. The screencast also shows how multiple widgets on a RHTML View can talk to each other using simple tags.

Enjoy it here!

Technorati: screencast jmaki netbeans rubyonrails mysql

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070723 Monday July 23, 2007

jMaki on Rails - Updated for NetBeans 6 M10

Based upon a user request, this is a follow up entry to show how jMaki on Rails For Dummies work on NetBeans 6 Milestone 10. Some of the steps are simplified and more details are provided. The updates from the previous blog entry are highlighted in this color.

  1. Download NetBeans 6.0 M10 (Full version) and configured to install only "Base IDE", "Java IDE", "Web and Java EE" and "Ruby" modules. A cutting-edge build can be obtained from the hudson build.
  2. Download and install jMaki plug-in in NetBeans update center.
    1. In NetBeans 'Tools', 'Plugins', select 'Downloaded', click on 'Add Plugins ...'.
    2. Select the downloaded .NBM module, click on 'Install' button (bottom left corner). Follow the next few instructions to install jMaki plug-in and restart the IDE.
    3. To verify, go to 'Tools', 'Plugins', select 'Installed'. It should show 'jMaki Ajax support' with today's installation date.
  3. Create a new "Ruby on Rails Application" Project, lets say named 'jmaki_ror'. Take everything else as default.
  4. Create a new controller by right-clicking the project, select 'Generate ...', select 'controller', specify the Name as 'jmaki' and Views as 'yahoo'.
  5. jMaki-enable the Rails app
    1. Right click on your Rails project, select "Rails Plugins ...".
    2. Select the "Repositories" tab.
    3. Click "Add URL" and specify "http://jmaki-goodies.googlecode.com/svn/trunk/rails_plugins".  This adds the plug-in registry to the list of repositories used for searching plug-ins.
    4. Now install the jmaki runtime. Select the "New Plugins" tab .
    5. Multi-select jmaki_core and jmaki_yahoo and press "Install". Follow the instructions and the two plug-ins will be installed. After the installation is complete, you'll see the following:



      and click on 'Close'.
    6. Expand 'Views', right-click on 'layouts', select 'New', select 'RHTML file ...'. Enter the 'File Name' as 'standard'. This will add 'standard.rhtml' in layouts sub-tree. Enter the following fragment before <body>:

      <head>
        <%= stylesheet_link_tag "jmaki-standard", :media => "all" -%>
        <%= javascript_include_tag "jmaki" -%>
        <%= jmaki_setup -%>
      </head>
    7. Within <body>, add the following fragment:

      <%= @content_for_layout %>
    8. In 'Controllers', 'jmaki_controller.rb', add the following fragment before 'def yahoo' line:

      layout "standard"
  6. Download and Configure the MySQL database
    1. Download MySQL 5.0 Community Server and install by taking all the default values.
    2. In a command prompt window, Start MySQL server using the command: 'mysqld-nt --user root'.
    3. Create database using the command: 'mysqladmin -u root create jmaki_ror_development'. You need to make sure that the database name in this script is changed to match the project name.
    4. Right select the NetBeans project, select 'Generate', select 'model', specify the arguments as 'grid', click 'OK'. This will generate, in NetBeans project, Database Migrations, migrate, 001_create_grids.rb.
    5. Open 001_create_grids.rb, change self.up helper method such that it looks like:

      def self.up
        create_table :grids do |t|
          t.column :company, :string
          t.column :price, :float
          t.column :change, :float
          t.column :percent_change, :float
          t.column :last_updated, :string
        end
      end 
    6. Right-select NetBeans project, select 'Run Rake Target', 'db', 'migrate'. This generates the database table.
    7. Execute the query to insert data into the table.
      1. The easiest way to run this query is to run mysql client in the command prompt window as: 'mysql --user root'.
      2. Enter the command as 'use jmaki_ror_development' to see the following interaction:

        mysql> use jmaki_ror_development;
        Database changed
      3. And then execute the query given below:

        insert into grids values (1, 'A Co', 71.72, 0.02, 0.03, 'Jan 1, 2007, 10:00am' );
        insert into grids values (2, 'B Inc', 29.01, 0.42, 1.47, 'Feb 1, 2007, 10:00am' );
        insert into grids values (3, 'C Group Inc', 83.81, 0.28, 0.34, 'Mar 1, 2007, 10:00am' );
        insert into grids values (4, 'D Company', 52.55, 0.01, 0.02, 'Apr 1, 2007, 10:00am' );
  7. Add jMaki-wrapped Yahoo DataTable widget
    1. In NetBeans project, in 'Views', 'jmaki', 'yahoo.rhtml', drag-and-drop 'Data Table' widget from the 'Yahoo' category of jMaki palette.
      1. Until the jMaki data model for grid and data widgets is consistent between Java and JRuby, you need to replace the generated code in 'yahoo.rhtml' with the following:

        <%= jmaki_widget 'yahoo.dataTable',
            :args => {
                :columns => [
                    { :title => 'Company', :width => 200, :locked => false },
                    { :title => 'Price', :width => 75, :renderer => 'usMoney' },
                    { :title => 'Change', :width => 75, :renderer => 'change' },
                    { :title => '% Change', :width => 75, :renderer => 'pctChange' },
                    { :title => 'Last Updated', :width => 85, :renderer => 'italic' }
                ]
            },
        :value => @table_data
        -%>
      2. '@table_data' is defined in 'jmaki_controller' in 'def yahoo' as:

        def yahoo
            @table_data = []
            Grid.find_all().each do |data|
              @table_data << [ data.company, data.price, data.change, data.percent_change, data.last_updated]
            end
        end
  8. That's it, run your app and view the page at 'http://localhost:3000/jmaki/yahoo'. Now jMaki-wrapped Yahoo DataTable widget is picking data from the MySQL database. 

And as a next step, you can WAR'up this RoR application and deploy it on GlassFish V2 using these instructions.

Technorati: jmaki rubyonrails ror netbeans mysql glassfish

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070610 Sunday June 10, 2007

Screencast #Web2: jMaki on Rails for Dummies

This screencast shows how a jMaki-wrapped Yahoo DataTable widget can be used to pull data from MySQL database using ActiveRecord in a Rails application. This is a screencast of the detailed instructions posted earlier.

Enjoy it here!

Technorati: jmaki rubyonrails ror netbeans mysql screencast

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070517 Thursday May 17, 2007

jMaki on Rails For Dummies

Craig announced jMaki on Rails. Here I provide detailed steps to read data from a MySQL database and display it in a jMaki-wrapped Yahoo DataTable widget.

  1. Download NetBeans 6.0 M9 (Full version) and configured to install only "Base IDE", "Java IDE", "Web and Java EE" and "Ruby" modules. A cutting-edge build can be obtained from the hudson build.
  2. Download and install jMaki plug-in in NetBeans update center.
    1. In NetBeans 'Tools', 'Plugins', select 'Downloaded', click on 'Add Plugins ...'.
    2. Select the downloaded .NBM module, click on 'Install'. This will install the jMaki plug-in and restart the IDE.
    3. To verify, go to 'Tools', 'Plugins', select 'Installed'. It should show 'jMaki Ajax support' with '1.6.9.7' version number.
  3. Create a new "Ruby on Rails Application" Project, lets say named 'jmaki_ror'.
  4. Create a new controller by right-clicking the project, select 'Generate ...', select 'controller', specify the Name as 'jmaki' and Views as 'yahoo'.
  5. jMaki-enable the Rails app
    1. Open a command prompt and go to your application directory. Make sure you have a SVN client configured on your machine. Then invoke the following commands:

      script/plugin source http://jmaki-goodies.googlecode.com/svn/trunk/rails_plugins
      script/plugin install jmaki_core
      script/plugin install jmaki_yahoo

      The first step adds the plug-in registry to the list of registries used for searching plug-ins. The second two steps install the core and yahoo plug-ins.
    2. Expand 'Views', right-click on 'layouts', select 'New', select 'Empty RHTML (Embedded Ruby) file ...'. Enter the 'File Name' as 'standard'. This will add 'standard.rhtml' in layouts sub-tree. Enter the following fragment before <body>:

      <head>
        <%= stylesheet_link_tag "jmaki-standard", :media => "all" -%>
        <%= javascript_include_tag "jmaki" -%>
        <%= jmaki_setup -%>
      </head>
    3. Within <body>, add the following fragment:

      <%= @content_for_layout %>
    4. In 'Controllers', 'jmaki_controller.rb', add the following fragment before 'def yahoo' line:

      layout "standard"
  6. Configure the MySQL database
    1. Create database using the command: 'mysqladmin -u root create jmaki_ror_development'. You need to make sure that the database name in this script is changed to match the project name.
    2. Right select the NetBeans project, select 'Generate', select 'model', specify the arguments as 'grid', click 'OK'. This will generate, in NetBeans project, Database Migrations, migrate, 001_create_grids.rb.
    3. Open 001_create_grids.rb, change self.up helper method such that it looks like:

      def self.up
        create_table :grids do |t|
          t.column :company, :string
          t.column :price, :float
          t.column :change, :float
          t.column :percent_change, :float
          t.column :last_updated, :string
        end
      end 
    4. Right-select NetBeans project, select 'Run Rake Target', 'db', 'migrate'. This generates the database table. Execute the following query to insert data into the table:

      insert into grids values (1, 'A Co', 71.72, 0.02, 0.03, 'Jan 1, 2007, 10:00am' );
      insert into grids values (2, 'B Inc', 29.01, 0.42, 1.47, 'Feb 1, 2007, 10:00am' );
      insert into grids values (3, 'C Group Inc', 83.81, 0.28, 0.34, 'Mar 1, 2007, 10:00am' );
      insert into grids values (4, 'D Company', 52.55, 0.01, 0.02, 'Apr 1, 2007, 10:00am' );
  7. Add jMaki-wrapped Yahoo DataTable widget
    1. In NetBeans project, in 'Views', 'jmaki', 'yahoo.rhtml', drag-and-drop 'Data Table' widget from the 'Yahoo' category of jMaki palette.
      1. Until the jMaki data model for grid and data widgets is consistent between Java and JRuby, you need to replace the generated code in 'yahoo.rhtml' with the following:

        <%= jmaki_widget 'yahoo.dataTable',
            :args => {
                :columns => [
                    { :title => 'Company', :width => 200, :locked => false },
                    { :title => 'Price', :width => 75, :renderer => 'usMoney' },
                    { :title => 'Change', :width => 75, :renderer => 'change' },
                    { :title => '% Change', :width => 75, :renderer => 'pctChange' },
                    { :title => 'Last Updated', :width => 85, :renderer => 'italic' }
                ]
            },
        :value => @table_data
        -%>
      2. '@table_data' is defined in 'jmaki_controller' in 'def yahoo' as:

        def yahoo
            @table_data = []
            Grid.find_all().each do |data|
              @table_data << [ data.company, data.price, data.change, data.percent_change, data.last_updated]
            end
        end
  8. That's it, run your app and view the page at 'http://localhost:3000/jmaki/yahoo'. Now jMaki-wrapped Yahoo DataTable widget is picking data from the MySQL database. 

And as a next step, you can WAR'up this RoR application and deploy it on GlassFish V2 using these instructions.

Technorati: jmaki rubyonrails ror netbeans mysql glassfish

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20070515 Tuesday May 15, 2007

jMaki, NetBeans and GlassFish in Rails Conf

Sun Microsystems is a diamond sponsor of Rails Conference (May 17 - 20). In the conference, you'll hear from Sun luminaries on different topics. You'll see how NetBeans IDE and GlassFish provide a complete development and deployment environment for your Rails application. You'll also see how RIA can be easily created using jMaki.

Here is list of sessions from Sun speakers:

Your First Day with JRuby on Rails Charles Nutter, Thomas Enebo Thu, 5/17 8:30am - 12pm
Keynote Tim Bray Sat, 5/19 9:15am - 10:15am
Ruby Tooling: State of the Art Brian Leonard Sat, 5/19 10:45am - 11:30am
JRuby on Rails: A Taste of Honey (for the Enterprise) Charles Nutter, Thomas Enebo Sun, 5/20 10:45am - 11:35am

Other than this, you can always find us in the exhibitor pavilion. Joyent, one of our partners, will be sharing the booth space and showcasing their Ruby on Rails powerful and scalable development and deployment systems.

See you there!

Technorati: sun railsconf ror rubyonrails netbeans jmaki glassfish

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.