views:

785

answers:

5

Hi all,

I'm trying to get some code working that a previous developer has written. Yep, his now left the company. :-(

I have a JSON RPC call being made from the JS code. The JS all runs fine & the callback method gets an object back (not an error object).

But the method on the Java class never gets hit. The smd method does get hit though.


public String smd()
{
return SUCCESS; // break point reaches here
}

@SMDMethod
public void updateRowValueForField(String key, String value, String fieldname)
{
// We never get into this method.
}


Blockquote

<action name="ebToggleSelection" class="eboggleSelectionAction" method="smd">
  <interceptor-ref name="jsonStack">
    <param name="enableSMD">true</param>
  </interceptor-ref>
  <result type="json">
    <param name="enableSMD">true</param>
  </result>
</action>


I'm stumpped as to why, or what I'm missing. I've read JSON plugin page over and over.

I think I just need another set of eyes.

Note: no errors in the Tomcat console, no JS errors.

Anyone got any clues? Cheers Jeff Porter

A: 

I'm guessing that you need to update the smd() method to actually call updateRowValueForField() rather than simply return immediately. Looks like the previous developer never actually hooked up the methods.

matt b
+1  A: 

You forgot to include the javascript code. From the example:

<s:url id="smdUrl" namespace="/nodecorate" action="SMDAction" />
<script type="text/javascript">
    //load dojo RPC
    dojo.require("dojo.rpc.*");

    //create service object(proxy) using SMD (generated by the json result)
    var service = new dojo.rpc.JsonService("${smdUrl}");

    //function called when remote method returns
    var callback = function(bean) {
        alert("Price for " + bean.type + " is " + bean.price);
    };

    //parameter
    var bean = {type: "Mocca"};

    //execute remote method
    var defered = service.doSomething(bean, 5);

    //attach callback to defered object
    defered.addCallback(callback);
</script>

Are you sure you call service.updateRowValueForField(key, value, fieldname) and not something different?

Further, your method returns a void (e.g. doesn't return anything). What did you expect to get?

extraneon
A: 

Thanks for the replys.

My JS code is pretty much as above...

function updateRowValue(action, key, value, fieldname, callback)
{
//load dojo RPC
dojo.require("dojo.rpc.*");

//create service object(proxy) using SMD (generated by the json result)
var service = new dojo.rpc.JsonService(action);

//execute remote method
var defered = service.updateRowValueForField(("" + key), ("" + value), ("" + fieldname));

//attach callback to defered object
defered.addCallback(callback);
}

I didn't think that I had to link up the smd() method to call the updateRowValueForField() method. I presumed that the point is that it calls the updateRowValueForField() on the class. Otherwise, how would it pass the parameters over?

Anyother ideas?

:-)

Jeff Porter

jeff porter
A: 

ahhh!!!!!

Its a firefox 3 & Struts 2.09 thing!!

dojo forum post

I've still no idea how to fix it, anyone?

:-)

jeff porter
+1  A: 

New version fixes my problems.

Google JSON plugin

jeff porter