File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes How to make a crud jsf with ebj without id filed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "How to make a crud jsf with ebj without id filed?" Watch "How to make a crud jsf with ebj without id filed?" New topic
Author

How to make a crud jsf with ebj without id filed?

Jamil Shreet
Greenhorn

Joined: Dec 11, 2010
Posts: 5
Hi guys:
I use the option Jsf Pages From Entity class in Netbeans IDE, it works good but I do not want to generate code for id field(primary key) for each table, cause it is AutoIncrement.
but the Netbeans generates input text for all databease's field in the tables.......! even for Id.......!!
I changed the @Id @GeneratedValue(strategy) to be (GenerationType.AUTO) and delete the input text for id field from the page and tried to save a new data but it didn't work.....!!
I got error message in the page(may be not null).....!!
I tried to trace where he use the quiery to save data but I could not find anything....!!
please help me.
this is the code for session bean, entity class and jsf page



session bean


The Jsf page


I delete the value attribute form input text for id field cause I supposed that it should be insert automaticlly inside database not by user.
Jamil Shreet
Greenhorn

Joined: Dec 11, 2010
Posts: 5
sorry guys I forget the controller class

Krystian Gor
Ranch Hand

Joined: Jan 11, 2011
Posts: 30
Your Managed bean code, line 65
getFacade().create(current);
If you CTRL+click "create" Netbeans should show you this method code. This will be where your object is saved to database.

But I don't think your data goes there.
Take a look at your JSF code.
<h:inputText></h:inputText>
Your input box is not connected with your managed bean. Managed bean should contain private String teacherFullName; and getName() and setName methods so you can use jsf code:
<h:inputText value="#{teachersInfoController.teacherFullName}"></h:inputText>
Then if you submit form it will be passed to managed bean so you can use it to create new teacher. Think about it.
 
GeeCON Prague 2014
 
subject: How to make a crud jsf with ebj without id filed?