Tuesday August 28, 2007
Dynamic Data in jMaki Widgets Using JPA - Updated for formal data models
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:
<%@ 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("] }");
%> <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
Posted by Arun Gupta in web2.0 | Comments[12]
|
|
|
|
Posted by Arun Gupta's Blog on August 28, 2007 at 05:54 AM PDT #
Posted by Arun Gupta's Blog on August 30, 2007 at 06:21 AM PDT #
Posted by Arun Gupta's Blog on September 08, 2007 at 07:08 PM PDT #
Hi arun,
I get an error when i run the jsp that contains <a:widget name="yahoo.dataTable"
service="data.jsp" />.
.it says Data format error loading data from http://localhost:8084/PMS/data.jsp
iam using tomcat apache 5.5
please help....
thanks in advance
Posted by akash mohan on October 18, 2007 at 03:44 AM PDT #
Akash, is there any error in the server-side logs ?
Posted by Arun Gupta on October 19, 2007 at 04:30 PM PDT #
Posted by Arun Gupta's Blog on November 04, 2007 at 03:44 PM PST #
Broken link. I'm trying to access the original article but get an error from the "earlier post" link whose shortcut value is:
http://blogs.sun.com/arungupta/entry/dynamic_data_in_jmaki_widgets
A dialog box is displayed saying, "There was a problem retrieving xml data: Not Found."
Regards,
Bill
Posted by Bill on December 12, 2007 at 09:16 AM PST #
Bill, I can click on the link you mentioned and view the page. Which exact page are you not able to view ?
Posted by Arun Gupta on December 12, 2007 at 09:25 AM PST #
Hi Arun, I have exactly the same problem of akash mohan (Data format error loading data from ...) and like him, I am also using Tomcat 5.5.
The data.jsp output is the following (yes, not exactly your example, but even simpler):
{columns : [ { label : 'Title', id : 'title'}, { label :'Author', id : 'author'}, { label : 'ISBN', id : 'isbn'}, { label : 'Description', id : 'description'} ], rows: [ {title :'La biologia delle Credenze',author:'B. Lipton',isbn:'1999-0952',description:'Genesi e sviluppo della nuova Epigenetica'} ] }
that seems correct. Tomcat logs have any entry relating this error
Have you any idea?
Thanks in advance
Marco Azzalini
Posted by Marco Azzalini on January 23, 2008 at 03:43 AM PST #
hi, how i add the link for rows , when user click by rows , goto link to id from database
for ex:in row one when user click goto
href= "result.jsp?id=1 "
row 2 click:"result.jsp?id=2 " and .....
thanks;
Posted by yadi on March 26, 2008 at 11:21 AM PDT #
help
with the registration in the google maps
so that I look at you in the
google mpas
Posted by leodany007 on April 17, 2008 at 12:49 PM PDT #
Hello, thank you very much for this tutorial, it was very helpful. I used an editable table. I'd like the changes I make to the table cells to be automatically made on the database. Any ideas on how? Thanks again.
Posted by Ioana Iacob on May 13, 2008 at 05:35 AM PDT #