Tuesday July 29, 2008
TOTD #39: Prototype/Script.aculo.us Autcomplete widget with MySQL, GlassFish, NetBeans
There are several JavaScript libraries that can be embedded in your
webapplication to create a visually appealing interface. Script.aculo.us is
one of the popular ones and is built on the Prototype JavaScript
Framework. The library provides an easy-to-use, cross-browser
user interface JavaScripts that allows you to create fancy effects
commonly visible on web pages these days.
This blog entry gets you started by using Ajax.Autocompleter
that allows for server-powered autocompleting of text fields.
Basically, you type a character in a text field and suggestions for
possible correct values starting with that character are
shown . This is achieved by by sending an Ajax request to the
data source on server, passing the typed character in the request and
processing the response to display on the web page. This effect was
first popularized by Google
Suggest.
In this TOTD (Tip
Of The Day) we will create
a simple web application with a text field in a JSP page that will use
Servlet as the data source. The Servlet retrieves the parameter from
the RequestContext, uses Java Persistence API to query the database and
return response in the expected format. We will use:
| @NamedQuery(name = "States.findLikeName", query = "SELECT s FROM States s WHERE LOWER(s.name) LIKE :searchString"), |

|
String searchString = request.getParameter("autocomplete_parameter"); List<States> list = em.createNamedQuery("States.findLikeName"). setParameter("searchString", searchString.toLowerCase() + "%"). getResultList(); out.println("<ul>"); for (int i = 0; i < list.size(); i++) { States s = list.get(i); out.println("<li>" + s.getName() + "</li>"); } out.println("</ul>"); |
|
<script src="javascripts/prototype.js"
type="text/javascript"></script> <script src="javascripts/scriptaculous.js?load=effects,controls" type="text/javascript"></script> <script type="text/javascript"> window.onload = function() { new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "/Autocomplete/StatesServlet", {}); } </script> |
|
<input type="text" id="autocomplete"
name="autocomplete_parameter"/> <div id="autocomplete_choices" class="autocomplete"></div> |
| .autocomplete { position:absolute; width:250px; background-color:white; margin:0px; padding:0px; overflow:hidden; } .autocomplete ul { list-style-type:none; margin:0px; padding:0px; overflow:auto; } .autocomplete ul li.selected { background-color: #ffb;} .autocomplete ul li { list-style-type:none; display:block; margin:0; padding:2px; height:32px; cursor:pointer; } |
| <LINK href="stylesheets/autocompleter.css" rel="stylesheet" type="text/css"> |





|
window.onload = function() { new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "/Autocomplete/StatesServlet", { minChars: 2 }); } |
Posted by Arun Gupta in web2.0 | Comments[6]
|
|
|
|
|
Wednesday July 23, 2008
FREE Hosting for Facebook & OpenSocial Developers - Social App Program
Are you developing Facebook
and/or OpenSocial
applications ?
Would you like to deploy them and monetize before spending any money on
infrastructure ?
![]() |
Social App Program
is a new collaborative offering from Sun
Microsystems and Joyent
that allows you to do exactly that! It allows you to leverage
Scalability and Cost-effectiveness of Joyent's cloud powered by OpenSolaris on
Sun's renowned reliable servers and storage for deploying critical
applications. And all this completely FREE for 12 months. This program is also accompanied with FREE Sun-Joyent Social Developer Days planned for 8 cities (San Francisco, Los Angeles, Seattle, Vancouver, Chicago, Boston, New York and Austin/Dallas) in the US later this year to learn and get hands-on experience on writing applications which can scale to million of users. Learn how to architect, develop and deploy web-scale applications on Cloud infrastructure. |
![]() |
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Thursday May 29, 2008
Screencast #25: Project SocialSite - Enabling Social Network in your Application
![]() |
Project
SocialSite
makes it easy to add social networking features to your existing web
applications or community sites (running on Java, PHP or Ruby) and turn
it into an OpenSocial
container. It comes with a comprehensive and
highly scalable implementation of social graph, integrates seamlessly
with existing identity and authentication mechanism, make it easy to
plug into existing directory server or other user management systems. This screencast shows how to add social networking features such as Friends, Activities, Profile and an OpenSocial-compliant gadget to your application using NetBeans IDE. |
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Friday May 23, 2008
Redmine on GlassFish - Ruby-on-Rails Project Management Application
Redmine is a flexible project management web application
written using Ruby on
Rails framework. The feature list
is pretty comprehensive from the usual suspects like multiple projects,
role-based control, forums/wikis/SCM for each project to enterprise
level features such as LDAP-authentication and multiple languages. It
is cross-platform and cross-database and deploys very nicely on GlassFish
v3.
GlassFish v3 modularity and extensibility allows Rails applications to
be deployed without
any modification (no WARing). This blog explains the
steps on how to deploy Redmine on GlassFish and shows some screenshots
later. More
documentation is available in Redmine
Guide.
| ~/testbed/redmine >svn co http://redmine.rubyforge.org/svn/branches/0.7-stable redmine-0.7 |
| ~/testbed/redmine
>sudo mysqld_safe
--user root Starting mysqld daemon with databases from /usr/local/mysql/data |
| ~/testbed/redmine/redmine-0.7
>../jruby-1.1.1/bin/jruby
-S rake db:create (in /Users/arungupta/testbed/redmine/redmine-0.7) |
| ~/testbed/redmine/redmine-0.7
>../jruby-1.1.1/bin/jruby
-S rake db:migrate (in /Users/arungupta/testbed/redmine/redmine-0.7) == 1 Setup: migrating ========================================================= -- create_table("attachments", {:force=>true}) -> 0.2840s -- create_table("auth_sources", {:force=>true}) -> 0.0540s -- create_table("custom_fields", {:force=>true}) -> 0.0430s -- create_table("custom_fields_projects", {:id=>false, :force=>true}) -> 0.0080s -- create_table("custom_fields_trackers", {:id=>false, :force=>true}) -> 0.0500s . . . == 90 ChangeVersionsNameLimit: migrating ====================================== -- change_column(:versions, :name, :string, {:limit=>nil}) -> 0.0220s == 90 ChangeVersionsNameLimit: migrated (0.0220s) ============================= == 91 ChangeChangesetsRevisionToString: migrating ============================= -- change_column(:changesets, :revision, :string, {:null=>false}) -> 0.0210s == 91 ChangeChangesetsRevisionToString: migrated (0.0230s) ==================== == 92 ChangeChangesFromRevisionToString: migrating ============================ -- change_column(:changes, :from_revision, :string) -> 0.0130s == 92 ChangeChangesFromRevisionToString: migrated (0.0150s) =================== |
| JRUBY_HOME="/Users/arungupta/testbed/redmine/jruby-1.1.1" |
| ~/testbed/redmine
>./glassfishv3-tp2/glassfish/bin/asadmin
deploy redmine-0.7 Command deploy executed successfully. |
| May
21, 2008 4:58:30 PM com.sun.enterprise.rails.RailsDeployer
registerAdapter INFO: Loading application redmine-0.7 at /redmine-0.7 May 21, 2008 4:58:30 PM INFO: Starting Rails instances May 21, 2008 4:58:37 PM SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL May 21, 2008 4:58:42 PM com.sun.grizzly.jruby.RubyObjectPool$1 run INFO: Rails instance instantiation took : 11979ms May 21, 2008 4:58:42 PM com.sun.enterprise.v3.deployment.DeployCommand execute INFO: Deployment of redmine-0.7 done is 12091 ms |








Posted by Arun Gupta in web2.0 | Comments[17]
|
|
|
|
|
Thursday May 22, 2008
Socialsite @ Enterprise 2.0 Conference - Add social networking to your community
![]() |
Sun Microsytems
is a sponsor of Enterprise
2.0 Conference (Jul 9-12, 2008, Boston). The conference has regular tutorials, keynotes and general sessions, multiple tracks and pavilion (even a free pavilion pass). They also have Launch Pad that allow companies developing new social networking products to compete for the chance to present them in front of the largest audience in the Enterprise 2.0 community. |
Posted by Arun Gupta in web2.0 | Comments[3]
|
|
|
|
|
Tuesday May 20, 2008
FREE 20-week Ruby-on-Rails Programming Course - with Passion!
![]() |
Sang
Shin and Brian
Leonard are starting a new free online course
of "Ruby, JRuby and Rails Application Development
(with Passion!)". The course is taken online and
will start from Jul 15, 2008. The objective of this course are "This course will go through briefly the basics of Ruby (and JRuby) programming language first. The rest of the course will be devoted to learning Rails functionality such as Active Record, Active Controller, and Active View. Attendees will acquire sufficient knowledge in order to write reasonably sophisticated Rails application upon completion." Read more details here. |
Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Monday May 19, 2008
Benefit of using JRuby-on-Rails: Using Java 2D power within Rails
One of the main advantages of using JRuby-on-Rails instead of
Ruby-on-Rails is to harness the power of Java libraries available in
the Java platform. The Java 2D
API is a set of classes for advanced 2D graphics and imaging,
and provides extensive support for image compositing and alpha channel
images, a set of classes to provide accurate color space definition and
conversion, and a rich set of display-oriented imaging operators.
Jennifer
published a new blog showing image-filtering effect (negative,
grayscale, brigthen, sharpen). Read the complete
entry.
A more comprehensive tutorial for JRuby-on-Rails on GlassFish
v3 TP2 (also Jennifer's work) is available here.
Technorati: rubyonrails
ruby jruby glassfish
v3
java2d
web2.0
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Saturday May 17, 2008
Ask The "JRuby + NetBeans + GlassFish" Experts
![]() |
NetBeans
and GlassFish
have changed the landscape of Ruby,
JRuby and Rails development
and deployment. Code completion, debugging, similar development and
deployment environment and many other features (NetBeans, GlassFish)
together make it a compelling offering. Tor Norbye, Brian Leonard and Charles Nutter are fielding questions on Ruby/JRuby/Rails support in the NetBeans IDE and GlassFish in a week-long Ask The Expert session (May 19-23). A complete archive of the Q&A will be available later. You can submit your question here. |
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Wednesday May 14, 2008
WAR-based
packaging and dispatching of Rails application on Java Application
Servers is going through third iteration based what is used for
packaging and dispatching:
| ~/testbed/jruby-1.1.1
>bin/jruby -S gem
install rails warbler --no-ri --no-rdoc JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Updating metadata for 289 gems from http://gems.rubyforge.org/ .............................................................................................................................. .............................................................................................................................. ..................................... complete Successfully installed activesupport-2.0.2 Successfully installed activerecord-2.0.2 Successfully installed actionpack-2.0.2 Successfully installed actionmailer-2.0.2 Successfully installed activeresource-2.0.2 Successfully installed rails-2.0.2 Successfully installed warbler-0.9.9 7 gems installed |
| ~/testbed/jruby-1.1.1/samples/rails
>../../bin/jruby
-S rails hello -d mysql create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments . . . create doc/README_FOR_APP create log/server.log create log/production.log create log/development.log create log/test.log |
| config.frameworks -= [ :active_record, :active_resource, :action_mailer ] |
| ~/testbed/jruby-1.1.1/samples/rails/hello
>../../../bin/jruby
-S warble JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL jar cf hello.war -C tmp/war . |
| ~/testbed/glassfish/v2ur2/glassfish
>bin/asadmin
start-domain --verbose Starting Domain domain1, please wait. May 13, 2008 11:23:44 AM com.sun.enterprise.admin.servermgmt.launch.ASLauncher buildCommand INFO: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java . . . [#|2008-05-13T11:34:13.252-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;4848;|WEB0712: Starting Sun-Java-System/Application-Server HTTP/1.1 on 4848|#] [#|2008-05-13T11:34:13.691-0700|INFO|sun-appserver9.1|javax.enterprise.system.core.selfmanagement|_ThreadID=10;_ThreadName=main;|SMGT0007: Self Management Rules service is enabled|#] [#|2008-05-13T11:34:13.718-0700|INFO|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=10;_ThreadName=main;|Application server startup complete.|#] |
| ~/testbed/jruby-1.1.1/samples/rails/hello
>~/testbed/glassfish/v2ur2/glassfish/bin/asadmin
deploy hello.war Command deploy executed successfully. |
| [#|2008-05-13T11:34:23.330-0700|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;/private/tmp/s1astempdomain1server1547440193/hello.war;|ADM1006:Uploading
the file to:[/private/tmp/s1astempdomain1server1547440193/hello.war]|#] [#|2008-05-13T11:34:26.019-0700|INFO|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=15;_ThreadName=Thread-30;|deployed with moduleid = hello|#] [#|2008-05-13T11:34:30.626-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-1;|PWC1412: WebModule[/hello] ServletContext.log():Info: using runtime pool timeout of 30 seconds|#] [#|2008-05-13T11:34:30.626-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-1;|PWC1412: WebModule[/hello] ServletContext.log():Warning: no initial runtimes specified.|#] [#|2008-05-13T11:34:30.627-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-1;|PWC1412: WebModule[/hello] ServletContext.log():Warning: no max runtimes specified.|#] |

| ~/testbed/jruby-1.1.1/samples/rails/hello
>../../../bin/jruby
script/generate controller home index JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL exists app/controllers/ exists app/helpers/ create app/views/home exists test/functional/ create app/controllers/home_controller.rb create test/functional/home_controller_test.rb create app/helpers/home_helper.rb create app/views/home/index.html.erb |
| def
index @greeting = "Hello from Rack!!" # access Servlet Context @server_info = $servlet_context.get_server_info # alternative way to get Servlet Context #@server_info2 = request.env['java.servlet_context'].get_server_info # access Servlet Request @method = request.env['java.servlet_request'].get_method @request_uri = request.env['java.servlet_request'].get_request_uri @protocol = request.env['java.servlet_request'].get_protocol @port = request.env['java.servlet_request'].get_server_port end |
| <%=
@greeting %><br><br> Hosted on "<%= @server_info %>" on port "<%= @port %>"<br> <%= @method %> <%= @request_uri %> <%= @protocol %> |

|
<filter> <filter-name>RackFilter</filter-name> <filter-class>org.jruby.rack.RackFilter</filter-class> </filter> <filter-mapping> <filter-name>RackFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class> </listener> |
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Sunday May 04, 2008
GlassFish v3 Gem 0.2.0 released
A newer version of GlassFish
v3 Gem for Ruby
on Rails is now available.
What's new ?
| ~/testbed/jruby-1.1.1
>bin/jruby -S gem
list glassfish *** LOCAL GEMS *** glassfish (0.1.2) |
| ~/testbed/jruby-1.1.1
>bin/jruby -S gem
uninstall
glassfish Successfully uninstalled glassfish-0.1.2-universal-java Remove executables: glassfish_rails, asadmin, asadmin.bat in addition to the gem? [Yn] y Removing glassfish_rails Removing asadmin Removing asadmin.bat |
| ~/testbed/jruby-1.1.1
>bin/jruby -S gem
install glassfish JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed glassfish-0.2.0-universal-java 1 gem installed |
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Saturday May 03, 2008
JRuby 1.1.1, Rails 2.0.2, Warbler now in GlassFish v2 Update Center
Vivek updated
JRuby module in GlassFish v2 UR2
Update Center.
It now contains JRuby 1.1.1 + Rails 2.0.2 and Warbler (instead of
Goldspike) for packaging the app.
Read all details on how to download, install and getting started here.
The image below shows a snapshot of Update Center with the latest
module selected:

After following all
the steps (had to manually set executable perms on
jruby-1.1.1/bin/jruby), your application is now hosted at
"http://localhost:8080/HelloWorldRailsApp/say/hello" and shows the
following output:

The generated "HelloWorldRailsApp.war" is approx 8.5 Mb and could
quickly grow depending upon the gems installed and other factors. As an
alternative, you can consider shared deployment as explained in each
sample's GLASSFISH_README.txt.
Send us feedback at Forums
or webtier@glassfish.
Technorati: rubyonrails
jruby ruby glassfish
updatecenter
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Monday April 21, 2008
JRuby and GlassFish v2 - Another successful deployment @ WorldxChange Communication NZ
![]() |
From proof-of-concept to production in 8 weeks, WorldxChange Communication NZ's online billing system is another succes story of JRuby and GlassFish v2. The portal is designed solely using NetBeans 6.1 IDE. |
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Friday March 21, 2008
Ajax World East 2008 - Day 2 Report
I delivered my Maki
as an Ajax Mashup Framework talk and the slides are available
here.
Lots of attendees came by afterwards and told me that they enjoyed the
demo. The talk showed how jMaki
Webtop provides a lightweight mashup framework that runs in
the browser. Here is a pictorial representation of the demo shown:

jMaki Webtop is basically a jMaki widget that can be embedded in a JSP
or PHP page. This widget provides the framework for managing widgets
and users, ability to persist the Webtop on client-side using Google
Gears or server-side using backend database, layouts and other
functionality. In JSP case, the widget uses JPA for performing all the
CRUD operations with the back-end MySQL database. The resulting WAR
file is deployed on GlassFish
(can be any other Servlet container as well). If you are interested in
a Java version of Webtop then the recommended path is:
![]() |
![]() |
![]() |
![]() |
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Tuesday March 18, 2008
Ajax World East 2008 - Day 1 Report
Ajax World East 2008 started earlier today.
I delievered my "Web 2.0 Application development using jMaki" and the
slides are available here.
There were several demos shown in the talk (using NetBeans and GlassFish)
and they are all accessible at the links mentiond below:
| Pros of Ajax | Cons of Ajax |
| No deployment required | Ajax apps are browser depdendent |
| 100+ Frameworks | 100+ Frameworks |
| Open Source, no need to purchase software license | Expensive due to long cycle, skilled developers demand top rate |
| JavaScript is an interpreted language, entire source code can be viewed using "View Source" | |
| Network communication speed is not optimizedf for Ajax requests |
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Tuesday February 19, 2008
Screencast #23: Social Software for GlassFish - Blogging, Tagging & Content Rating
![]() |
Social Software for GlassFish provides an integrated suite of Blogging, Tagging and Content Rating on GlassFish. More details about this suite are available here. This screencast explains how this integrated suite of software can be easily downloaded using GlassFish Update Center, how different components are seamlessly integrated and can be used. Enjoy it here! More screencasts focused on each individual topic are available here. |
Posted by Arun Gupta in web2.0 | Comments[8]
|
|
|
|
|
Today's Page Hits: 4459
Total # blog entries: 1002