Saturday, June 12, 2010

Converting Text to Upper Case in Oracle ADF

Hi all,

Just got to know the cool solution using Javascript at OTN forums i feel it would be better to share it.

If you want to convert a text of field to uppercase 2 possible solutions in my opinion

Solution 1:
  - JavaScript code which converts the text to uppercase using af:resource tag
  - link the function with the InputValue of the component.

Solution 2:
- Covert the value in setter method of the ViewObjectImpl class


Solution 3: (Updated on July 10, 2010)
Found great and better solution by Chris Muir (better than mine)

In this example:
- I will use Solution 1 on the First Name field
- I will use Solution 2 on Last Name field.

Note: Solution 1 in my opinion is better choice which is faster and less overhead on application


Solution 1 by Frank Nimphius
Here is the post by Frank Nimphius

1. drag and drop an input text field to the filter facet of a column2. create a JS function as shown below
3. Drag and drop an af:clientListenener to the input text field to reference the JS function







Solution 2:
- Generate RowImpl java class on EmployeView View Object by double clicking go to Java tab press the pencil icon on the top right and check the options.

- Change value to value.ToUpperCase() in the method of setLastName as shown in the slide

- Set AutoSubmit to TRUE of LastName field in JSF page


Run the application Enter "steve" in the First Name field and tab out you will notice it will automatically convert to "STEVE" do the same for Last Name enter "king" and tab out it will convert to "KING"

Download the example workspace

Happy JDeveloping,
Baig

4 comments:

  1. Hi,
    Thanks I successful with Solution 2 with text-transform:uppercase in UI;

    ReplyDelete
  2. For output text to display uppercase

    ReplyDelete
    Replies
    1. Hi,

      The same steps would work on output-text as well. Or you can use CSS styling.

      Zeeshan

      Delete