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….. 🙂