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
Problem getting started with XT Ajax Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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. I am using XT ajax with spring MVC. 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>



    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 in advance.

  • #2
    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. I am using XT ajax with spring MVC.
    What XT Ajax version do you use?
    Moreover, can you put the log level to DEBUG and post some server side log?

    Thanks,
    Cheers,

    Sergio B.

    Comment


    • #3
      I am using XT Ajax 0.7. Debug is enabled.

      Still no message. No sign that I am reaching server-side code.

      Thanks.

      Originally posted by sbtourist View Post
      What XT Ajax version do you use?
      Moreover, can you put the log level to DEBUG and post some server side log?

      Thanks,
      Cheers,

      Sergio B.

      Comment


      • #4
        Originally posted by Mugoma Okomba View Post
        I am using XT Ajax 0.7. Debug is enabled.
        Still no message. No sign that I am reaching server-side code.
        I'm running out of ideas: can you put a breakpoint in the AjaxInterceptor preHandle method and debug it?
        What does it happen?

        Comment


        • #5
          Hi,

          Looking at the original post, seems you are missing the supporting javascript files:

          <script type="text/javascript" src="js/prototype.js"/>
          <script type="text/javascript" src="js/scriptaculous.js?load=effects"/>

          Note, the latter downloads both scriptaculous.js and effects.js files.

          Regards,
          Derek

          Comment


          • #6
            After going through all my Spring configuration files I discovered that I had mixed up the AjaxInterceptor. I have two link to the same form. One was missing AjaxInterceptor, and this is the one I was calling. The configurations I sent to the list were correct only that I was not calling the correct link.

            I am very sorry for the confusion emanating from my end.

            Now I have all that corrected and I can spit out Ajax. XT Ajax is great.

            Thanks a lot for the help offered.


            Originally posted by sbtourist View Post
            I'm running out of ideas: can you put a breakpoint in the AjaxInterceptor preHandle method and debug it?
            What does it happen?

            Comment

            Working...
            X