On 8/29/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Like most of you, there are plenty of places in my backend beans where I
> grab an identifying value from the request and use it to get an
> object/resultSet from the ORM/JDBC. I prefer to put this code in a
> Converter but I just can't see how to do this when a user navigates from one
> view to another (user clicks on an item in a list of Customers, goes to a
> form for just that Customer).
>
> Usually Converters are "marketed" as a part of the "Apply Request Values"
> phase. Perhaps there is something wrong w/ my eyes, but I don't see why
> they cannot be created in the backing bean as well. After all, there are
> some use cases where validation and messaging are more convenient from the
> backing bean.
>
> Do any of you see any risks w/ this approach? before I start doing it all
> over my project ;-)
>
> Dennis Byrne
>
You can certainly use a converter that is bound to a backing bean property:
<h:inputText ... converter="#{backingBean.intConverter}"/>
where "intConverter" might be a property of type IntegerConverter.
Sun Java Studio Creator does this kind of thing for you when you
explicity assign a Converter to a component.
That being said, I'm somewhat less comfortable with the idea of using
a converter for database retrieval operations, as you are
contemplating. It's really designed for type conversions. The other
thing to remember is that Converters are two way thngs ... it's used
in Apply Request Values (String->Object), but also in Render Response
(Object->String).
Craig