Wednesday 21 May 2014

Convert input text Content to Upper Case or Lower Case

In this post i am going to talk about converting lower case data to upper case (or Upper Case data to Lower Case). There are multiple solutions to achieve this but i am showing there different methods.

1. you can use contentStyle="text-transform:uppercase;" on input text field.
        --text-transform:lowercase;
   
       
2. Using java script code

<af:resource type="javascript">
      function convertToUpperCase(evt){
        var field = evt.getCurrentTarget();
        var fieldVal= field .getSubmittedValue();
        field .setValue(fieldVal.toUpperCase());        
    }
    </af:resource>


 <af:inputText label="Label 1" id="it1">
                <af:clientListener method="convertToUpperCase" type="valueChange"/>
              </af:inputText>


3. You can create ViewRowImpl.java class with accessors and use toUpperCase() of String class

    public void setFirstName(String value) {
        setAttributeInternal(FIRSTNAME, value.toUpperCase());
    }


Thanks :) Happy Learning :) 

No comments:

Post a Comment