aspose file tools*
The moose likes JSF and the fly likes Generics, POJOs & JSF cuestion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Generics, POJOs & JSF cuestion" Watch "Generics, POJOs & JSF cuestion" New topic
Author

Generics, POJOs & JSF cuestion

Fernando Soto Martorell
Greenhorn

Joined: May 21, 2010
Posts: 6
I've an base entity class:

a entity class:

and other:

In the base managed bean where i get the selectItems:

In the page where i save/update the second entity(CentroCosto):


the command button with the action for save the entity dont call the action and i get an "Conversion Error setting value '5' for 'null Converter'."
I think it's cause JSF can't register a converter for the id.

How I can avoid this?

I can't even imagine i have to write a custom converter for each entity.

Sorry for my english.
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Hi Fernando,

Welcome to JavaRanch, I think the problem can fixed by providing any of the following JSF standard converters

or
Fernando Soto Martorell
Greenhorn

Joined: May 21, 2010
Posts: 6
Thanks, the first work for my, i've tryed before the second one and throwed a exception that cannot convert from Integer to Long.
Fernando Soto Martorell
Greenhorn

Joined: May 21, 2010
Posts: 6
And when an entity class has an ID of type String? i.e.:


uesd in:


i'm getting the same error (null Converter).
Does JSF understand generics? where i can find some info about that?

thanks in advance.
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
It doesn't matter to JSF whether these objects are part in generics class or not, since it inspect the class type of the instance at runtime.
That said, String objects doesn't need any converters. Please elaborate more by posting the exception in order to inspect the stack trace.
Milan Kunc
Greenhorn

Joined: Sep 03, 2013
Posts: 2
Quite old post but I had similar problem also. I had many entities like userRole, userProfile, ... and needed it in JSF WUI. I created universal converter which converts object to string like "class:idValue" which is used in xhtml. If need to convert back, you can load object from DB because you have his type and id. See example:

This code is shortened. All ids have to be Long. If you have different Id types in different classes you can use reflection.
You can find more about this type of converter here


http://good-helper.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics, POJOs & JSF cuestion
 
Similar Threads
Error 500: "{2}" Conversion Error setting value ''{0}'' for ''{1}''.
Custom converter Error in h:SelectOneMenu
Problem setting PropertyActionListener in h:selectOneMenu
Validation Error on SelectOneMenu
selectOneMenu