This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF 2.0 MyConverter.getAsObject(...) how to get a handle on the backing bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 2.0 MyConverter.getAsObject(...) how to get a handle on the backing bean" Watch "JSF 2.0 MyConverter.getAsObject(...) how to get a handle on the backing bean" New topic
Author

JSF 2.0 MyConverter.getAsObject(...) how to get a handle on the backing bean

Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
I've got JavaServer Faces to work now with the following :


in the class Company I have :


The list has objects :



in MyConverter :



What happens in System.out :

The index.xhtml is loaded and this happens
INFO: ctor
INFO: getAsString() Person lastName value : Adams
INFO: getAsString() Person lastName value : Bumstead
INFO: getAsString() Person lastName value : Chester

I select the second on the list and nothing is added here

Then I press commandButton and the following happens

INFO: MyConverter.getAsObject() value : Bumstead

INFO: ctor // just kills the selection I made !!!

INFO: doSomething selectedPerson = null
INFO: getAsString() Person lastName value : Adams
INFO: getAsString() Person lastName value : Bumstead
INFO: getAsString() Person lastName value : Chester


Now, when the command button is pressed,

the routine getAsObject(...) in MyConverter is called.

I presume that there I'm supposed to come up with a Person object as a return value of getAsObject

which corresponds to the "Bumstead" string I selected in the list.

I need a handle to the Company instance but these two arguments,

javax.faces.context.FacesContext context and

javax.faces.component.UIComponent component are vague and don't help at all.

In getAsObject() how can I access the Company instance so that I can access the persons list so that I can

access the Person object the label and value are pointing to?
Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
Found it, this is how to find the instance of Company....





 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF 2.0 MyConverter.getAsObject(...) how to get a handle on the backing bean
 
Similar Threads
Tidying up my code?
The "this" keyword and the constructor.
usage of "this"
Jrame not visible when Try to run from Unit Test
how this program works i didn't understand