• Post Reply Bookmark Topic Watch Topic
  • New Topic

Client side Javascript validation in JSF?  RSS feed

 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a built-in support in JSF for client side Javascript validation (like Struts)?
 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about "built-in" support, but it is very easy to use javascript within JSF applications. Everything is the same as a usual JSP, however, you access your component values via the following syntax:

passedform["formname:componentid"].value

Hope this answers your question.

Josh Juneau
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also customize your components to render javascript.
 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By built-in support I mean by just adding a line like..

<html:javascript formName = "/Blah"
method = "validateForm"
dynamicJavascript = "true"
staticJavascript = "true"
page = "1"
cdata = "false"/>

in my JSP, the Javascript is automatically provided to me based on the validation rules I specify in the xml, without me having
to manipulate/extend/customize any out of the box functionality. (Struts)

From what it looks like JSF components do not generate the relevant Javascript out of the box.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alok Pota:
By built-in support I mean by just adding a line like..

<html:javascript formName = "/Blah"
method = "validateForm"
dynamicJavascript = "true"
staticJavascript = "true"
page = "1"
cdata = "false"/>

in my JSP, the Javascript is automatically provided to me based on the validation rules I specify in the xml, without me having
to manipulate/extend/customize any out of the box functionality. (Struts)

From what it looks like JSF components do not generate the relevant Javascript out of the box.


Nope, they don't. Sun decided to leave that up to the implementation. They did not want that in the specification.
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at Shale ( http://wiki.apache.org/struts/StrutsShale ). Integration of Commons Validator for client and server-side validation support is already added there. So, you can use it in your JSF application similar to Struts.

--
Sergey : jsfTutorials.net
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!