Results 1 to 4 of 4

Thread: XT-Ajax: doAjaxAction - ServerParameters not working

  1. #1
    Join Date
    Aug 2008
    Posts
    2

    Default 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 at 07:55 AM.

  2. #2
    Join Date
    Aug 2008
    Posts
    2

    Default 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 at 02:02 PM.

  3. #3
    Join Date
    Sep 2008
    Posts
    2

    Default

    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

  4. #4
    Join Date
    Sep 2008
    Posts
    2

    Default

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

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •