Wednesday August 20, 2008
2000 comments on "Miles to go..."
This blog
has now been commented (including trackbacks) 2000 times.
Here are the statistics as of this morning:

With 671 entries, that makes it approx 3 comments/entry.
And the tag cloud showing the # of blog entries on each topic. GlassFish is certainly
way above others :)

And finally a tool to evaluate blog worth:
| weblogs.java.net/blog/arungupta | blogs.sun.com/arungupta |
|
|
|
Posted by Arun Gupta in General | Comments[2]
|
|
|
|
| TOTD #42: Hello JavaServer Faces World with NetBeans and GlassFish
This TOTD (Tip
Of The Day) shows how to
create a simple Java
Server Faces application using NetBeans IDE 6.1. This
is my first ever Java Server Faces application :) Much more
comprehensive applications are already available in NetBeans
and GlassFish
tutorials.
The application is really simple - it allows you to create a database
of cities/country that you like. You enter the city & country
name on a page and click on Submit. This stores the data entered in the
backend database and displays all the stored values in a new page. This
application demonstrates simple JSF concepts:


| create table cities(id integer AUTO_INCREMENT, city_name varchar(20), country_name varchar(20), PRIMARY KEY(id)); |
| @NamedQuery(name = "Cities.findAll", query = "SELECT c FROM Cities c"), |


| private Cities cities; public void setCities(Cities cities) { this.cities = cities; } |
| <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> |
|
@PersistenceContext(unitName="CitiesPU") private EntityManager entityManager; @Resource UserTransaction utx; |
| public
Collection<Cities> getAllCities() { Collection<Cities> allCities = new ArrayList<Cities>(); List list = entityManager.createNamedQuery("Cities.findAll").getResultList(); for (int i = 0; i < list.size(); i++) { allCities.add((Cities)list.get(i)); } return allCities; } |
| public String saveCity() throws
NotSupportedException, SystemException, RollbackException,
HeuristicMixedException, HeuristicRollbackException { utx.begin(); entityManager.persist(cities); utx.commit(); return "submit"; } |



| <h2>Detail</h2> <h:form> <h:panelGrid columns="2"> <h:outputText value="Id:"/> <h:outputText value="#{anInstanceOfserver.Cities.id}" title="Id" /> <h:outputText value="CityName:"/> <h:outputText value="#{anInstanceOfserver.Cities.cityName}" title="CityName" /> <h:outputText value="CountryName:"/> <h:outputText value="#{anInstanceOfserver.Cities.countryName}" title="CountryName" /> </h:panelGrid> </h:form> |
| <h2>Detail</h2> <h:form> <h:panelGrid columns="2"> <h:outputText value="CityName:"/> <h:inputText value="#{cities.cityName}" title="CityName" id="cityName" required="true"/> <h:outputText value="CountryName:"/> <h:inputText value="#{cities.countryName}" title="CountryName" id="countryName" required="true"/> </h:panelGrid> </h:form> |
| <h:commandButton action="#{dbUtil.saveCity}" value="submit"/> |
| <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"/> |
| <%@taglib prefix="f"
uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> |

| <f:view> <h:form> <h1><h:outputText value="List"/></h1> <h:dataTable value="#{arrayOrCollectionOfserver.Cities}" var="item"> <h:column> <f:facet name="header"> <h:outputText value="Id"/> </f:facet> <h:outputText value=" #{item.id}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="CityName"/> </f:facet> <h:outputText value=" #{item.cityName}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="CountryName"/> </f:facet> <h:outputText value=" #{item.countryName}"/> </h:column> </h:dataTable> </h:form> </f:view> |
| <h:dataTable value="#{dbUtil.allCities}" var="item"> |
| <h:form> <h:commandButton action="back" value="back"/> </h:form> |

|
<navigation-rule> <from-view-id>/welcomeJSF.jsp</from-view-id> <navigation-case> <from-outcome>submit</from-outcome> <to-view-id>/result.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/result.jsp</from-view-id> <navigation-case> <from-outcome>back</from-outcome> <to-view-id>/welcomeJSF.jsp</to-view-id> </navigation-case> </navigation-rule> |




Posted by Arun Gupta in web2.0 | Comments[21]
|
|
|
|
|
Today's Page Hits: 735
Total # blog entries: 1002