Skip to main content

Converting user input to uppercase

Converting the user input to upper case is a very common requirement for a typical web application. In this post, I'm sharing a simple solution for this use case using Java Script. Idea is to trigger the client side Java Script method using <af:clientListener> for 'keyUp' event. The below given code snippet may give you better idea on the implementation part.
<af:resource type="javascript">
  function toUpper(event) {
      var inputComp = event.getCurrentTarget();

<af:inputText value="#{bindings.CountryId.inputValue}"
    shortDesc="#{bindings.CountryId.hints.tooltip}" id="it2"
 <f:validator binding="#{bindings.CountryId.validator}"/>
 <af:clientListener type="keyUp" method="toUpper"/>

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

A glance at the implementation

This example contains test.jspx page to capture 'Country' master data. The attribute 'CountryId' is supposed to be in upper case always. The upper case conversion is achieved by triggering a custom Java Script method 'toUpper(...)' for keyUp event using <af:clientListener> tag.
To test this functionality, run the test.jspx and click on CreateInsert button which may let you to define new 'Country'. When you try key in the CountryId, you may notice that the keyed in letters are getting converted to upper case.


loperaja said…
thank you, your info was very helpful. Do you know if is there any way to convert the submitted text before adding it to a db register?

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…