Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

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.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
XT-Ajax: doAjaxAction - ServerParameters not working Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • XT-Ajax: doAjaxAction - ServerParameters not working


    I'm trying to pass some JSON object as a parameter by an Ajax Action Event to the server.

    Without any parameters (null) the event works perfectly and does what its supposed to do.

    But when I put some JSON object as "server-parameters" there is not response to the click at all.

    This is the definition of the doAjaxAction method in the manual.

    onclick="XT.doAjaxAction(event-id, source-element, server-parameters, client-parameters);"

    The following line works perfectly
    <form name="" action="">
    <input id="testEvent" type="button" value="Press" onclick="XT.doAjaxAction('testEventAction', this,);">
    <div id="content"></div>
    This one doesn't do anything. There is no reaction to that onlick event at all
    <form name="" action="">
    <input id="testEvent" type="button" value="Press" onclick="XT.doAjaxAction('testEventAction', this, {'testparam' : 'TESTVALUE'},null);">
    <div id="content"></div>
    The is the Action Handler
    public class TestActionsHandler extends AbstractAjaxHandler {
      public AjaxResponse testEventAction(AjaxActionEvent event) {
            // doing here something with the parameter Value via event.getParameters().get("testparam")
        	AppendContentAction action = new AppendContentAction("content", new SimpleText("test"));
            AjaxResponse response = new AjaxResponseImpl();
            return response;
    the servlet.xml
    <!-- Ajax Interceptor -->
    <bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
      <property name="handlerMappings">
          <prop key="/preview.*">ajaxTestActionsHandler</prop>
    <!-- Ajax Handling -->
    <bean id="ajaxTestActionsHandler" class="ajax.TestActionsHandler"/>
    can anybody tell me why that event doesn't fire when i wanna pass some JSON parameters to the server.

    Thanks in advance


    There is a response. I traced the call and there seams to be a problem within the AjaxInterceptor. Within the initEvent method the JSONObject never returns. The code just stops at the last line of the following snippet. I tried to look into JSON itself but didn't find anything there.
    (The paramsString is a valid JSON Object)

    private void initEvent(AjaxEvent event, HttpServletRequest request) {
      String paramsString = request.getParameter(this.jsonParamsParameter);
      if (paramsString != null) {
        Map<String, String> parameters = new HashMap<String, String>();
        JSONObject json = JSONObject.fromString(paramsString);
    ANY contribution is appreciated.

    Thank you
    Last edited by NJansen; Aug 22nd, 2008, 07:55 AM.

  • #2
    Very helpfull forum

    I found the solution. I have no idea why or where i was supposed to know that from but you have to import several libraries which are listed nowhere and no exception was thrown.

    commons.beanutils package

    have to be imported to use JSONObjects with XT-Ajax Calls as Serverparameters.

    Have Fun
    Last edited by NJansen; Aug 25th, 2008, 02:02 PM.


    • #3

      I can't find any commons.beanutils package in Ezmorph.jar, am I missing something here? I know there is a commons.beanutils jar from apache, but that didn't work.

      Any help is much much apriciated


      • #4
        Sorry, my mistake, I figured it out. Your solution works perfect. Importing ezmorph.jar and commons.beanutils.jar libraries did the trick.