2

我正在尝试使以前的开发人员编写的一些代码正常工作。是的,他现在离开了公司。:-(

我有一个从 JS 代码进行的 JSON RPC 调用。JS 运行良好,回调方法返回一个对象(不是错误对象)。

但是 Java 类上的方法永远不会受到影响。smd 方法确实受到了打击。


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.
}

<package name="EntryBarRPC" namespace="/" extends="star-default">

    <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>
</package>

我不知道为什么,或者我错过了什么。我一遍又一遍地阅读JSON 插件页面。

我想我只需要另一双眼睛。

注意:Tomcat 控制台中没有错误,没有 JS 错误。

有人有任何线索吗?干杯杰夫波特

4

3 回答 3

2

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?

于 2008-10-20T16:42:32.510 回答
2

New version fixes my problems.

Google JSON plugin

于 2008-10-22T11:37:14.093 回答
1

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.

于 2008-10-20T16:40:26.290 回答