Tuesday Apr 08, 2008
Tuesday Apr 08, 2008
This year, Brian Leonard, and I (diva #2) are putting on the Developing (J)Ruby on Rails Applications with the NetBeans™ IDE hands-on lab at JavaOne. If you haven't tried developing a web application using Ruby on Rails, this is a good opportunity to get your feet wet. For those of you who are familiar with Ruby but haven't tried it in the IDE, you will also find this lab helpful. In this lab, you build the classic Ruby web log, you access the FreeTTS Java API to speach-enable the application, and you deploy the application to the GlassFish application server.
Speaking of JavaOne, in last year's hands-on-lab, one of the exercises was to use Dynamic Faces to build a chat room application. This section has been turned into the Building an Ajax Chat Room with the Ajax Transaction Dynamic Faces Component tutorial which is available from the NetBeans Web Application Learning Trail.
About the picture. Right behind me is flowing lava. To be able to walk right up to 1200 degree Celsius lava flow was an awesome experience. Fortunately, because the lava contains a large amount of glass, the lava flows very slowly.
Wednesday Mar 26, 2008
The Ruby Developer Resource Center at developers.sun.com is live. Just learning or already deploying? Get downloads, docs, news feeds, blogs, screencasts, and learning trails to help you build applications using Ruby, JRuby, and Ruby-on-Rails.
Friday Feb 29, 2008
April 8, 2008 Update: The final version of this tutorial is available at http://www.netbeans.org/kb/61/ruby/rapid-ruby-weblog.html.
This is an early draft of a NetBeans IDE 6.1 tutorial in which you use the Ruby support in the NetBeans IDE to create and run a simple Rails 2.0 web application. This tutorial is an update of an earlier blog, which was written for NetBeans IDE 6.0. A final version of this tutorial will be published at www.netbeans.org when final NetBeans IDE 6.1 is released.
This tutorial requires the following technologies and resources.
You begin by creating a Ruby on Rails project. By default, the application is created in a directory structure that conforms to the Ruby on Rails project conventions for applications.
rubyweblog in the Project Name text box.
Accept all the other default settings on this page.
The IDE creates the project directory with the same name as your project and opens the database.yml file in the editing area. Notice that the default database name for the development configuration is rubyweblog_development.
This weblog application is built around the Post model, which stores instances of blog posts. Here you use the Rails scaffold generator to create the model and its controller, as well as the index (list), show, new, and edit views.
The generator also creates a migration file for creating the model's database table, and creates unit test and fixture stubs for writing model tests. Last, the generator adds the map.resources :posts declaration to the routes.rb file to create named routes that are mapped to the URL paths for the controller actions.
In the Projects window, right-click the rubyweblog project node and choose Generate.
In the Rails Generator dialog box, select scaffold from the Generate drop-down list. Make sure that you select scaffold, and not use the default selected value (controller).
Post in the Model Name text box.
title:string in the Attribute Pairs text
box, as shown in the following figure,
and click
OK.
The Output window lists the files that the scaffold generator creates and updates.
In this section, you use a Rake task to create the rubyweblog_development
database. Then you use the 001_create_posts.rb migration file
to add the Posts table to the database.
Rake creates the MySQL database for the development configuration in the database.yml file.
Double-click the 001_create_posts.rb node to open the file in the editing area.
The file opens to show the self.up method, which creates a table called posts, and the
self.down method, which tears the posts table down, as shown in the following code sample.
Code Sample 1: Code for 001_create_posts.rb |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :title
t.timestamps
end
end
def self.down
drop_table :posts
end
end
|
In the Projects window, right-click the rubyweblog node and choose Migrate Database > To Current Version.
This action updates the the database to include the posts table. The Output window indicates when the migration is complete.
In the Projects window, expand the Configuration node and double-click routes.rb to open it in the editor. Find the comment:
# map.root :controller => "welcome"
map.root :controller => "posts"
In the Projects window, expand the Public node, right-click index.html and choose Delete.
The index.html page displays a
default Welcome page, which is not what you want.
By deleting index.html, Rails looks
in routes.rb to figure out what page
to display.
Click the Run Main Project button in the toolbar.
This action starts the WEBrick server, which is part of the Ruby on Rails framework, and launches the web browser.
If you are using a server other than WEBrick, you might need to enter
http://localhost:3000 in the browser's address text box and press Enter.
Click the New post link to display the second page of the application.
Enter a title and click Create.
Click the Back link to return to the list of posts.
Here you add a body column to posts table to hold the text for each blog entry.
Right-click the Database Migrations node and choose Generate.
In the Rails Generator dialog box, type
AddBodyToPost body:text in the Arguments text box and
click OK.
The IDE creates the versioned migration script
002_add_body_to_post.rb. The file opens to show
the self.up method, which adds a body column, and the
self.down method, which removes the column, as shown in the
following code sample. Notice how the generated code extracted the table
name from
the first argument AddBodyToPost.
Code Sample 2: Code for 002_add_body_to_post.rb |
class AddBodyToPost < ActiveRecord::Migration
def self.up
add_column :posts, :body, :text
end
def self.down
remove_column :posts, :body
end
end
|
Right-click the rubyweblog node and choose Migrate Database > To Current Version.
Alternatively, right-click in the source file and choose Run File from the pop-up menu.Add the statements shown in bold in the following code sample.
Alternatively, place the cursor before the <p> tag for the Title and drag the mouse to the position after the paragraph's ending </p> tag, then press Ctrl+Shift+Down Arrow to duplicate the lines. Replace Title with Body and replace f.text_field :title with f.text_area :body.
| Code Sample 3: Adding the Body to the Edit View |
<h1>Editing post</h1>
<%= error_messages_for :post %>
<% form_for(@post) do |f| %>
<p>
<b>Title</b><br />
<%= f.text_field :title %>
</p>
<p>
<b>Body</b><br />
<%= f.text_area :body %>
</p>
<p>
<%= f.submit "Update" %>
</p>
<% end %>
<%= link_to 'Show', @post %> |
<%= link_to 'Back', posts_path %>
|
Add the statements shown in bold in the following code sample. Alternatively, use Ctrl+Shift+Down Arrow to duplicate the Title paragraph and edit the duplicated code as described in Step 5.
| Code Sample 4: Adding the Body to the New View |
<h1>New post</h1>
<%= error_messages_for :post %>
<% form_for(@post) do |f| %>
<p>
<b>Title</b><br />
<%= f.text_field :title %>
</p>
<p>
<b>Body</b><br />
<%= f.text_area :body %>
</p>
<p>
<%= f.submit "Create" %>
</p>
<% end %>
<%= link_to 'Back', posts_path %>
|
Add the statements shown in bold in the following code sample. Alternatively, use Ctrl+Shift+Down Arrow to duplicate the Title paragraph as described in Step 5, change Title: to Body:, and change @post.title to @post.body.
| Code Sample 5: Adding the Body to the Show View |
<p> <b>Title:</b> <%=h @post.title %> </p> <p> <b>Body:</b> <%=h @post.body %> </p> <%= link_to 'Edit', edit_post_path(@post) %> | <%= link_to 'Back', posts_path %> |
Return to the browser and click the New Post link to see how Ruby recognizes the new body column.
Create a few more blog entries.
Here, you add code to the Post class to ensure that the users provide values for both the title and the body fields.
Open up a line inside the Class definition, type vp, then press Tab.
The IDE replaces the vp trigger with the following code template.validates_presence_of :attribute
validates_presence_of :title, :body
Run the application, click New Post, and click Create.
The application now reports that the title and body cannot be blank.Expand Views > posts and open index.html.erb, which is used to show the list of blog entries. Delete the <h1> and <table> tags and replace them with the following code that is shown in bold.
Code Sample 6: Code for index.html.erb |
<h1>The Ruby Blog</h1> <% @posts.each do |post| %> <h2><%=h post.title %></h2> <p><%=h post.body %></p> <small><%= link_to 'Permalink', post %></small> <hr> <% end %> <br /> <%= link_to 'New post', new_post_path %> |
For each instance of a post action, this code produces a
title, body, and Permalink.
Notice that the second parameter for link_to is post. You might remember that when you generated the scaffold, the generator added a map.resources :posts declaration to the routes.rb. The resources method generates named routes for the Post model, one of which is post. The post named route produces the same result as passing :action => 'show', :id => post to the link_to method. The post id is passed in the URL. When you click the Permalink link, look at the URL in the address bar. You should see a URL similar to http://localhost:3000/posts/1.
To see all the named routes for a project, right-click the rubyweblog project node and choose Run Rake Task > routes. The Output window shows the route list. The first column shows the named route, the second and third columns show the HTTP verb and URL that are passed in the request, and the last column shows the controller and action that will be called. To learn more about using named routes see the Rails API for the ActionController:Resources class.
Save the changes and run the application to see the new interface for the Post model.
To display the blog with the most recent entry first,
edit the code that you just added to reverse
the sort order by adding a call to the .reverse
method, as shown below.
<% @posts.reverse.each do |post| %>
Tuesday Jan 15, 2008
Note: On 2/25/08, I updated Code Sample 3 to take advantage the REST URLs and Path methods that the map.resources entity in the routes.rb generates. I also modified Step 3 in the last Doing More section to match the modified code.
Our Ruby weblog tutorial series for NetBeans IDE 6.0 is written for Rails 1.2.5 and uses the ActionController scaffold method. The Rails 2.0 framework dropped this method, so the tutorials do not work if you have updated to Rails 2.0.
We are now learning about the 2.0 changes so that we can produce updated tutorials. In the meantime, here is a quick draft of how to do the first weblog tutorial, Creating a Ruby Weblog in 10 Minutes, using the Rails 2.0 framework and the NetBeans 6.0 IDE. We are still learning about the new Rails 2.0 features, so there will probably be many changes to come. Please consider this a temporary document.
Currently, this tutorial assumes that you are using a native Ruby interpreter, and have updated to Rails 2.0 (I believe you need to update RubyGems as well). There are many flavors of Ruby, one of which can be download from ww2.ruby-lang.org. To learn how to set up the IDE to use a native Ruby interpreter, see Installing and Configuring Ruby Support.
Note: This tutorial uses the MySQL database server. See Installing and Configuring Ruby Support for information about using a MySQL database server in a Ruby application that is built using the NetBeans 6.0 IDE.
Select Ruby in the Categories field and Ruby on Rails Application in the Projects field. Click Next.
Note: The first time that you create a Ruby project in the IDE, the IDE checks if you have any other Ruby installations in addition to the bundled JRuby software. If you do, the IDE displays a dialog box asking you to select which software to use. Choose the native Ruby interpreter.
rubyweblog in the Project Name field.
Accept all the other default settings. Click Finish to create the new project.
The IDE creates the project directory with the same name as your project.
database.yml by providing the password in the development configuration.Save and close the database.yml file.
Note: If your operating system's host file does not contain localhost, use 127.0.0.1 instead.
In the Projects window, right-click the rubyweblog project node, and choose Run Rake Task > db > create.
Rake creates the MySQL database for the development configuration.Here you use the Rails Generator to create a scaffold and a model for the application. The rubyweblog application requires a Post model for storing instances of blog posts.
In the Projects window, right-click the rubyweblog project node and choose Generate.
In the Rails Generator dialog box, choose scaffold from the Generate drop-down list.
Type Post title:string in the Model Name field and click OK (Controller Name and Actions not valid arguments in Rails 2.0).
The Rails Generator creates a model named Post, creates a migration file, and adds the controller and views for listing, creating, updating, and deleting posts. In addition, Rake edits the routes.rb file to map Post as a resource. The Output window lists the files that are created as part of the model generation.
001_create_posts.rb.
In the Output window, click the link for the db/migrate/001_create_posts.rb file.
The file opens to show the self.up method, which creates a table called posts, and the
self.down method, which tears the posts table down, as shown in the following code sample:
Code Sample 1: Code for 001_create_posts.rb |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :title
t.timestamps
end
end
def self.down
drop_table :posts
end
end
|
In the Projects window, right-click the rubyweblog node and choose Migrate Database > To Current Version.
This action updates the the database to include the posts table. The Output window indicates when the migration is complete.
Note that Rails 2.0 provides some new db Rake tasks, such as create (which you used earlier), drop, reset, rollback, and version.In the Projects window, expand the Configuration node and double-click routes.rb to open it in the editor. Find the comment:
# map.root :controller => "welcome"
map.root :controller => "posts"
Expand the Public node, right-click index.html and choose Delete.
index.html displays a default Welcome page, which is not what you want. By deleting index.html, Rails looks in routes.rb to figure out what page to display.
Click the Run Main Project button in the toolbar.
This action starts the WEBrick server, which is part of the Ruby on Rails framework, and launches the web browser.
If you are using a server other than WEBrick, you might need to enter
http://localhost:3000 in the browser's address text box and press Enter.
Click the New post link to display the second page of the application.
Enter a title and click Create.
Here you add another field so that, in addition to the Title field, the posts table includes a Body column for providing the text of the blog.
Right-click the Database Migrations node and choose Generate. In the Rails Generator dialog box, type AddBodyToPost body:text in the Arguments field and click OK.
The IDE creates the versioned migration script 002_add_body_to_post.rb. The file opens to show the self.up method, which adds a body column, and the
self.down method, which removes the column, as shown in the following code sample:
Code Sample 2: Code for 002_add_body_to_post.rb |
class AddBodyToPost < ActiveRecord::Migration
def self.up
add_column :posts, :body, :text
end
def self.down
remove_column :posts, :body
end
end
|
Right-click the rubyweblog node and choose Migrate Database > To Current Version.
Alternatively, right-click in the source file and choose Run File from the pop-up menu.Typically, you would now edit the views to add the new field. For this tutorial, you will simply regenerate the scaffold. In the Projects window, right-click the rubyweblog project node and choose Generate.
In the Rails Generator dialog box, choose scaffold from the Generate drop-down list.
Type Post title:string body:text --skip-migration in the Model Name field.
Select the Overwrite radio button.
Click OK.
Return to the browser and click the New Post link to see how Ruby recognizes the new body field.
Create a few more blog entries.
Open up a line inside the Class definition, type vp, then press Tab.
The IDE replaces the vp trigger with the following code template:validates_presence_of :attribute
validates_presence_of :title, :body
Run the application, click New Post, and click Create.
The application now reports that the title and body cannot be blank.Expand Views > posts and open index.html.erb, which is used to show the list of blog entries. Delete the <h1> and <table> tags and replace them with the following code that is shown in bold:
Code Sample 3: Code for index.html.erb |
<h1>The Ruby Blog</h1> <% for post in @posts %> <h2><%=h post.title %></h2> <p><%=h post.body %></p> <small><%= link_to 'Permalink', post %></small> <hr> <% end %> <br /> <%= link_to 'New post', new_post_path %> |
For each instance of a post action, this code produces a
title, body, and Permalink.
Run the application to see the new interface for the Post model.
To display the blog with the most recent entry first, reverse the sort order by adding .reverse to the end of @posts in index.html.erb:
<% for post in @posts.reverse %>
Save the file and refresh your browser to see the list displayed in reverse order.
Friday Dec 14, 2007
If you have installed the NetBeans IDE support for Ruby and you are interested in integrating jMaki in your Ruby on Rails projects, here is a five-minute tutorial that will get you started. In this tutorial, you add a Yahoo data table to a Ruby on Rails view. (If you have not yet installed the NetBeans IDE 6.0 or if you need to add Ruby support to your NetBeans IDE, learn how to here.)
<%= jmaki_widget 'yahoo.dataTable',
:value =>
{:columns => [
{ :label => 'Id', :id => 'id'},
{ :label =>'Type', :id => 'type'},
{ :label => 'Price', :id => 'price'},
],
:rows => @items
}
-%>
|
Friday Nov 30, 2007
Recently we posted a list of tutorials to help you get started with NetBeans Ruby and Rails. Another way to get started is by watching the NetBeans Ruby screencasts, starring Tor Norbye and Roman Strobl, and produced by Cindy Church. These screencasts provide an overview of the features of NetBeans Ruby, including the Ruby Editor and Debugger, and also provide scenarios for creating Ruby and Rails applications. Sit back, relax, and enjoy.
Monday Nov 26, 2007
Do you need help getting started with NetBeans Ruby? If so, we have three learning trails to get you going. Our first trail gives you a whirlwind tour of the NetBeans Ruby and Ruby on Rails environment. The second trail provides the nuts and bolts for creating a basic Ruby on Rails application. The third trail is an all-in-one lesson for working with Ruby and Java applications. You can start at whatever trail best meets your needs.
Wednesday Nov 07, 2007
The other day, Tor Norbye sent us an email listing some NetBeans Ruby navigation shortcuts, which we thought we'd highlight in the blog. We did a little further research on the subject and also list here some favorite user shortcuts that we undercovered.
(For a complete list of NetBeans Ruby Keyboard Shortcuts, see Ruby Shortcuts).
Navigation Shortcuts
Navigation is important - jumping between files and their tests, or between Rails actions and views. Here are some navigation shortcuts:
User Favorite Shortcuts
Here are some more frequently used shortcuts.
| Action | Shortcut | Mac Shortcut |
|---|---|---|
| Show code completion alternatives | Ctrl-Space. If Ctrl-Space does not work for your language, try using Ctrl-\ | Ctrl-Space |
| Open File by name prefix (not path) | Alt-Shift-O | Ctrl-Shift-O |
| Show name of current parameter (when editing an argument list for a method call) | Ctrl-P | Command-P |
| Format Code | Alt-Shift-F | Ctrl-Shift-F |
| Reformat the current comment paragraph | Ctrl-Shift-P | Command-Shift-P |
| Jump to matching parenthesis / brace / bracket, or other matching | Ctrl-[ | Command-[ |
| Show Documentation | Ctrl-Shift-Space | Command-Shift-Space |
NetBeans Shortcuts
You can download a shortcut card that lists the highlights of the NetBeans IDE 6.0 keyboard shortcuts and code templates. In the NetBeans IDE, choose Help > Keyboard Shortcuts Card from the main menu. Similarly, you can view the shortcuts online from the NetBeans IDE 6.0 Keyboard Shortcuts Specification.
Friday Nov 02, 2007
Teera Kanokkanjanarat is a Sun campus ambassador who recently contributed the tutorial Swing with JRuby: Developing a Desktop Application with the JRuby and Java Swing APIs. Here we interview Teera to find out more about his interest in NetBeans Ruby.
First, tell us a little bit about yourself.I've been working as a freelance software developer for about 8 years ever since finishing high school. My work mainly focuses on the web platform with various technologies ranging from Java, ASP.NET, PHP, and recently I got started on Ruby and Rails. Since November 2006, I've been hired by Sun as a campus ambassador at Simon University in British Columbia, Vancouver, where I'm completing my degree in Computing Science and Business Administration.
What is your interest in Ruby?
Coming from the strongly-typed language world of Java and C#, I find the flexibility and dynamic of the Ruby language to be very interesting. I believe that the productivity of developers has a heavy impact on the cost of software projects. I often find that I waste time waiting for the project to compile and re-deploy to web or application servers. So that's the first thing I found really appealing when I started working with the Ruby and Rails framework. Ruby seems to gain a lot of momentum on the web platform with the Rails framework. Now I'm more interested in the future of Ruby as a rich client on the desktop.
How did you learn Ruby?
I started out on Hal Fulton's The Ruby Way book to learn the Ruby language itself and the Ruby way of doing things. I often watch screencasts and vodcasts for techniques on learning Rails. I'm also a member of the Vancouver Ruby and Rails user group, where I attend monthly meetings. This is an interesting group; as a Java guy, I learn so much from others who work with Ruby on a daily basis.
What do you like and dislike about Ruby?
The Ruby language itself is beautiful. There are not many programming languages that are as intuitive and give me that "wow this is cool stuff!" sort of thrill. Of course, this is also because of Ruby's coding conventions and key principles.
I actually did a small experiment re-creating one of my old, small Java-based web projects with Ruby on Rails. I found that the entire project on RoR actually contains fewer lines of code than that in the previous version's configuration files!
In my opinion, performance and deployment are still the key issues of Ruby. JRuby and other initiatives are really aiming on these two issues.
How has NetBeans helped you build Ruby apps?
I tried RadRails, TextMate, and InstantRails. Yet, I like Netbeans Ruby support the most, especially in code editing, the Ruby debugger, and the auto-complete capability. Netbeans is tightly integrated with JRuby as well.
Tell us about the NetBeans Ruby app you are currently building?
I'm developing JSF web components for one of the my clients. There's future planning to release these components in rich client version (Swing and SWT). I'm doing an experimental project on how to leverage JRuby for developing these desktop components.What was your favorite experience as a Sun ambassador?
Meeting with people! I made a lot of friends from around the world through this program. I also learned a lot from talking to people when I do evangelizing work, whether it's a tech demo or a presentation at a user group. Nothing beats learning from those who do real work out there in the field.
What are some things you like to do outside school and work?
I started a small coffee shop back when I was 19 and opened up a day-spa with my sister about two years ago. Both of them are in Thailand. So, I'm helping my sister run them remotely.
Where do you see yourself in five years?
Completing my degree is my first priority (it has been delayed several times due to my work). After finishing my term at Sun at the end of this year, I'll be joining Business Objects as a software developer. In the next five years, I might do another startup if there some good ideas come along, but things change, you never know.
Tuesday Oct 30, 2007
We have posted a draft of the first 2 sections of the Getting Started With Ruby and Rails tutorial. If you can take some time to look it over and give us feedback, please do.
For those of you who are new to using the NetBeans Ruby support, we would like to know:
For those of you who are experienced with Ruby, can you look for incorrect terminology or misinformation? Are the code examples ok?
To provide feedback on this tutorial, please send corrections, suggestions, and comments to the NetBeans Ruby Developers mailing list at dev@ruby.netbeans.org. Put "Getting Started Draft Feedback" in the subject line.
Monday Oct 15, 2007
I have written both an installation and configuration article and an accessing databases FAQ for projects built using NetBeans Ruby support. However, because there are lots of different configuration paths, and each path requires some in-depth information, neither of these documents make it easy to quickly figure out what you must do to set up your Rails project to access your database server. I created this chart to hopefully make the steps simpler, and more clear. If you need more details, then consult the two documents that I mention above.
| Steps for Accessing Databases Using NetBeans Ruby Support | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||
|
|||||||||||||||||||||||||
|
All |
|||||||||||||||||||||||||
| Do: Edit database.yml to specify username, password, and, if necessary, database name. | |||||||||||||||||||||||||
Tuesday Oct 09, 2007
Our NetBeans Ruby tutorials show how to use the Rails Generator dialog box to add models to a Ruby on Rails web application. We show one step that uses the Rails Generator wizard to create the following:
In the subsequent step we have you edit the migration file to specify the column names and types. Did you know that you can can create the model and edit the migration file in one step by passing arguments in the Rails Generator? For example, let's say that I wanted a categories database table. I can right-click the project's node and choose Generate. In the Rails Generator wizard, I choose model from the Generate drop-down list. Then, I enter the following text in the Argument text box, and click OK to create the files:
Category name:string description:text level:integer created:timestamp icon:binary
The arguments list begins with the model name and is followed by column-name:type parameters. The type can be one of :string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean. To learn more about model arguments, see the TableDefinition API.
After the IDE finishes creating the files, I can click on the create db/migrate/002_create_categories.rb link in the Rails Generator tab in the Output window to open the file in the editor. The contents looks like this:
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.column :name, :string
t.column :description, :text
t.column :level, :integer
t.column :created, :timestamp
t.column :icon, :binary
end
end
def self.down
drop_table :categories
end
end
|
Once you have a migration file set up, you can move your application to another machine and have the IDE create the tables automatically. The same is true for database changes. With the up and down methods, you can quickly add or back out changes. Migrations also make it easier to switch to a different database server, say from JavaDB to MySQL.
Note: If you have an existing database, and you want to quickly create migration files, right-click the project node and choose Run Rake Task > db > schema > dump. The IDE writes the schema for your database to Database Migration > schema.rb. You can copy the create statements from the schema dump into migration files.
Wednesday Sep 26, 2007
The jMaki 1.0 framework, with support for Java, PHP, and Ruby, was released yesterday. Last week, Arun Gupta posted a screencast showing how to use jMaki wrappers of button and table widgets from Dojo and Yahoo frameworks in a Ruby on Rails application built using the NetBeans 6.0 Beta IDE.
With Arun's permission, I am supplying the steps to recreate a similar jMaki on Rails project. To save steps, I changed the order a bit. If you don't already have NetBeans Ruby Support, go to the Installing and Configuring Ruby Support tutorial for instructions.
mysqladmin -u root -p create rorjmakitables_developmentIf you don't need a password, omit the -p.
development: adapter: mysql database: rorjmakitables_development username: root password: root_password host: localhost
map.connect '', :controller => 'say', :action=>'table'
<%= jmaki_widget 'yahoo.button',
:value => { :label => 'Select 1',
:action => { :topic => '/jmaki/table/select',
:message => { :targetId => '1' }
}
} -%>
<%= jmaki_widget 'yahoo.button',
:value => { :label => 'Select 2',
:action => { :topic => '/jmaki/table/select',
:message => { :targetId => '2' }
}
} -%>
These buttons use the jMaki publish/subscribe mechanism to publish to the /jmaki/table/select topic, which you will program two table widgets to listen to. The table widgets will select either the first row or the second row, depending on which button is clicked. For more details on how to use publish/subscribe, see Carla Mott's