I am new to java really. I have a simple timesheet application that uses a derby db, struts and hibernate and adds fields userCn, userName, firstName,lastName... etc... I am trying to use a JSP page to populate the data with a new user. I have a method called lookup:
...that takes data from a jsp input form and loads a new page with the persons CN. I have been trying to create a page that adds a new user with a method called create() that looks like this:
I feel like I should be using set instead of get in there... but set won't work without errors. I am confused on how this works. How come I can get data from my form no problem with the lookup, but cannot add it?
Thanks for any ideas.
Where my issue is, is adding / creating a user. I am not sure why I am not getting data from the form.
In any case, it sounds like you are passing a form to your model layer. Is this the case? If so, it's a violation of the principles of Separation of Concerns that govern the MVC pattern. The model should be completely agnostic of the controller and presentation layers.
If you haven't read then yet, I always suggest JSP writers read these articles:
Bear Bibeault wrote:I'm not a big fan of using a set() to set a user and then calling create() on it. Why aren't you just passing the user to the create method?
Hi Bear, do I not have to create the create() method? Is this build in? I cannot find it in any of my hibernate code and all i see in my books is URI create().
I'll keep looking. Thanks for the reads also, I'll read em right now!
In any case, this really isn't about JSP, so I've moved it to the ORM forum.
I'm not sure what book and patterns you are following but this isn't similar to anything I've actually seen in use.
Bear Bibeault wrote:just that I'm not a fan of the the style where you have to set the user before calling create(), rather than just passing the user to the create() method directly.
So you don't need to have Setters and Getters all of the time then I am hearing?
btw... you can let me know if I am asking irrelevant questions... I might be going down the wrong path here