convert af:inputText to upperCase,lowerCase,capitalize in Oracle ADF

Requirement- We need to show value in input text into uppercase,lower or capitalize.There is a way to do this by setting contentStyle of the input text.

For UpperCase- <af:inputText label="name" id="it1" contentStyle="text-transform:uppercase;"/>



For LowerCase- <af:inputText label="name" id="it1" contentStyle="text-transform:lowercase;"/>


For InitCap-  <af:inputText label="name" id="it1" contentStyle="text-transform:capitalize;"/>

Note: – This is only used in displaying.When you commit, it will save as what user entered in the input text.

Using Java script –

<af:resource type="javascript">
  function changeToUpper(event) {
      var inputComp = event.getCurrentTarget();
      inputComp.setValue(inputComp.getSubmittedValue().toUpperCase());
  }
</af:resource>

<af:inputText value="#{bindings.EmpName.inputValue}"
    label="#{bindings.EmpName.hints.label}"
    columns="#{bindings.EmpName.hints.displayWidth}"
    shortDesc="#{bindings.EmpName.hints.tooltip}" id="it2"
    clientComponent="true">
 <f:validator binding="#{bindings.EmpName.validator}"/>
 <af:clientListener type="keyUp" method="changeToUpper"/>
</af:inputText>

It will trigger the javascript function which will fetch value of inputText and set to upper case.

Another way of doing this.Override voImpl method like below

public void setEmpName(String value) {
setAttributeInternal(EmpName, value.toUpperCase());
}

Happy coding with Vinay in Techartifact….. 🙂

Vinay

I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube