I suspect my problem is something obvious, the type that makes committers
fire off "please read the list!" e-mails...

But I've been searching through the list and haven't had any luck. 
Apologies in advance.

I'm using the JSON plugin.  As a sanity check, I tried to get the
JSONExample listed at http://cwiki.apache.org/S2PLUGINS/json-plugin.html up
and running in my (very simple) web app.  I had to make a few modifcations
that should probably be corrected in the Confluence page, but more on that
later.

The end result was that I was able to get the proper JSON response from
JSONExample.  So I copied the <action/> and pointed the new one at my Action
class (also setup the Spring plugin to autowire my service manager to my
action class):

<struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.objectFactory" value="spring"/>

    <package name="example" extends="json-default">
        <action name="JSONExample" class="example.JSONExample">
            <result type="json"/>
        </action>
        <action name="item" class="com.gfs.item.webapp.action.ItemAction">
            <result type="json"/>
        </action>
    </package>
</struts>

My action code is supposed to see if an item's ID or description is passed
in and then do the appropriate service call depending on which attribute is
set.  I want to return a JSON array of the item(s) that matched:

public class ItemAction {
    private ItemManager itemManager = null;
    private Long id = null;
    private String description = null;
    private Collection<Item> items = null;

   public String execute() {
        if (id != null) {
            items = new ArrayList<Item>();
            items.add(itemManager.getItemById(id));
        } else if (StringUtils.isNotEmpty(description)){
            items = itemManager.getItemsByDescription(description);
        }
        return Action.SUCCESS;
    }

    ... getter for the items collection, setters for everyone else ...
}

JSONExample still works, but I get this message when I try to hit
item.action:

"No result defined for action com.gfs.item.webapp.action.ItemAction and
result success"

?  I've got my <result/> right in there.  I didn't even modify the result
when I copied-n-pasted from the JSONExample action.  Why doesn't it
recognize the result?

Thanks,
Kyle
-- 
View this message in context: 
http://www.nabble.com/-S2--JSON-Plugin-and-No-Result-Defined-tf3608118.html#a10081221
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to