• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

In wich tag should I call a javaScript function?

 
Ranch Hand
Posts: 36
3
Eclipse IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 25625
183
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic