Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In wich tag should I call a javaScript function?

 
Fernando Guerrero
Greenhorn
Posts: 15
Eclipse IDE Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

I have a javascrip function ( myFunction() ) that I want to load when one specific page is loaded (don't worry, my question is about JSF not about Javascript ), In my page I have several input text fields, only the first field is enable, and the rest of them become enable as the user goes filling out the fields. The javaScrip code is a simple alert message, I want to see the message every time I go to that page and every time one of the input text fields that is disables becomes enable.

Where should I call the javascript function?, I already tried in ui:define onload attribute, but the functions is never called, also I tried in the h:form onsubmit attribute and I don't see any message when the value changes in each input field and the form is submitted, I only see the message when all the input fields have been filled out and I press the next page button and the form is submitted.

the structure of my pages is as follows:




Thanks in advance
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Fernando Guerrero,

There is a tag named <ui:script> which is used to place all the script functions when your using facelets.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suresh dasari wrote:hi Fernando Guerrero,

There is a tag named <ui:script> which is used to place all the script functions when your using facelets.


Oh? I can't find any documentation on that.

I've always used the "f:verbatim" tag myself. Usually I employ an XML CDATA escape within it, since JavaScript can easily end up confusing the XML parser thanks to things like the ">" operator.
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

I apology for that, there is no <ui:script> tag.
Actually when using the faclets, we can define <ui:insert name="script"></ui:insert> in side the <head> tag.
and in actualy xhtml page we can include the script functions as follows
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic