aspose file tools*
The moose likes JSF and the fly likes In wich tag should I call a javaScript function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "In wich tag should I call a javaScript function?" Watch "In wich tag should I call a javaScript function?" New topic
Author

In wich tag should I call a javaScript function?

Fernando Guerrero
Greenhorn

Joined: Apr 26, 2011
Posts: 14

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

Joined: Oct 05, 2009
Posts: 121

hi Fernando Guerrero,

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


Sun Certified Java Programmer with 93 percent
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
suresh dasari
Ranch Hand

Joined: Oct 05, 2009
Posts: 121

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: In wich tag should I call a javaScript function?