Is there a way to use Eclipse to generate a JSF form from a JPA POJO?
Asked Answered
P

1

6

Is there a code generator for Eclipse that can create a facelets form that is based on the fields of a JPA POJO?

I'm just looking for something that can inspect my JPA entity and belch out a form based on it. Doesn't need to be pretty. I'm using a regular Eclipse Helios Java EE distribution. If I have to install a plugin or something, that is fine as long as it is free.

As an alternative if you know of any other tools that can do this that would be good too, as long as it doesn't require installing another IDE. I'm looking for quick and dirty here.

TIA.

Palliate answered 11/2, 2011 at 14:23 Comment(0)
D
5

Eclipse can't do it out the box. It can only generate JPA entities out of an existing DB table (and vice versa) with the Java EE builtin Dali plugin. For generating JSF/Facelets pages based on JPA entities, there's as far there's only the CRUDO plugin.

Netbeans can do it all out the box by the way.

Downandout answered 11/2, 2011 at 14:29 Comment(7)
Yeah, I know Netbeans can do it but I really don't want go through installing it and trying to make it play nice with my Eclipse project just to generate some code... if I'm going to do all that I might as well just write the code myself, which is not a problem but I want to go the lazy route on this project.Palliate
I'm also not really recommending Netbeans :) Even more, I don't use it myself. Just informing for the case others stumble upon this question.Downandout
Last time I checked Netbeans kept everything in session scope - which along with tabbed browsing can result in a very undesired behaviour (eg. deleting a different entity than the one you tried to delete); so if you use a tool like that, better check.Contain
@fdreger: are you saying that Netbeans somehow keeps request/view scoped beans in session scope?Downandout
@BalusC: No, it was not a suggestion that Netbeans is a JSR-314 implementation :-) Merely my inability to express myself clearly. What I meant was that Netbeans creates CRUD JSF pages that contain dataTables backed with session-scoped beans. The dataTables have a "remove" button in each row, that passes object to delete by a method-with-argument expression. This effectively means it says "delete Nth object in the table". If someone has the same datatable opened in two tabs and deletes the first row in the first one, buttons will delete object from the NEXT row. I'd say this is badly broken.Contain
@fdreger: oh, it generates session scoped beans. Well, replace by @ViewScoped then.Downandout
@BalusC: Uhmm... I know I can do that. My comment was just a remark on the fact, that even tooling in established IDEs can do stupid things that must be corrected by hand. And by the way, if you want to keep state on client, view scoped will not work; you would have to modify deeper.Contain

© 2022 - 2024 — McMap. All rights reserved.