two simple question about jsf...

G

gbattine

Hi guys,
i've 2 question about jsf ,i hope you help me.
1) I want following MVC pattern,but i've not understood a thing..
if i have a class User with name,lastname,city,profession etc....and
methods like addUser,editUser,deleteUser in the same class that
performs operations like insert into db,delete etc..(so they realize
connection to database also) how can i realize it?
I need one only class User,or i have to change it into 2 classes?
Please explain me how acting...

2) i've a jsf page in which i've 10 inputText fields and i want to
create a css.
I create a class inputText with my attributes,later i've to link this
class with styleClass attribute for each inputText on the page?
Or can i define it once in a page?
Please reply me,thanks
 
I

Ian Wilson

gbattine said:
Hi guys,
i've 2 question about jsf ,i hope you help me.
1) I want following MVC pattern,but i've not understood a thing..

Have you read http://en.wikipedia.org/wiki/Model-view-controller
Which part are you having difficulty understanding?
if i have a class User with name,lastname,city,profession etc....and
methods like addUser,editUser,deleteUser in the same class that
performs operations like insert into db,delete etc..(so they realize
connection to database also)

I'm no expert on MVC but I believe that the relationship of your data
objects to your underlying persistence/storage is nothing to do with MVC.
how can i realize it?

I'm not sure what you mean by your question, are you asking how your
class could be written in Java?
I need one only class User,or i have to change it into 2 classes?
Please explain me how acting...

You can do it either way. One way would be to have two classes, a User
class and a Storage class which synchronises your data model with the
database. The first class might just have private fields, a constructor
with those fields as parameters and some getters and setters. The second
class might have methods like addUser(User user), deleteUser(UserID
userID) and maybe methods that do SQL updates to a single record. More
likely I'd have methods that correspond more closely with higher level
transactions in the application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top