Tuesday October 28, 2008
GlassFish @ Silicon Valley Code Camp 2008
|
Sun Microsystems is a sponsor of Silicon Valley Code Camp,
Nov 8-9,
2008. More than 800 attendees have already registered and numbers are expected to bump up. There are three sessions by the GlassFish team:
|

Posted by Arun Gupta in General | Comments[4]
|
|
|
|
|
Monday October 27, 2008
Silicon Valley Half Marathon 2008 Completed - best time so far
I completed Silicon
Valley Half Marathon yesterday. Although I missed
my target
of 8 min/mile by 4 seconds but still improved my personal
best by 3 min and 8 secs. Here are my official results:

A summary of half-marathoners:

And the top 5 finishers:

And then the complete
results.
Even though the number of 1/2 marathoners were much smaller (957
instead of 6679) than my previous
marathon but I still enjoyed the run. Going through familiar
streets and neighborhood was the best part :)
Here is a short video at the start:
And another one at the finish line in Los Gatos High School:
No marathon can ever be completed without family support. All the
practice takes a significant amount of time away from family. And it's
certainly exciting when they accompany you, early in the morning, for
the actual race. Many thanks to my family for helping in my marathons
all through out these years :) Here are couple of pictures:
Friday October 24, 2008
TOTD #51: Embedding Google Maps in Java Server Faces using GMaps4JSF
![]() |
GMaps4JSF allows Google Maps to be easily integrated with any JSF application. This blog shows how to use this library with Mojarra - JSF implementation delivered from the GlassFish community. |
| private float latitude; private float longitude; private String details; @ManagedProperty(value="#{cities}") private Cities cities; private final String BASE_GEOCODER_URL = "http://maps.google.com/maps/geo?"; private final String ENCODING = "UTF-8"; private final String GOOGLE_MAPS_KEY = "GOOGLE_MAPS_API_KEY"; private final String OUTPUT_FORMAT = "CSV"; public String getLatLong() throws IOException { details = cities.getCityName() + ", " + cities.getCountryName(); String GEOCODER_REQUEST = BASE_GEOCODER_URL + "q=" + URLEncoder.encode(details, ENCODING) + "&key=" + GOOGLE_MAPS_KEY + "&output=" + OUTPUT_FORMAT; BufferedReader reader = new BufferedReader( new InputStreamReader( new URL(GEOCODER_REQUEST).openStream())); String line = null; int statusCode = -1; while ((line = reader.readLine()) != null) { // 200,4,37.320052,-121.877636 // status code,accuracy,latitude,longitude statusCode = Integer.parseInt(line.substring(0, 3)); if (statusCode == 200) { int secondComma = line.indexOf(",", 5); int lastComma = line.lastIndexOf(","); latitude = Float.valueOf(line.substring(secondComma+1, lastComma)); longitude = Float.valueOf(line.substring(lastComma+1)); System.out.println("Latitude: " + latitude); System.out.println("Longitude: " + longitude); } } return "map"; } // getters and setters |
| @ManagedBean(name="coords", scope="request") |
| <h:commandButton action="#{coords.getLatLong}" value="map"/> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:m="http://code.google.com/p/gmaps4jsf/"> <head> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAF9QYjrVEsD9al2QCyg8e-hTwM0brOpm-All5BF6PoaKBxRWWERRHQdtsJnNsqELmKZCKghs54I-0Uw" type="text/javascript"> </script> </head> <body> <m:map latitude="#{coords.latitude}" longitude="#{coords.longitude}" width="500px" height="300px" zoom="14" addStretOverlay="true"> <m:marker draggable="true"> <m:eventListener eventName="dragend" jsFunction="showStreet"/> </m:marker> <m:htmlInformationWindow htmlText="#{coords.details}"/> <m:mapControl name="GLargeMapControl" position="G_ANCHOR_BOTTOM_RIGHT"/> <m:mapControl name="GMapTypeControl"/> </m:map> <br/> <br/> <m:streetViewPanorama width="500px" height="200px" latitude="#{coords.latitude}" longitude="#{coords.longitude}" jsVariable="pano1" /> <script type="text/javascript"> function showStreet(latlng) { pano1.setLocationAndPOV(latlng); } </script> <form jsfc="h:form"> <input jsfc="h:commandButton" action="back" value="Back"/> </form> </body> </html> |
|
<navigation-rule> <from-view-id>/welcome.xhtml</from-view-id> <navigation-case> <from-outcome>map</from-outcome> <to-view-id>/map.xhtml</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/map.xhtml</from-view-id> <navigation-case> <from-outcome>back</from-outcome> <to-view-id>/welcome.xhtml</to-view-id> </navigation-case> </navigation-rule> |



Posted by Arun Gupta in web2.0 | Comments[9]
|
|
|
|
|
Thursday October 23, 2008
TOTD #50: Mojarra 2.0 EDR2 is now available - Try them with GlassFish v3 and NetBeans 6.5
Yaaay, 50th tip!! The previous 49 tips are available here.
Mojarra EDR2 is now available
- download binary
and/or
source
bundle!
GlassFish
v2 UR2 ships with Mojarra 1.2.0_04 and v3 prelude comes with 1.2.0_10.
The Mojarra binaries in both v2 and v3 can
be easily replaced by the new ones as described in Release
Notes. Additionally, TOTD#
47 explains how to get started with Mojarra 2.0 on GlassFish
v2. This blog will guide you through the steps of installing these bits
on GlassFish v3 Prelude and show how to use them with NetBeans IDE.


Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
| Tempo, Interval, Aerobic, Easy, Long runs etc ...
Still confused by the difference between tempo and interval running ?
How easy is an easy run ?
How long a long run should be ?
Here is a great
article defining different types of runs/pace, advantages and
how to do them properly.
Technorati: running
tempo interval
Posted by Arun Gupta in Running | Comments[1]
|
|
|
|
|
Wednesday October 22, 2008
42k195.com - An exhaustive marathon directory
![]() |
42k195.com
provides an
exhaustive directory of marathons across continents. The marathons can be selected by countries, month or by a keyword. The search feature is especially nice because it shows all the details about the race - marathon route, registration page, nearest marathons, community rating, and even hotel booking amongst many other features. |

Posted by Arun Gupta in Running | Comments[1]
|
|
|
|
|
Tuesday October 21, 2008
NetBeans is turning 10 next week!
![]() |
NetBeans
is turning 10 next week! Wow, it's been 10 years and the IDE has certainly evolved tremendously over these years. My first usage of NetBeans goes back to version 3.6 (Mar 2004). The What's New list shows Code Folding, Native L&F for Windows and MacOS and Arrange Windows using drag-and-drop amongst many other features. And today, it leverages the mauturity of Java platform and incorporates comprehensive tooling for languages and frameworks other than Java such as PHP, Ruby-on-Rails, Groovy-on-Grails, C/C++, JavaScript, and many others. |

Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
| Jim and I presented on "Using Comet to
create a Two-Player Web Game" at Ajax World 2008 West
yesterday. The talk explained the basic concepts of Comet, showed how a
Tic Tac Toe game can be easily created using code walkthrough and then
talked about future directions. The slides are available here
and the code can be downloaded here.
A similar sample that can be deployed on Rails and Grails is described here. It uses GlassFish's support for multiple dynamic languages and associated web frameworks. |
Monday October 20, 2008
CIO published an article
highlighting 5 cheap (or free) software that can be afforded during
financial crisis. Their recommendations are:


Posted by Arun Gupta in General | Comments[7]
|
|
|
|
|
Friday October 17, 2008
SOAP and REST - both equally important to Sun
"Sun moving away from SOAP to embrace REST" is the misleading title
of an article recently published in SD
Times. The article provides a good introduction to JAX-RS and
Jersey. But I really wonder what motivated the author of this
article to use this title. This blog, hopefully, provides a better
context.
Jersey is
the Reference Implementation of Java API for RESTful Web Services
(JAX-RS, JSR
311)
and was released earlier this week. The headline indicates that Sun is
leaving SOAP and will support REST. The debate between
REST and SOAP is not new and there are religious camps on both sides
(even within Sun).
And that's completely understandable because each technology has its
own merits and demerits. But just because a new JSR aimed to make
RESTful Web services easy in
the Java platform is released, it does not mean Sun Microsystems is
leaving existing technology in trenches.
The addition of Jersey to Sun's software portfolio makes the Web
services stack from GlassFish community a more compelling and
comprehensive offering. This is in contrast to "moving away"
from SOAP as indicated by the title. As a matter of fact, Jersey will
be included as part of Metro
soon,
the Web Services stack of GlassFish. And then you can use JAX-WS (or
Metro) if you like to use SOAP or JAX-RS (or Jersey) if you prefer
RESTful Web
services. It's all about a offering choice to the community instead of
showing a direction.
Here are some data points for JAX-WS:
Posted by Arun Gupta in webservices | Comments[9]
|
|
|
|
| TOTD #49: Converting a JSF 1.2 application to JSF 2.0 - @ManagedBean
This is a follow up to TOTD
#48 which showed how to convert a JSF 1.2 application to use
new features of JSF 2.0. In this blog, we'll talk about a new
annotation added to the JSF 2.0 specification - @ManagedBean.
@ManagedBean is a new annotation in the JSF 2.0 specification. The
javadocs (bundled with the nightly)
clearly defines the purpose of this annotation:
The presence of this
annotation on a class automatically registers the class with the
runtime as a managed bean class. Classes must be scanned for the
presence of this annotation at application startup, before any requests
have been serviced.
Essentially this is an alternative to <managed-bean>
fragment in "faces-config.xml". This annotation injects a class in the
runtime as a managed bean and then can be used accordingly.
Using this annotation, the following "faces-config.xml" fragment from
our application:
| <managed-bean> <managed-bean-name>cities</managed-bean-name> <managed-bean-class>server.Cities</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <managed-bean> <managed-bean-name>dbUtil</managed-bean-name> <managed-bean-class>server.DatabaseUtil</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>cities</property-name> <value>#{cities}</value> </managed-property> </managed-bean> |
| @Entity @Table(name = "cities") @ManagedBean(name="cities", scope="request") @NamedQueries({@NamedQuery(...)}) public class Cities implements Serializable { |
| @ManagedBean(name="dbUtil", scope="request") public class DatabaseUtil { @ManagedProperty(value="#{cities}") private Cities cities; |
Posted by Arun Gupta in web2.0 | Comments[10]
|
|
|
|
|
Thursday October 16, 2008
"Using Comet to Create a Two-Player Web Game" @ Ajax World

Jim
and I are speaking at Ajax
World next week on Using Comet to
Create a Two-Player Web Game.
The session walks through the process of creating a Tic Tac Toe game
that can be played over the Internet using Ajax and Comet. In the
process, it explains the
general Comet concepts using APIs specific to the GlassFish Application
Server. It also highlights the multi-lingual capabilities of GlassFish
v3 by deploying a similar application using Ruby-on-Rails.
Here is the list of other Sun sessions:
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Wednesday October 15, 2008
TOTD #48: Converting a JSF 1.2 application to JSF 2.0 - Facelets and Ajax
TOTD
#47 showed how to deploy a JSF 1.2 application (using
Facelets and Ajax/JSF Extensions) on Mojarra
2.0-enabled GlassFish.
In this blog we'll use new features added in JSF 2.0 to
simplify our
application:
|
<application> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> |
|
<init-param> <param-name>javax.faces.LIFECYCLE_ID</param-name> <param-value>com.sun.faces.lifecycle.PARTIAL</param-value> </init-param> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <ui:composition> <h:head> <h1><h:outputText value="What city do you like ?" /></h1> </h:head> <h:body> <h:form prependId="false"> <h:panelGrid columns="2"> <h:outputText value="CityName:"/> <h:inputText value="#{cities.cityName}" title="CityName" id="cityName" required="true" onkeyup="javax.faces.Ajax.ajaxRequest(this, event, { execute: 'cityName', render: 'city_choices'});"/> <h:outputText value="CountryName:"/> <h:inputText value="#{cities.countryName}" title="CountryName" id="countryName" required="true"/> </h:panelGrid> <h:commandButton action="#{dbUtil.saveCity}" value="submit"/> <br/><br/> <h:outputText id="city_choices" value="#{dbUtil.cityChoices}"></h:outputText> <br/><br/> <h:message for="cityName" showSummary="true" showDetail="false" style="color: red"/><br/> <h:message for="countryName" showSummary="true" showDetail="false" style="color: red"/> </h:form> </h:body> <h:outputScript name="ajax.js" library="javax.faces" target="header"/> </ui:composition> </html> |

Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Tuesday October 14, 2008
TOTD #47: Getting Started with Mojarra 2.0 nightly on GlassFish v2
Java Server Faces 2.0 specification
(JSR 314,
EDR2) and implementation
(soon to be EDR2) are brewing. This blog shows how to get started with Mojarra
- Sun's implementation of JSF.
GlassFish v2 comes bundled with Mojarra 1.2_04 which allows you to
deploy a JSF 1.2 application. This blog explains how you can update
GlassFish v2 to use Mojarra 2.0 nightly. And then it deploys a simple
JSF 1.2-based application on this updated GlassFish instance, there by
showing that your existing JSF 1.2 apps will continue to work with
Mojarra 2.0-enabled GlassFish. This is an important step because it
ensures no regression, unless it was a compatibility fix :)



Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Monday October 13, 2008
FREE Sun Student Technology Camp - Oct 24, 2008
Sun Student
Technology Camp is an effort to educate students about what
is going on in the world of technology. If you are a student, from
middle school on up through university-level, then this is for you!
There are presentations, demos, hands-on activities on the latest and
most innovative technology from resident technology geeks.
The topic for upcoming camp is Open Source. Find out how Open Source
will expand your opportunity,
increase flexibility, and foster innovation for their future. There
will also be a sneak peek on cool technology that has been
brewing in SunLabs.
Did I mention these events are FREE ? :)
Hurry- seating is limited! Register
today!
Here are the key details:
| Date | Friday, October 24th |
| Location | Menlo Park (room location given upon sign-up) |
| Time | 4:00pm – 6:00pm PST (but please try to arrive at 3:30pm) |
| Topic | Open Source Software (Zembly.com, OpenSolaris, and Wonderland) |
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Today's Page Hits: 2208
Total # blog entries: 1002