File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics, POJOs & JSF cuestion

 
Fernando Soto Martorell
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic