Netbeans VWP Tip: Binding Database Table to a VWP Table Component Using JPA

One of the NB 6.0 task items for me is to implement the ability to directly bind Netbeans Visual Web Pack Table Component to an array of Objects or List of Objects (POJOs). The idea behind this task is to easily bind the Table Component to a database table using JPA with out any DataProvider support. Since using JPA the database table data can be obtained as List or array of Entity Beans (POJOs), now you can directly bind that array to the table component with out the intermediate step of ObjectListDataProvider or ObjectArrayDataProvider.

The walk through tutorial is available at this link Binding Database Table to a Table Component Using JPA

Comments:

Hi! I'm Spanish and I write english not very well... But, I need help!! I want to bind a simple data table (not in a database) to a Table Component with the Visual Web Package of NetBeans 5.5. For example, to bind "String[][] my_table" with a Table Component!! Please heeelp!!!!

Posted by Santiago on May 07, 2007 at 07:54 PM PDT #

I'm using NB 6.0 M9, and I am unable to select the users array in the Bind to Data dialog. The only option is defaultTableDataProvider.

Your instructions say to click on the newly created table, and select users as the binding array. I'm assuming you right-click on the table and select Bind to Data, correct? There are no other obvious properties or dialog items to choose from.

Just to get the typical user-error stuff out of the way, after adding the controller class and updating the JSF session bean, I did compile the project, and did hit the refresh button on Page1.

Posted by Ian on May 17, 2007 at 06:43 AM PDT #

Hi Ian, Did you do the step "Add a Property called users to the Session Bean"?. You can download the sample project and experiment with it.

Posted by Winston Prakash on May 18, 2007 at 04:06 AM PDT #

Yes, I have a users property. That is, a private member array, with public getters/setters. Where's the link to download the sample project? I don't see it in the walkthrough.

Posted by Ian Evans on May 22, 2007 at 06:55 AM PDT #

Hi, I'm Polish,

I deploy TestWepApp but in table i have mesage
"No items found." i find this error in Apache log

2007-08-17 14:52:07 org.apache.catalina.session.StandardSession setAttribute
SEVERE: Session attribute event listener threw exception
java.lang.NoClassDefFoundError: javax/persistence/Persistence
at
testmodelapp.UserController.getEntityManager(UserController.java:29)
at testmodelapp.UserController.getUsers(UserController.java:35)
at com.samples.web.SessionBean1.updateUsers(SessionBean1.java:133)
at com.samples.web.SessionBean1.init(SessionBean1.java:66)
at
com.sun.rave.web.ui.appbase.servlet.LifecycleListener.attributeAdded(LifecycleListener.java:305)
at
org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1362)
at
org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1254)

I insert Toplink\*.jar in librarys and add line to
Manifest.mf
Class-Path: ./ ./lib/toplink-essentials.jar
./lib/toplink-essentials-agent.jar

but it's not work

Please Help and sory for my english ;)

Posted by Mariusz on August 17, 2007 at 04:19 AM PDT #

Hi Mariusz, you might want to check the two articles written based on my blog at http://www.netbeans.org/kb/60/web/web-jpa.html and
http://www.netbeans.org/kb/60/web/web-jpa-part2.html

Posted by Winston Prakash on August 17, 2007 at 09:43 AM PDT #

Hi Winston,

sorry it was my mistake, I used new jdk pack for fedora but not rebuilt all environment.

Now, it work correctly

Thanks

Posted by Mariusz on August 17, 2007 at 05:52 PM PDT #

I still occur no items found,can you support the source code files,thanks

2007-8-31 17:43:50 org.apache.catalina.core.StandardContext reload
信息: Reloading this Context has started
2007-8-31 17:44:08 com.sun.faces.config.ConfigureListener contextInitialized
信息: Initializing Sun's JavaServer Faces implementation (1.2_04-b10-p01) for context '/TestWebApp'
2007-8-31 17:44:09 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stopped already. Could not load java.lang.Object. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at com.sun.faces.application.ConverterPropertyEditorFactory$DisposableClassLoader.loadClass(ConverterPropertyEditorFactory.java:447)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at java.beans.PropertyEditorManager.findEditor(PropertyEditorManager.java:79)
at com.sun.faces.application.ApplicationImpl.addPropertyEditorIfNecessary(ApplicationImpl.java:652)
at com.sun.faces.application.ApplicationImpl.addConverter(ApplicationImpl.java:623)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:754)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:505)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:402)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3083)
at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:912)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:358)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:174)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)

Posted by justine on August 30, 2007 at 07:46 PM PDT #

Hmm.. wheres the link to download the sample program. Cant see it anywhere on the tutorial. Thanks..

Posted by fadil on September 26, 2007 at 01:08 AM PDT #

Hi, I follow the two articles from winston's web site (testwebapp) and I get the "no items found" message into table component when run the application.
Does Anyone now how resolve this?

Posted by AleX Cabrera on January 08, 2008 at 02:39 AM PST #

I get the the error "No Items Found" even though there are records in the table. Any suggestions?

Posted by Sallisha Kadir on January 08, 2008 at 10:52 PM PST #

Application working! Apparently, my class wasn't included in persistence.xml - <class> com.x.y.ClassName </class>

Hope this helps!

Posted by Sallisha Kadir on January 09, 2008 at 12:27 AM PST #

Hi Winston, I have a table directly bound to an ArrayList in the sessionBean. The table is fully editable but when I submit the arrayList in the sessionBean isn't updated.
Any idea? (Using NetBeans IDE 6.0.1 (Build 200801291616))
thanks

Posted by Fabio on March 10, 2008 at 09:10 PM PDT #

btw, everything works fine if I use an array

Posted by Fabio on March 11, 2008 at 12:18 AM PDT #

Winston,

I am having a very strange issue with tables; I am still on NB6.0.1; Here is the situation ...
1. Drag and drop a woodstock table
2. Bind with with an array of some JPA entities I have in the web session object, but right click on Table Layout and selecting the array in the Get data from pull down and then selecting the cols that I am interested in.
Up to this point all is well and I can deploy the page and data shows up nicely and I can sort, and other buttons on the page fire their events etc... no issues

To make this more human friendly I want to set the col. names to be something much better than the default field name from the record in the array. So I go back to the table layout and click the col. As I click on each column, the GUI gives me an option to edit the Column details below in the same PopUp ... so I set the Col name to something more human readable, rather than the default
Once I do this ... and redeploy the page, for some bizzare reson events don't fire any more; I cant sort the table rows etc... and even buttons that are on the page stop firing their events.

Any clues?

Posted by Nanu on April 07, 2008 at 07:21 AM PDT #

well, i found a way to make it work! click on the second tab and uncheck all the options to sort/pagination etc... and click ok.
again go back to the table layout (this time leave the updated col names as they are ... since i changed it at the previous attempt) and simply go to the second tab and enable sorting/pagination etc... and click ok

deploy and it runs and all events etc... fire! stange but that is how i am able make this work consistantly :)

Posted by Nanu on April 10, 2008 at 04:04 AM PDT #

I'm receiving the same message "No items found". I'm using NB 6.1 on Windows, followed Winston's (two) articles instructions, checked my persistence.xml file, all my classes are there, my database connection is properly defined (I can remotely access my tables from NB). But, when I run the application, nothing happens, no error message, no access to the database (I ran a trace) and my table of data displays "No items found.". The two articles are the best I've found but for the sake of me I can't figure out what is wrong with my code / environment. Any help will be appreciated. Thanks

Posted by javaway on May 15, 2008 at 01:19 AM PDT #

HI Javaway, make sure the List is initialized. In the example in the article, updateUsers() is being called in the init() method which in turn initializes the list.

Posted by Winston Prakash on May 15, 2008 at 03:21 AM PDT #

Thanks, Winston for your email. I solved my problem.

I looked at the GlassFish log and found the following:

"Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:sqlserver://..."

After trying different options (CLASSPATH, etc), the solution for SQL Server consist in placing a copy of the JDBC Driver

C:\\Program Files\\Microsoft SQL Server 2005 JDBC Driver\\sqljdbc_1.2.2828.100_enu\\sqljdbc_1.2\\enu\\sqljdbc.jar

in the GlassFish's lib folder

C:\\Program Files\\glassfish-v2ur2\\lib

The syntax of the database connection is also very important

jdbc:sqlserver://serverName:portNumber;databaseName=DatabaseName;integratedSecurity=true;

Thanks so much for the great articles, they are invaluably helpful. You deserve the JPA Nobel Prize.

Posted by javaway on May 15, 2008 at 04:18 AM PDT #

Hi All,
I have a problem in populating the table in NetBeans 6.1. I am using woodstock components and visual Web JSF. Can anyone help me populating the table component and I am able to retrieve the values from the database for a specific date but can't in a table.Please provide me the solution or any tutorials links that wood help me.

Regards,
Kris

Posted by Kris on October 13, 2008 at 10:40 AM PDT #

this is my style

Posted by tashan on May 03, 2009 at 05:28 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
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