5 Replies Latest reply on Apr 1, 2009 11:29 AM by schlumsch

    calling javascript-function with a4j:support?

    schlumsch

      Hello,

      I have a inputText-Element within my jsf-page. Now, when user has entered a new value a javascript-method has to be called. Is this possible?



      <script type="text/javascript">
       //<![CDATA[
       function alertme() {
       alert('me');
       }
       //]]>
      </script>
      
       <h:inputText required="true" id="tourStopStartAddress" value="#{e2e.tour.startAddress}" size="50" styleClass="portlet-form-input-field" requiredMessage="#{res.CAPTURE_NEEDSTART}" immediate="true" valueChangeListener="#{e2e.tour.changeStartAddress}">
      <a4j:support event="onchange" action="alertme()" reRender="tourGrid,zusammenfassung,zusammenfassungStartAddress" />
       </h:inputText><br/>
      


        • 1. Re: calling javascript-function with a4j:support?
          six-p4ck

          may be just:


          <h:inputText onchange="alertme();" />
          


          • 2. Re: calling javascript-function with a4j:support?
            nbelaevski

            Hello,

            Use onsubmit attribute of a4j:support.

            • 3. Re: calling javascript-function with a4j:support?
              schlumsch

              Well, thanx a lot, works fine. But now another problem occurs, maybe u can also help me with this. The method im calling when user changes the input is placing markers on a googlemap-component. The problem is now, that event onchange occurs earlier than my valuechangelistener. So when the user has entered a new value and leaves the inputelement, all data for displaying markers are empty.

              I have also put a simple link on my page for testing. If i change the value of inputtext and activate this link, my map works fine...

              • 4. Re: calling javascript-function with a4j:support?
                schlumsch

                okok, use oncomplete to solve this is the answer :)

                • 5. Re: calling javascript-function with a4j:support?
                  schlumsch

                  So, excuse me but there is another question. The same javascrip should now be called after action-method of a commandbutton has finished. Can u tell me how 2 do this?

                  [CODE]
                  <a4j:commandButton style="width:170px;" align="right" value="#res.MODALPANELSTARTADDRESSBUTTONNEWADDRESS}"
                  action="#{e2e.tour.takeStartAddressFromModalPanel}" onclick="#{rich:component('startModalPanel')}.hide(), showPlace()" reRender="startAddressPanelGroup, zusammenfassungStartAddress">

                  <a4j:actionparam name="hasCanceledStartAddressAlternative" value="true"
                  assignTo="#{e2e.tour.hasCanceledStartAddressAlternative}" />
                  <!-- <a4j:support event="onclick" oncomplete="showPlace()" reRender="tourGrid,zusammenfassung,zusammenfassungStartAddress" />-->
                  </a4j:commandButton>
                  [CODE]