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[19]
|
|
|
|
|
Today's Page Hits: 4092
Total # blog entries: 994
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 4 | 6 | 7 | ||
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
| Today | ||||||
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 #
Arun,
I am using a yahoo datatable. How can I format cells to show say checkbox or drop down list please.
Many thanks
Roy
Posted by roy on September 09, 2008 at 04:27 PM PDT #
Roy, please post your question users@ajax.dev.java.net for a timely response.
Posted by Arun Gupta on September 09, 2008 at 05:01 PM PDT #
Hello and THANKS for this blog, it really helped me a lot.
I've got one question which I've been googling a lot, but I didn't find what I was looking for.
in a nutshell: how to ask a table widget just to refresh its data source?
I got a dojo table feeded by service (mydata.jsp), which, also, gather data from a webservice.
Is there a way to put a button which forces the dojo table to refresh itself from the provided service (mydata.jsp) ? I'd like to do that without having to reload entire page, and keeping favourite sortings selected by user.. (that means without destroying and recreating the widjet).
any ideas?
Thank you!
Andrè
Posted by Andrè on November 02, 2008 at 01:21 PM PST #
gotcha. I finally made it, some information at http://javajumper.blogspot.com/2008/01/struts-and-jmaki-yahoodatatabledojotabl.html
along with some of your VERY NICE screencasts I've been able to reload a table.. whoa. still on schedule! :-)
Great job, without some of your screencast I wouldn't be able to complete this task.
Posted by Andrè on November 02, 2008 at 04:55 PM PST #
Andre, please ask your question on users@ajax.dev.java.net for a quicker response.
Posted by Arun Gupta on November 02, 2008 at 08:00 PM PST #
Hello and THANKS for this blog, it really helped me a lot.
I've got one question which I've been googling a lot, but I didn't find what I was looking for.
in a nutshell: how to ask a table widget just to refresh its data source?
Posted by LAPTOP BATTERY on November 26, 2008 at 09:01 PM PST #
This only works for me if I use:
<a:widget name="yahoo.dataTable"
service="./data.jsp" />
It doesn't work for me without the "./" before the "data.jsp"
I am using GlassFish V2.
Posted by Dom on June 03, 2009 at 09:26 AM PDT #