This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 146402

Summary: CRUD samples based on the NetBeans Platform
Product: usersguide Reporter: puce <puce>
Component: CodeAssignee: Geertjan Wielenga <geertjan>
Status: RESOLVED FIXED    
Severity: blocker CC: rmichalsky, tomwheeler
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on:    
Bug Blocks: 155214    

Description puce 2008-09-06 12:26:51 UTC
I know that there are tutorials how to make a small CRUD application 
using NetBeans, but only with the new Swing Application Framework.
It would be great if somebody would provide tutorials how to make CRUD 
applications on top of the NetBeans Platform.

Especially with the Node and Explorer APIs most example use DataObject/ 
FileObject and not POJOs persisted with JPA. I think the following is 
quite a common requirement:
- A TopComponent containing an Explorer View showing the entities 
retrieved with JPA from an embedded Java DB
- A TopComponent to edit the entries using the Bean Binding framework.
- New, Save and Delete actions to create, change and delete entities. 
The view should update accordingly.

Variations for other samples:
- provide a viewer TopComponent, which displays the content of the 
currently selected node and changes when the selection changes
- double-click the node: open an editor for the entity, which does not 
change when node selection changes
- New action which does not persist the entity but justs opens a new 
instance in the editor. When save is pressed it will be persisted.
- A more complex entitiy structure with 2 types of entities (NON-LEAF 
and LEAF types) forming a tree. Depending which type is selected in the 
explorer view, another viewer/ editor is need to show and manipulate its 
data. 2 separate New actions will be needed.
- Get the entities from a remote EJB service instead of getting them 
from an embedded Java DB
- Get the entities from a remote WebService instead of getting them from 
an embedded Java DB

I think such samples would not only help me but many other people, as well, who are 
creating applications unrelated to an IDE or any file-type based 
application. It could also be used for evaluation purposes by project responsibles planing to create their new / move
their existing applications to the NetBeans Platform.
Comment 1 Jana Maleckova 2008-09-10 15:13:14 UTC
reassign to documentation for evaluation
Comment 2 Patrick Keegan 2008-09-10 16:05:24 UTC
I think this is a great idea
Comment 3 rmichalsky 2008-09-18 13:20:58 UTC
Would be great to have this. I thought about adding JPA support to apisupport wizards and such a tutorial would help a lot.
Comment 4 Geertjan Wielenga 2008-10-01 05:43:27 UTC
I plan on turning this outline into a tutorial:

http://blogs.sun.com/geertjan/entry/connecting_to_a_database_from

Would that be sufficient to resolve this issue?
Comment 5 Patrick Keegan 2008-10-01 10:22:30 UTC
Geertjan, I assume you would use beans binding and JPA or Hibernate to help here?
Comment 6 puce 2008-10-01 11:59:52 UTC
I think it's a good start, but it would be good to have a little "bigger" sample, as proposed in the description of this
issue. We need tutorials that show us how everything can come together for JPA and EJB applications:
- the Node/Explorer API (refresh on change)
- cookies and actions for Nodes
- cookies and actions for toolbars/menus
- 2 or 3 TopComponents and their interaction (Master/ Detail)

I know it's work (and that time is money), but I think it would be good to have such a tutorial from one who knows the
NetBeans Platform and can tell us, "how you do it" with the NetBeans Platform. Trying by ourselves really takes A LOT of
time to figure that out, even after reading a whole book about the NetBeans Platform and several tutorials, and then one
is still not sure if it has been done "the right way". One who has read less has almost no chance at all, I think.
Comment 7 puce 2008-10-27 15:32:03 UTC
From the dev@openide.netbeans.org mailing list:
"A recap to anyone else trying to get a nb platform module suite to
connect to your ejb's on a glassfish server":
http://forums.netbeans.org/topic3722-0-asc-15.html

(Start of the topic: http://forums.netbeans.org/topic3722-0-asc-0.html)
Comment 8 puce 2008-10-27 16:42:16 UTC
Here some more documentation on this topic is in progress:
http://wiki.netbeans.org/NBDTRCPAndJEEBestPractices
Comment 9 Geertjan Wielenga 2008-12-09 19:45:19 UTC
Began making a prototype today: http://blogs.sun.com/geertjan/entry/netbeans_platform_crud
Comment 10 Geertjan Wielenga 2008-12-09 19:51:41 UTC
There is already plenty of info on the "GlassFish + NetBeans Platform scenario", which is one of the scenarios that this
issue seems to be concerned with. Here are some of them:

http://wiki.netbeans.org/DevFaqAppClientOnNbPlatformTut
http://blogs.sun.com/geertjan/entry/deploying_swing_as_an_application
http://blogs.sun.com/blog/entry/java_ee_application_client_on
http://wiki.netbeans.org/DevFaqCallEjbFromNbm
Comment 11 Geertjan Wielenga 2008-12-09 19:57:10 UTC
Set milestone to 7.0.
Comment 12 Geertjan Wielenga 2009-01-17 14:08:10 UTC
http://netbeans.dzone.com/news/eclipselink-netbeans-platform

Above is yet another article (new as of today) describing a CRUD-related scenario.
Comment 13 Geertjan Wielenga 2009-01-20 19:08:07 UTC
puce, is this getting closer to what you were thinking about when you wrote this issue?:

http://blogs.sun.com/geertjan/entry/status_report_on_the_year

Look at that and then please specify, i.e., prioritize which of the various things you've listed are most important to
you to have included. Please don't say 'all'. Please prioritize.
Comment 14 puce 2009-01-21 01:06:40 UTC
Hi Geertjan,

thanks for your work! It's great to see more documented business scenarios! :-)

As for the priorization:
Well, since you dropped the BeansBinding framework (which is a pity since I liked it, but I also see some of the
reasons) I will not priorize it here either - which at least allows us to focus on other parts.

Since you started with a JPA CRUD application we also leave the EJB and WebService scenarios for later (though they
might be more relevant to most real-world projects.)

I agree with your next step:
1. edit & save functionality

Then I suggest to continue with:
2. Update CustomerChildFactory on save.
3. Make sure the Properties TopComponent always shows the currently selected data - no matter if the Customer List
TopComponent, the Editor TopComponent or the Properties TopComponent itself has focus, Maybe add the Customer object to
the Lookup of the Node/ TopComponent? Better way?
4. Show where and how to intialize the EntityManager/ EntityManagerFactory and how to pass it to the other components.
In the module installer? Passed via a custom Lookup which spans one or several (dependent) modules? Best practice how to
implement such a Lookup?
5. New & Delete actions (to make the CRUD round-trip complete)
6. More about best practices when working with JPA. Use attached/ detached objects? Provide a data access layer?

(For others: also see the discussion on the dev@openide.netbeans.org mailing list, topic "From JPA Entity to NetBeans
Node?".)
Comment 15 Patrick Keegan 2009-01-22 10:23:47 UTC
Puce, what do you mean by "since you dropped the beans binding framework"? Activity on it has definitely slowed (and
it's unfortunate that apparently it won't be a standard part of JDK 7), but it's still very useful and support for it is
still in the IDE
Comment 16 puce 2009-01-22 10:34:16 UTC
Geertjan dropped BeansBinding for now in his blog samples (the base of these tutorials).
Comment 17 Geertjan Wielenga 2009-01-22 10:56:18 UTC
Yes. Since it won't be in JDK 7, I'd rather not use it in this example. Plus, I'd have to go out of my way to find a
place for it in the context of this example. Both of those reasons mean that it's better to not include it.
Comment 18 Geertjan Wielenga 2009-01-22 11:24:23 UTC
Here's the next part of the series, published yesterday, with some tweaks today, laying the groundwork for several of
the items in puce's list:

http://netbeans.dzone.com/news/hello-eclipselink-modularity-n
Comment 19 Geertjan Wielenga 2009-01-22 11:26:16 UTC
PS: It would help a lot if everyone reading this issue would read these articles and vote for them (more people will get
to read them if it becomes more popular).
Comment 20 tomwheeler 2009-01-23 16:17:56 UTC
Re beans binding being dead, I certainly thought it was.  There has not been any official change in the status of the
JSR since 2006:

   http://jcp.org/en/jsr/detail?id=295

And the last release of beans binding was in 2007.  As far as I can tell from looking at their issue tracker, there has
not been a single issue resolved since then, although more than 20 issues marked as DEFECT have been submitted in that
time (in addition to a dozen more DEFECTS that were filed earlier and still unresolved).

IIRC, Scott Violet was the original author but passed it on to Shannon Hickey when he left Sun.  Now it seems that
Shannon has left Sun too.   The new maintainer (Richard Bair) has blogged about JavaFX and a little about the Swing
Application Framework, but I was not able to find anything in his blog about beans binding (with the exception of
comments from others wanting to know its status too).

So despite the IDE currently having support for beans binding, the future does not look bright for the framework.  Since
applications hopefully outlast a particular version of the IDE, I appreciate that the articles in this series have
changed to explore other approaches.  The article on explorer views and property sheets was particularly relevant and
informative in this regard.
Comment 21 Geertjan Wielenga 2009-03-20 21:25:40 UTC
<object width="480" height="376"><param name="movie"
value="http://mediacast.sun.com/flash/jw-flv-player/mediaplayer.swf?width=480&height=360&autostart=false&type=flv&file=http%3A%2F%2Fmediacast.sun.com%2Fusers%2FGWiel%2Fmedia%2FCrudNetBeansPlatform.flv"/><param
name="allowFullScreen" value="true"/><embed
src="http://mediacast.sun.com/flash/jw-flv-player/mediaplayer.swf?width=480&height=360&autostart=false&type=flv&file=http%3A%2F%2Fmediacast.sun.com%2Fusers%2FGWiel%2Fmedia%2FCrudNetBeansPlatform.flv"
type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="376"></embed></object>
Comment 22 Geertjan Wielenga 2009-03-21 22:06:34 UTC
Here's where I'm creating the tutorial, currently in draft form:

http://platform.netbeans.org/tutorials/nbm-crud.html

Feedback welcome.
Comment 23 Geertjan Wielenga 2009-03-23 15:28:06 UTC
I believe this item is now fixed. If not please reopen it.