• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using simultaneously Converters

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

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

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

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
 
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Have you considered using css?

Ex: text-transform: uppercase;

Cheers.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 h:outputText, so I see no harm in using css rather than having more converters.
 
reply
    Bookmark Topic Watch Topic
  • New Topic