This blog describes steps to add JavaScript to
WebCenter/ ADF web application, providing an example of Password Meter. It is
common requirement in web applications to enforce user to create strong account
password while registering on web site
1. Create
new WebCenter Portal – Framework Application, say MyWebApplicationWithJavaScript.
Add new MyRegistrationForm.jspx file, in
which JavaScript code is required to be added. Select View > Component
Palette > Common Components and drag and drop ADF Faces Input
Text into the .jspx file. Source code would contain lines as below
<af:inputText
label="Password" id="itPassword"/>
Modify
these as below
<af:inputText
label="Password" id="itPassword">
</af:inputText>
2. Select
View > Component Palette > Operations and drag and drop Client Listener
above </af:inputText>
Figure 1
3. In Insert
Client Listener pop-up dialog, type method name of your JavaScript method in
Method *: (in this example, chkpass), select type of event from Type *: (in
this example, keyUp). This should change code to following
<af:inputText
label="Password: " id="itMyValue">
<af:clientListener
method="printMyValue" type="keyUp"/>
</af:inputText>
Note that secret="true" has not been added to af:inputText. Hence typed text would be visible as plain text to make it
convenient for you to observe
4. Add div
tag as below, after password
<div
id="divPasswordStrength">
<af:clientAttribute
name="caPasswordStrength"/>
</div>
5. Add af:resource tag to
.jspx file just above </af:document> tag. Add
JavaScript code by either typing JavaScript function directly within af:resource tag
<af:resource
type="javascript”>
function chkPass(evt) {
//Add your code here
}
</af:resource>
Or provide path to your .js file and .js file name,
containing your JavaScript code, as value to source property of af:resource
<af:resource
type="javascript" source="/PATH_TO_YOUR_.JS_FILE/YOUR_.JS_FILE_NAME">
</af:resource>
Below is code for MyRegistrationForm.jspx and function chkPass
<?xml
version='1.0' encoding='UTF-8'?>
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page
contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1"
title="My Registration Form">
<af:form id="f1">
<af:inputText label="Password:
" id="itPassword" maximumLength="10">
<af:clientListener
method="chkPass" type="keyUp"/>
</af:inputText>
<div
id="divPasswordStrength">
<af:clientAttribute
name="caPasswordStrength"/>
</div>
</af:form>
<af:resource
type="javascript">
function chkPass(evt) {
var objItPassword =
evt.getCurrentTarget();
var strPassword =
objItPassword.getValue();
var intScore = 0;
if (strPassword.match(/[a-z]/)) {
intScore++;
}
if (strPassword.match(/[A-Z]/)) {
intScore++;
}
if (strPassword.match(/\d+/)) {
intScore++;
}
if
(strPassword.match(/.[!,@,#,$,%,^,*,?,_,~,-,(,)]/)) {
intScore++;
}
if (strPassword.length > 7) {
intScore++;
}
var strStrengthArray = new
Array();
strStrengthArray[0] = "Blank
Password";
strStrengthArray[1] = "Very
Weak";
strStrengthArray[2] =
"Weak";
strStrengthArray[3] =
"Good";
strStrengthArray[4] =
"Strong";
strStrengthArray[5] = "Very
Strong";
var strStrength =
strStrengthArray[intScore];
var objDiv =
document.getElementById('divPasswordStrength');
objDiv.innerHTML = "";
if (intScore == 0) {
objDiv.style.color =
"#ffffff";
}
else if (intScore == 1) {
objDiv.style.color =
"#ff0000";
}
else if (intScore == 2) {
objDiv.style.color =
"#ff5f5f";
}
else if (intScore == 3) {
objDiv.style.color =
"#56e500";
}
else if (intScore == 4) {
objDiv.style.color =
"#4dcd00";
}
else if (intScore == 5) {
objDiv.style.color =
"#399800";
}
if (intScore > 0) {
objDiv.innerHTML = "Score:
" + (intScore * 20) + "%";
objDiv.innerHTML += " |
Strength: " + strStrength;
}
else {
objDiv.innerHTML =
"";
}
}
</af:resource>
</af:document>
</f:view>
</jsp:root>
6. To test application, download it by
clicking on 'Download Application' below, unzip it, right click MyRegistrationForm.jspx in Application Navigator and click
Run. Type characters in upper/ lower cases, numbers, special characters and
press enter to observe password strength. Output is as shown in Figure 2
Figure 2
Pretty interesting post! Thanks it was interesting. on website
ReplyDeleteI absolutely appreciated the articles material! Please keep it up writing about these postings, I’m able to more likely be subscribing subsequent!
ReplyDeletewebsite design
https://www.eetimes.com/profile.asp?piddl_userid=172188
ReplyDeletehttps://wdd.resellerclub.com/members/wilda123/profile/
https://play.eslgaming.com/player/14386403
https://gitlab.com/wildagjones
https://www.forexfactory.com/wilda123
https://css-tricks.com/forums/users/wilda123/
ReplyDeletehttp://www.acapela.tv/en/my-account/show/wilda123/
https://www.espguitars.com/users/6831051
https://morsbags.com/forums/users/wilda-jones/
https://www.circleme.com/Wilda123
https://www.semrush.com/user/180388113/
ReplyDeletehttps://www.myvidster.com/profile/Wilda123
https://www.programmableweb.com/profile/wildagjones
https://community.linksys.com/t5/user/viewprofilepage/user-id/1145562
https://hub.docker.com/u/wilda123
ReplyDeleteنقل عفش من الدمام الى الرياض نقل عفش من الدمام الى الرياض
ارخص نقل عفش بمكة ارخص نقل عفش بمكة
نقل عفش من جدة الى الاردن نقل عفش من جدة الى الاردن
نقل عفش
Thank you for sharing article with us.......
ReplyDeletebitdefender does not update automatically
bitdefender update failed
how to cancel avast auto renewal
how to cancel my avg subscription
Thank you for sharing article with us.......
ReplyDeletebitdefender does not update automatically
bitdefender update failed
how to cancel avast auto renewal
how to cancel my avg subscription
If you want to find the net worth and some information about a celebrity, here's the website Celeb Networth for you.
ReplyDeleteVery Nice blog for learning new things, thanks for such beautiful blog.
ReplyDeletethis website
I have read your article, it's very informative and helpful for me. I admire the valuable information you provide in your articles. Thank you for posting it.
ReplyDeleteThis article will discuss whether assignment service online is legit, the top 10 most trusted online assignment help websites for students, and how to choose a good assignment help website.
ReplyDelete