1 Reply Latest reply: Apr 25, 2013 1:59 AM by gimbal2 RSS


      I am working a proyect with jsf 1.2 and facelets, now i want to use javascript funtions to validate a few of box but i can't . I am using the xhtml file i have it now

      <ui:define name="header">
                <script type="text/javascript" language="javascript" src="pruebaJavascrip.js"> </script>
                <script type="text/javascript">
                     function bodyLoaded(){
                     alert('Event bodyLoaded fucntion from overrriden template');


           and i called the funtion here:
      <h:commandButton value="Limpiar" action="#{consultaBean.clean}" styleClass="btn" onclick="bodyLoaded()" />

      but it no work , can u help can i use the javascrip into xhtml file????? thak u
        • 1. Re: JSF+FACELETS and maybe JAVASCRIPT?
          Use \
           tags when posting code to make it more readable and keep the forum from trying to interpret it.
          "It no work" is pretty much useless. How does it not work? You get a crash? Page does not render? The browser logs a javascript error? Your TV turns on by itself?
          Assuming "nothing at all" happens, can you make it work with a regular HTML button (<input type="button">) ? Are you sure that pruebaJavascript file you are including there is not causing conflicts?
          Also when you view the HTML source of the page in your browser, is there an actual 'onclick' attribute in the submit button that is generated for the commandButton? If not you may be running into a very old JSF 1.2 bug and you need to upgrade the version of JSF 1.2 used.
          And finally: a Google for "jsf command button onclick" will give you examples on how to do an onclick.