• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List JSF JPA

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic