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: doAjaxAction - ServerParameters not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • XT-Ajax: doAjaxAction - ServerParameters not working

    Hi,

    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
    Code:
    <form name="" action="">
    <input id="testEvent" type="button" value="Press" onclick="XT.doAjaxAction('testEventAction', this,);">
    <div id="content"></div>
    </form>
    This one doesn't do anything. There is no reaction to that onlick event at all
    Code:
    <form name="" action="">
    <input id="testEvent" type="button" value="Press" onclick="XT.doAjaxAction('testEventAction', this, {'testparam' : 'TESTVALUE'},null);">
    <div id="content"></div>
    </form>
    The is the Action Handler
    Code:
    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();
            response.addAction(action);
            return response;
        }
    }
    the servlet.xml
    Code:
    <!-- Ajax Interceptor -->
    <bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
      <property name="handlerMappings">
        <props>
          <prop key="/preview.*">ajaxTestActionsHandler</prop>
        </props>
      </property>
    </bean>
    		
    <!-- 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



    UPDATE:

    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)

    Code:
     
    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.

    ezmorph.jar
    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.

    Comment


    • #3
      Hi!

      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

      Comment


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

        Thanks

        Comment

        Working...
        X