Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

List JSF JPA  RSS feed

 
Rene Ribeiro
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Morning,

I'm making a list, but I have some difficulty.
I have my method to list and the xhtml to view, but I think you're missing something.



 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The commandButton and commandLink controls are not intended to execute arbitrary parameterized methods. They are intended to fire JSF Action Methods.

A JSF Action Method has certain characteristics:

1. It takes no parameters. Any data it uses are expected to be properties of the backing bean that the method is located within - either directly or via injection of external beans into that bean.

2. It does not return void or an arbitrary binary object, It returns navigation information as a String. If the returned value is null, the same View is re-displayed, with whatever changes were made to the Model Data applied to it. If the returned value is not null, then the value is considered to be a logical View identifier mapped in faces-config.xml or, for JSF2, it can also be a direct reference to another View's URL.

For your sample, you don't need to find paciente, since it's already a property of the bean that the action method is in pacienteMB. If you wanted to find a fresher copy of that object, you could simply have the action method perform the getId() method itself with no need to pass it in as a parameter.

Views are supposed to be static templates, not repositories of logic. The only logic that a View should define should be relative to rendering the View, not business logic or persistence logic. Otherwise you lose MVC's advantages of having a single place to look for logic (the backing bean) and risk coupling the Model and View so tightly that it makes them fragile, expensive to maintain, and harder to re-use. In MVC, the only direct coupling between Model and View should be via JSF's internal Controllers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!