• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting form value out of the FacesContext  RSS feed

 
Tanya Ruttenberg
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
chan jian wee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you get rid of the parenthese first as suggested by Tim?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!