jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes Using simultaneously Converters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Using simultaneously Converters" Watch "Using simultaneously Converters" New topic
Author

Using simultaneously Converters

Andres Quinones
Ranch Hand

Joined: Oct 09, 2006
Posts: 57
Hi guys,

I nedd to use two converters in one component in JSF likes this:

<hutputText value="#{MyBean.month}">
<f:converter converterId="UpperCaseConverter"/>
<f:convertDateTime pattern="MMMM" timeZone="Americas/Bogota" locale="es-CO"/>
</hutputText>

But right now the result is the mont from the convertDateTime converter but no in UpperCase. The UpperCaseConverter is implemented by me. The problem is that I need to use both so the result can be shown through the outputText. Does anybody knows how to do that??

Thanks in advance
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Hello Andres,

It is not legal to attach multiple converters onto a single "value holder" component.

What I would recommend is that you create a CompositeConverter which takes two converters as arguments. So, something like:



The implementation is left "as an exercise to the student." ;)

-Bryan
Andres Quinones
Ranch Hand

Joined: Oct 09, 2006
Posts: 57
Originally posted by Bryan Basham:
Hello Andres,

It is not legal to attach multiple converters onto a single "value holder" component.

What I would recommend is that you create a CompositeConverter which takes two converters as arguments. So, something like:



The implementation is left "as an exercise to the student." ;)

-Bryan


Thanks Brian I have solved the problem. I created a coverter in my bean by a Inner class and I used both converters.

Thanks
Ioana Iacob
Greenhorn

Joined: Mar 04, 2010
Posts: 2
Hi,

Have you considered using css?

Ex: text-transform: uppercase;

Cheers.

Rory Evans
Greenhorn

Joined: Feb 19, 2010
Posts: 18
I would be slightly cautious of using css to convert text to uppercase. This is because it only APPEARS as uppercase - the raw data is still in the exact case that you entered it.

This has caused problems for me on search screens where I am trying to match a search string with a record in the database. For example: the string 'USER1' is stored in the database. You type 'user1' into the search field on your jsf page (although, due to the css style, what you'll actually see is 'USER1'). You hit go and the application tries to match your search string with any records in the database. Of course, 'user1' is not the same as 'USER1' and so no matches are found. To the user, this appears very wrong since they are under the illusion that their text was converted to uppercase and the search should have therefore returned the record 'USER1'.

Hope this helps
Ioana Iacob
Greenhorn

Joined: Mar 04, 2010
Posts: 2
Rory Evans wrote:I would be slightly cautious of using css to convert text to uppercase. This is because it only APPEARS as uppercase - the raw data is still in the exact case that you entered it.

This has caused problems for me on search screens where I am trying to match a search string with a record in the database. For example: the string 'USER1' is stored in the database. You type 'user1' into the search field on your jsf page (although, due to the css style, what you'll actually see is 'USER1'). You hit go and the application tries to match your search string with any records in the database. Of course, 'user1' is not the same as 'USER1' and so no matches are found. To the user, this appears very wrong since they are under the illusion that their text was converted to uppercase and the search should have therefore returned the record 'USER1'.

Hope this helps


You are right, but on the other hand, one could easily use string toUpperCase() and do an upper on the value in db (actually I often do this, at least this way I know both the strings I'm comparing are in uppercase). Plus the example on the forum was about an hutputText, so I see no harm in using css rather than having more converters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using simultaneously Converters