I am just learning java ee 6. My goal is having a simple crud application which let me create edit list and delete one trivial entity made simply by the id, a name string and a description string. I followed this just to see some code http://netbeans.org/kb/docs/web/jsf20-crud.html I used eclipse instead of netbeans and jboss 7 instead of glass fish. Well.... It works.
Now think my entity is a "User": id, username, Password. I want to add a "UserRole" entity and here it is: id, rolename. Then I set a OneToMany and a ManyToOne relationship.
So, how can I manage the role input in the create user page? Netbeans crud suggested code is a selectonemenu (a select drop down list) with all the roles ids as values. On form submit a static inner class "roleconverter" (a facesconverter) in the role controller (the jsf managed bean) takes the selected and submitted role Id string and looks up for the corresponding role using a ejb-dao.
My questions are:
- do I understand? Is what I wrote above correct?
- is using a converter in that way the best best practice? Doesn't a better solution exist for such a simple and recurrent task?
- converters for entities are all the same except for the entity name, how can I remove the duplication, for example with a generic converter?
- what's the best GUI in your opinion for managing many to many in jsf 2? (e.g. A user with multiple roles scenario)