Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JSF Page validation using Jquery not working

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to validate my JSF page using JQuery. I tried a piece of code. But it did not work. The foll is my code.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<link rel="stylesheet" href="style.css" />
<!-- Load jQuery and the validate plugin -->
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"/>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript"/>
<!-- jQuery Form Validation code -->
<script>
// When the browser is ready...
$(document).ready(function(){
// Setup form validation on the #loginform element
$("#loginform").click(function(){
var username = $('#userName').val();
var pwd = $('#passwrod').val();
if(username="")
{
$('#dis').slideDown().html('Please type user name');
return fasle;
}
if(pwd="")
{
$('#dis').slideDown().html('Please type password');
return fasle;
}
});
});
</script>
<title>Login Page</title>
</h:head>
<h:body>
<f:view>
<h:form id="loginform">
<h1>Login Page</h1>
<h:message for="userName"/></font>
<h:message for="password"/>
<table border="1" cellpadding="0" cellspacing="0" style="height: 134px">
<tr>
<td>UserName : </td>
<td><h:inputText id="userName" value="#{loginBean.userName}" /></td>
</tr>
<tr>
<td>Password :</td>
<td>
<h:inputSecret id="password" value="#{loginBean.password}" />
<h:link value="forgot passwrod" outcome="adduser" /></td>
</tr>
<tr>
<td>Role :</td>
<td>
<h:selectOneListbox value="#{loginBean.role}" style="height: 31px; width: 66px">
<f:selectItem id="chooserole" itemLabel="choose role"/>
<f:selectItem id="admin" itemLabel="admin" itemValue="admin" />
<f:selectItem id="user" itemLabel="user" itemValue="user" />
</h:selectOneListbox>
</td>
</tr>
</table>
<h:commandButton value="Clear" type="reset" actionListener="#{loginBean.clear}" immediate="true"/>
<h:commandButton value="Login" action="#{loginBean.findUser}" />
</h:form>
</f:view>
</h:body>
</html>

I have added the following dependency in my Pom:

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.1.0-2</version>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery-validation</artifactId>
<version>1.11.1</version>
</dependency>

Please help me find out what the prob is.
 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you considered using Primefaces? Primefaces brings jQuery to JSF's components:

http://www.primefaces.org/showcase/ui/home.jsf
 
And then we all jump out and yell "surprise! we got you this tiny ad!"
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic