Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
[XT Ajax] submit not doing ajax Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [XT Ajax] submit not doing ajax

    No trace of the xt ajax code running on the server.

    Outputting all the request params to the log there is no sign of either:

    ajax-request=ajax-submit or event-id=validate

    Am I missing something in the web page?

    Posting here the bits I think are relevant:

    Code:
    <script type="text/javascript" src="js/springxt.js"></script>
    <script type="text/javascript" src="js/prototype.js"></script>
    <script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
    ...
    <form id="command" method="post" action="">
    ...
    <input 
        type="submit" 
        value="Submit" 
        accesskey="s" 
        tabindex="14" 
        onclick="XT.doAjaxSubmit('validate', this);">
    Thanks for your time.

    Derek

  • #2
    Originally posted by derek View Post
    Code:
    <input 
        type="submit" 
        value="Submit" 
        accesskey="s" 
        tabindex="14" 
        onclick="XT.doAjaxSubmit('validate', this);">
    Your problem has been already discussed here: http://forum.springframework.org/sho...00&postcount=5

    You have to use an input of type button, not a submit one.

    Cheers,

    Sergio B.

    Comment


    • #3
      Possibly unsuported browser?

      Should have mentioned, I was testing it with Firefox 1.0.8 on FC4.
      Used Venkman to break at line 18, ajaxRequest.sendRequest();
      and if I understand Venkman correctly, the ajaxRequest object has no properties at this time.

      Testing it with IE6 on Windows I am seeing the XT ajax related request params on the server:

      name: ajax-request
      value: ajax-submit

      name: event-id
      value: validate

      Is Firefox 1.0.x unsupported?

      Cheers,
      D

      Comment


      • #4
        Ciao,

        Thanks for the reply (didn't see it until after submitting my last post).

        Last time I tried a button instead of input I had problems with IE but will give it a go all the same.

        One thing I was thinking was, wouldn't it be better to use an onsubmit event on the form instead of an onclick event on the submit button? Some people (including me) often submit forms by hitting the return key. In this case I'm thinking the ajax code wouldn't be reached.

        I'm a bit rusty on javascript and events etc, so could well be wrong about this.

        Cheers,
        D.

        Comment


        • #5
          Hi Derek,

          what kind of problems did you get with input buttons and IE?

          Originally posted by derek View Post
          One thing I was thinking was, wouldn't it be better to use an onsubmit event on the form instead of an onclick event on the submit button? Some people (including me) often submit forms by hitting the return key. In this case I'm thinking the ajax code wouldn't be reached.
          Using the onsubmit form event is not the correct way to go, because it gets called before sending the data to the server.

          If you want to use an input submit button, you have to return false from your event handler, in order to prevent the standard form submitting:
          Code:
          <input type="submit" value="Go" onclick="XT.doAjaxSubmit('validate', this); return false;"/>
          However, please remember that using inline handlers is a bad practice, good only for samples or very simple cases.

          Let me know if it works.
          Cheers,

          Sergio B.

          Comment


          • #6
            Hi Sergio,
            what kind of problems did you get with input buttons and IE?
            Now I remember better, IE button problems I encountered in the past were with button element, not input element of button type.

            However, I am having a problem with the input button in IE 6 now:

            Line 445:
            Exception thrown and not caught

            Seems a bit odd given that the next line is catch(exception)
            Code:
                        if(ajaxRequest.getPostRequest()) {
                            var f = ajaxRequest.getPostRequest();
                            f(ajaxRequest);
                        }
                    }                                                 <<<< line 445
                    catch(exception) {
            Good news is that it is working in Firefox 1.0.8 at least.

            Yes, you are right about the onsubmit event. Having experimented a bit it doesn't seem to cause any problem here but it also seems that using the return key on the form simulates the input submit being clicked so everything works ok if I use the
            Code:
            <input type="submit" value="Submit" accesskey="s" tabindex="14" onclick="XT.doAjaxSubmit('validate', this); return false;">
            control. I think this will also give the benefit that the form should still work with Javascript disabled.

            The IE 6.0 problem mentioned above is something I'll need to find a way around if I'm going to be able to use this for real though.

            Will experiment some more.

            Cheers,
            D.

            Comment


            • #7
              Originally posted by derek View Post
              I am having a problem with the input button in IE 6 now:

              Line 445:
              Exception thrown and not caught

              [CUT]

              Will experiment some more.
              Hi Derek,

              It's rather odd, I don't get any error in IE6: try playing with XT samples.

              Let us know how it goes, and if you discover anything interesting.
              I'll do the same.

              Cheers,

              Sergio B.

              Comment


              • #8
                Cause of error in IE6

                Hi Sergio,

                The error reported in IE6 was caused by the fact I hadn't put a placeholder element in the web page for every error code in the response. When I did put a placeholder div for each error code, it worked fine.

                I suppose it is a matter of opinion whether or not this condition should result in an error being thrown. Personally I'd prefer a warning rather than an error, with a meaningful message, and for the behaviour in such case to be consistent across browsers.

                But this isn't critical, good thing is that it works, so I can move on and look at implementing a Handler now.

                Cheers,
                D.

                Comment


                • #9
                  Originally posted by derek View Post
                  The error reported in IE6 was caused by the fact I hadn't put a placeholder element in the web page for every error code in the response. When I did put a placeholder div for each error code, it worked fine.
                  I suppose it is a matter of opinion whether or not this condition should result in an error being thrown. Personally I'd prefer a warning rather than an error, with a meaningful message, and for the behaviour in such case to be consistent across browsers.
                  It's a good piece of news: It is not critical, so I'll address that problem for the next 0.9 release.

                  It would be nice if you could open a Jira issue about that.

                  Originally posted by derek View Post
                  But this isn't critical, good thing is that it works, so I can move on and look at implementing a Handler now.
                  Ok, let us know if you need any help.

                  Cheers,

                  Sergio B.

                  Comment


                  • #10
                    Problem getting started with XT Ajax

                    Am just getting started on XT Ajax framework. I have followed instructions in the tutorial and the examples but can't get my action called. Here is my configuration:

                    JSP:


                    <script type="text/javascript" src="/web/scripts/xt/springxt-min.js"></script>


                    <link rel="stylesheet" type="text/css" media="all" href="/web/styles/springxt.css" />




                    <input type="button" value="Press" onclick="doAjaxAction('loadParties', this);">


                    <form:select id="targetAudienceID" path="targetAudienceID">
                    </form:select>



                    Spring:

                    <bean id="loadPartySelectionHandler" class="web.ajax.LoadPartySelectionHandler">
                    <property name="partyManager" ref="partyManager"/>
                    </bean>


                    <bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
                    <property name="handlerMappings">
                    <props>
                    <prop key="/party/act.html">loadPartySelectionHandler</prop>
                    </props>
                    </property>
                    </bean>





                    <bean id="party-urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
                    <property name="interceptors">
                    <list>
                    <ref bean="ajaxInterceptor"/>
                    </list>
                    </property>
                    <property name="mappings">
                    <props>
                    <prop key="/party/acts.html">actController</prop>
                    <prop key="/party/act.html">actFormController</prop>
                    </props>
                    </property>
                    </bean>



                    Thanks in advance.





                    Originally posted by sbtourist View Post
                    Your problem has been already discussed here: http://forum.springframework.org/sho...00&postcount=5

                    You have to use an input of type button, not a submit one.

                    Cheers,

                    Sergio B.

                    Comment


                    • #11
                      Originally posted by Mugoma Okomba View Post
                      Am just getting started on XT Ajax framework. I have followed instructions in the tutorial and the examples but can't get my action called. Here is my configuration:
                      [CUT]
                      Hi,

                      do you get any Javascript error? Any Java exception?

                      Moreover, can you post the signature of your Ajax handler?

                      Please let me know.
                      Cheers,

                      Sergio B.

                      Comment


                      • #12
                        Problem getting started with XT Ajax

                        No Javascript error. No Java exception.

                        There's no sign that the Java class is being called. Here's the java class:



                        package web.ajax;

                        import java.util.Collection;
                        import java.util.LinkedList;
                        import java.util.List;

                        import org.apache.commons.logging.Log;
                        import org.apache.commons.logging.LogFactory;
                        import org.springmodules.xt.ajax.AbstractAjaxHandler;
                        import org.springmodules.xt.ajax.AjaxActionEvent;
                        import org.springmodules.xt.ajax.AjaxResponse;
                        import org.springmodules.xt.ajax.AjaxResponseImpl;
                        import org.springmodules.xt.ajax.action.ReplaceContentAct ion;
                        import org.springmodules.xt.ajax.component.Option;

                        import web.ajax.model.Party;
                        import web.ajax.service.PartyManager;



                        public class LoadPartySelectionHandler extends AbstractAjaxHandler {

                        Log log = LogFactory.getLog( this.getClass() );

                        private PartyManager partyManager;

                        public AjaxResponse loadParties(AjaxActionEvent event) {

                        log.info("Entering loadParties with event:" + event.getEventId());

                        Collection<Party> parties = partyManager.getParties();

                        log.info("Parties:" + parties);

                        List options = new LinkedList();
                        Option first = new Option("-1", "Select one ...");
                        options.add(first);
                        for(Party party: parties) {
                        Option option = new Option(party, "partyID", "name");
                        options.add(option);
                        }

                        ReplaceContentAction action = new ReplaceContentAction("targetAudienceID", options);


                        AjaxResponse response = new AjaxResponseImpl();

                        response.addAction(action);

                        return response;
                        }

                        public void setPartyManager(PartyManager _partyManager) {
                        this.partyManager = _partyManager;
                        }
                        }



                        Thanks.


                        Originally posted by sbtourist View Post
                        Hi,

                        do you get any Javascript error? Any Java exception?

                        Moreover, can you post the signature of your Ajax handler?

                        Please let me know.
                        Cheers,

                        Sergio B.

                        Comment


                        • #13
                          Originally posted by derek View Post
                          The error reported in IE6 was caused by the fact I hadn't put a placeholder element in the web page for every error code in the response. When I did put a placeholder div for each error code, it worked fine.
                          As commented on the Jira issue (http://opensource.atlassian.com/proj...owse/MOD-308):

                          I'm not able to reproduce the error: what version of XT Ajax do you use?
                          Can you try to update XT js libs to the latest CVS revision?

                          Comment


                          • #14
                            Originally posted by Mugoma Okomba View Post
                            No Javascript error. No Java exception.
                            There's no sign that the Java class is being called.
                            See: http://forum.springframework.org/sho...17&postcount=2

                            Comment


                            • #15
                              Originally posted by sbtourist View Post
                              As commented on the Jira issue (http://opensource.atlassian.com/projects/spring/browse/MOD-308):

                              I'm not able to reproduce the error: what version of XT Ajax do you use?
                              Can you try to update XT js libs to the latest CVS revision?
                              Hi Sergio,

                              Just checked out whole springmodules module from cvs. Missing dependency problem building XT (ant dist)

                              Code:
                              :: problems summary ::
                                      WARN:   module not found: [ apache | commons-beanutils | 1.7 ]
                                      WARN:           integration-repo: tried /spring-modules/springmodules/projects/common-build/../integration-repo/artifacts/apache/commons-beanutils/ivy-1.7.xml
                                      WARN:           integration-repo: tried artifact [ apache | commons-beanutils | 1.7 ]/commons-beanutils.jar[jar]:
                                      WARN:                   /spring-modules/springmodules/projects/common-build/../integration-repo/artifacts/apache/commons-beanutils/jars/commons-beanutils-1.7.jar
                                      WARN:           filesystem-repo: tried /spring-modules/springmodules/projects/common-build/../repository/apache/commons-beanutils/ivy-1.7.xml
                                      WARN:           filesystem-repo: tried artifact [ apache | commons-beanutils | 1.7 ]/commons-beanutils.jar[jar]:
                                      WARN:                   /spring-modules/springmodules/projects/common-build/../repository/apache/commons-beanutils/jars/commons-beanutils-1.7.jar
                                      WARN:           ivyrep: tried http://ivyrep.jayasoft.org/apache/commons-beanutils/ivy-1.7.xml
                                      WARN:           ivyrep: tried artifact [ apache | commons-beanutils | 1.7 ]/commons-beanutils.jar[jar]:
                                      WARN:                   http://www.ibiblio.org/maven/commons-beanutils/jars/commons-beanutils-1.7.jar
                                      WARN:           ibiblio-maven2: tried http://www.ibiblio.org/maven2/apache/commons-beanutils/1.7/ivy-1.7.xml
                                      WARN:           ibiblio-maven2: tried artifact [ apache | commons-beanutils | 1.7 ]/commons-beanutils.jar[jar]:
                                      WARN:                   http://www.ibiblio.org/maven2/apache/commons-beanutils/1.7/commons-beanutils-1.7.jar
                                      WARN:           org-ibiblio: tried no ivy pattern => no attempt to find ivy file for [ apache | commons-beanutils | 1.7 ]
                                      WARN:           org-ibiblio: tried artifact [ apache | commons-beanutils | 1.7 ]/commons-beanutils.jar[jar]:
                                      WARN:                   http://www.ibiblio.org/maven2/org/commons-beanutils/commons-beanutils/1.7/commons-beanutils-1.7.jar
                                      WARN:   ::::::::::::::::::::::::::::::::::::::::::::::
                                      WARN:   ::          UNRESOLVED DEPENDENCIES         ::
                                      WARN:   ::::::::::::::::::::::::::::::::::::::::::::::
                                      WARN:   :: [ apache | commons-beanutils | 1.7 ]: not found
                                      WARN:   ::::::::::::::::::::::::::::::::::::::::::::::
                              Guess I can just copy the .js from ./src/js/lib/core/springxt.js into my app without building anyway. Will try that and see if I still get the error.

                              Regards,
                              D

                              Comment

                              Working...
                              X