Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm starting to learn JSF and I was wondering how could I implement the following:

I have an instance of Spring that contains several beans for logical and database operations, for example I have a Person bean with "name", "lastName" and "age" as attributes with operations for storing said data to a MySQL database. Now I want to add a JSF instance to the project from where I can read any appropriate bean in the Spring instance and make a CRUD of the bean's properties. All of this without creating a new bean in JSF.

In detail, in JSF I want to have the following views:

  • List objects (list)
  • Show an object (show)
  • A form for adding or editing the object (form)

If I go to the URL: http: // host/person/list

JSF should to make a petition for a Person bean to Spring and call the method "getAll()" from it and "dump" the result in the "list" view. That view would have logic to build a table iterating through the results and the properties of the Person object.

Now, if I go to the URL: http: // host/dog/list

JSF should now make a petition for a Dog bean to Spring and call the same method and dump the results into the "list" view. Of course the table displayed should be different since Dog and Person are classes with different attributes.

In the URL http: // host/person/new

JSF should instantiate a new Person bean from Spring. read its attributes and dump the new object to the "form" view which should iterate through its attributes and show a form with inputs for "name" "lastName" and "age". After clicking "Submit" JSF should call the "save()" method from the Spring bean, which would save the Person with the input values.

Is this possible in JSF? If not, what are the alternatives that get closer to this workflow? What is the best strategy that can be followed for this kind of implementation?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.