Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsf , jquery  RSS feed

 
soroor ashrafzadeh
Greenhorn
Posts: 4
Android Java ME jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when submit form in jsf, jquery will be inactivated !!! Please Help Me....
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Soroor!

I'm not 100% positive I understood that, since you didn't give any details, but no JavaScript can be run after you submit a form, whether the page is JSF or plain old HTML, and whether you use jQuery or brute-force JavaScript. That's because the page that the script is on is discarded by the client (browser) once it has been submitted so that the next page coming in can replace it.

This is a very old and well-known problem with JavasScript.

It's only a problem when you do a traditional submit. If you want to keep the same page and just do a partial page update, you can do an AJAX request. Since the original page is not destroyed, scripts on it can be executed after the AJAX request has been made.
 
Mahmoud Mahmoudi
Greenhorn
Posts: 1
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Soroor,

if after your submit you redirect to another page you must add all of jQuery needed in both page

if you use JSF 1.2 you can do like this

<script type="text/javascript" language="javascript">
// <![CDATA[
function doIt(){
window.onload=Your main jQuery call ;
}
// ]]>
</script>
<h:commandButoon action="..." onclick="doIt()">

if you use JSF 2 and <f:ajax> you must use jquery-1.7.x.min.js

and if you use AJAX pure check jQuery version conflict

Have fun
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!