 |
Dynamic Data in jMaki Widgets Using JPA - Updated for formal data models
Posted by arungupta on August 27, 2007 at 08:49 PM | Comments (1)
Doris pointed out that one of my
earlier post is not working any more. That entry explained the steps to
create a Web application, deployed on
GlassFish V2, and contained a jMaki-wrapped
Yahoo Data Table widget pulling data from
JavaDB using the
JPA.
The main reason for this is because
jMaki data
models have evolved since I wrote the original entry and are now
formalized. Here is the delta from the
previous entry to make it working:
- Use the following code in bullet 6 instead:
<%@ page import="java.util.*" %>
<%@ page import="server.Company" %>
<%@ page import="javax.persistence.*" %>
<%
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("jmaki-jpaPU");
EntityManager em = emf.createEntityManager();
List<Company> list = em.createQuery("select c from Company
c").getResultList();
out.println("{columns : [" +
"{ label : 'Company Name', id : 'companyName'}," +
"{ label :'Price', id : 'price'}," +
"{ label :'Change', id : 'change'}," +
"{ label :'% Change', id : 'pctChange'}," +
"{ label :'Last Updated', id : 'lastUpdated'}" +
"],");
out.println("rows: [");
for (int i=0; i<list.size(); i++) {
Company c = list.get(i);
out.print("{ companyName: '" + c.getCompanyname() + "'," +
"price: '" + c.getPrice() + "'," +
"change: '" + c.getChange() + "'," +
"pctChange: '" + c.getPercentchange() + "'," +
"lastUpdated: '" + c.getLastupdated() + "'}");
if (i < list.size()-1)
out.println(",");
else
out.println();
}
out.println("] }");
%>
- The new generated code fragment in bullet 7.2 is now:
<a:widget name="yahoo.dataTable"
service="data.jsp" />
With jMaki 0.9.7.1, here is a snapshot of the updated web page:

And the updated NetBeans project is available
here.
Technorati: jmaki
glassfish
jpa
netbeans
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first)
-
Hi Arun,
the example Dynamic Data in jMaki Widgets Using JPA is very useful . is it possible to display data using JSONArray
both coloumns and rows shoould come from a bean i.e, coloumns and rows are dynamic. Kindly give me an idea how do I proceed.
Thanks in Advance .
Reddy
Posted by: reddycm on May 21, 2008 at 06:36 AM
|