• 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

Getting form value out of the FacesContext

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a small form that allows you to enter data and persist the data to a database.

I added an envers RevisionListener that persists a RevisionEntity to the database when the main entity is changed in any way.

The data is contact information, name and phone number.
The RevisionEntity contains information about the entity that changed, the timestamp, and a revision ID. Additionally, I'd like to add a revision comment that can be filled in on the form as well.

The revision comment is bound to a POJO which also happens to be a seam component.

Here is the form



When I persist the main entity, the RevisionListener is called at some point, not sure where.

My problem is that I can't figure out how to get doors.revComment into the RevisionListener. I assume it is stored somewhere in the FacesContext, but where?

Hope I presented this problem clearly. Please let me know if I can clarify anything.

Tanya
 
Saloon Keeper
Posts: 27762
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
I'm not sure about the "()" on your ActionListener. I don't think that the parentheses should be there. I rarely use ActionListener, since action is simpler and does the same thing for most needs.

However, JSF is based on Inversion of Control, and the way you normally get information from one bean into another bean is to inject the information source bean into the information destination bean. Once that is done, the destination bean can solicit the source bean for the information using a POJO "get" method and you don't need to go anywhere near FacesContext. Or, for that matter, any other javax.faces class.
 
Tanya Ruttenberg
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that inversion of control is not working in this particular class and I can't figure out why.

I can grab components out of the seamland using Components.getInstance, but why does @In not work?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did you get rid of the parenthese first as suggested by Tim?
reply
    Bookmark Topic Watch Topic
  • New Topic