Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Converter for h:selectOneMenu  RSS feed

 
Mary Joe
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am new to JSF using JSF 1.1

what does the getAsObject vs getAsString do in a converter.

I would like to write a converter for a h:selectOneMenu,
where the list is driven by an Enum (String valued), and the value to be persisted is a String not an Enum

How to write a converter for this ?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Converters work in both directions - coming from the View and going to the View.

HTML Views (the most common View type) are text, so they need the getAsString to convert data to display form. On the way back in, getAsObject converts the text data value to whatever binary form you're backing the field with, such as converting a String date to a java.util.Date. Or in some cases, from a user-friendly display string to a database-friendly field code.

However modern JSF servers can handle enum conversions without the need of a custom converter.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!