We can convert content of input text to uppercase,lowercase and initcap by 2 method.......
1.) Using Property:-
Go to contentStyle property of af:inputtext
>For Uppercase:-
Write text in ContentStyle Property "text-transform:uppercase"
>For Initcap:-
Write text in ContentStyle Property "text-transform:capitalize"
Source code of field(in xml):-
1.) Using Property:-
Go to contentStyle property of af:inputtext
>For Uppercase:-
Write text in ContentStyle Property "text-transform:uppercase"
Source code of field(in xml):-
<af:inputText id="it7"
value="#{bindings.FirstName1.inputValue}"
contentStyle="text-transform:uppercase;"/>
value="#{bindings.FirstName1.inputValue}"
contentStyle="text-transform:uppercase;"/>
>For Lowercase:-
Write text in ContentStyle Property "text-transform:lowercase"
Write text in ContentStyle Property "text-transform:lowercase"
Source code of field(in xml):-
<af:inputText id="it7"
value="#{bindings.FirstName1.inputValue}"
contentStyle="text-transform:lowercase;"/>
value="#{bindings.FirstName1.inputValue}"
contentStyle="text-transform:lowercase;"/>
Write text in ContentStyle Property "text-transform:capitalize"
Source code of field(in xml):-
<af:inputText id="it7"
value="#{bindings.FirstName1.inputValue}"
contentStyle="text-transform:capitalize;"/>
value="#{bindings.FirstName1.inputValue}"
contentStyle="text-transform:capitalize;"/>
Run the page
1.Upper Case:-
2.Lower Case:-
3.Initcap:-
2.)Using java script:-
We can use af:resource JSP tag to define JavaScript .
af:resource is JSP tag that defines a CSS or JavaScript resource to be included in the HTML head element of the page.
Now drag af:resource from component palette to any part of page.
Select javascript Type property of af:resource
Add af:clientListner component to field where we want to use this.
af:resource is JSP tag that defines a CSS or JavaScript resource to be included in the HTML head element of the page.
Now drag af:resource from component palette to any part of page.
<af:resource type="javascript"><f:verbatim>
function isLetter(keyCode) { if (keyCode == "A" || keyCode == "B" || keyCode == "C" || keyCode == "D" ||
keyCode == "E" || keyCode == "F" || keyCode == "G" || keyCode == "H" || keyCode == "I" || keyCode == "J" ||
keyCode == "K" || keyCode == "L" || keyCode == "M" || keyCode == "N" || keyCode == "O" || keyCode == "P" ||
keyCode == "Q" || keyCode == "R" || keyCode == "S" || keyCode == "T" || keyCode == "U" || keyCode == "V" ||
keyCode == "W" || keyCode == "X" || keyCode == "Y" || keyCode == "Z") { return true; } return false; }
function convertCase(event) { var keyChar =
AdfKeyStroke.getKeyStroke(event.getKeyCode()).toMarshalledString(); if (isLetter(keyChar)) { var field =
event.getCurrentTarget(); var value = field.getSubmittedValue(); field.setValue(value.toUpperCase()); return
true; } }
</f:verbatim></af:resource>
function isLetter(keyCode) { if (keyCode == "A" || keyCode == "B" || keyCode == "C" || keyCode == "D" ||
keyCode == "E" || keyCode == "F" || keyCode == "G" || keyCode == "H" || keyCode == "I" || keyCode == "J" ||
keyCode == "K" || keyCode == "L" || keyCode == "M" || keyCode == "N" || keyCode == "O" || keyCode == "P" ||
keyCode == "Q" || keyCode == "R" || keyCode == "S" || keyCode == "T" || keyCode == "U" || keyCode == "V" ||
keyCode == "W" || keyCode == "X" || keyCode == "Y" || keyCode == "Z") { return true; } return false; }
function convertCase(event) { var keyChar =
AdfKeyStroke.getKeyStroke(event.getKeyCode()).toMarshalledString(); if (isLetter(keyChar)) { var field =
event.getCurrentTarget(); var value = field.getSubmittedValue(); field.setValue(value.toUpperCase()); return
true; } }
</f:verbatim></af:resource>
Select javascript Type property of af:resource
Add af:clientListner component to field where we want to use this.
Set properties of af:clientListner ,give method name as convertCase and type as keyUp
Now run your page
No comments:
Post a Comment