Hi Luther,

How about just binding to a property?

Javascript (jQuery):
$.post(url, {jsonString: '[[0,"2"],["2",-1]]'});

Java:
public String jsonString;
// could also use private field with public getter and setter if you
prefer

@HandlesEvent("update")
@DefaultHandler
public Resolution updateState()
{
    try
    {
        StateBeanAction.LOG.info("StateBeanAction.updateState: " +
        jsonString;
        return new StreamingResolution(MimeTypes.JSON, "");
    } catch (final IOException e) {
        final String msg = "Error tring to parse JSON state string. "
                + e.getMessage();
        StateBeanAction.LOG.error(msg, e);
    }
    return null;
}

Let me know if that helps.

Cheers,
Freddy

On Mon, 1 Mar 2010 14:21:03 -0800 (PST), "luther.baker"
<lutherba...@gmail.com> said:
> 
> I am setting up my first Stripes application and got most things working
> well. I am currently stuck trying to read JSON from a jQuery POST.
> 
> 
> I have  http://www.charlesproxy.com/ Charles  setup and can confirm the
> POST
> to localhost and can see the post content as the JSON string I am
> sending.
> The correct Stripes ActionBean handler is getting invoked but
> unfortunately,
> when I try to read the stream - I get nothing.
> 
> 
> Does Stripes possibly filter something like this? I'm not explicitly
> setting
> much on the jQuery side (type or anything).
> 
> 
> Javascript (jQuery):
> $.post(url, '[[0,"2"],["2",-1]]');
> 
> 
> Java:
>     @HandlesEvent("update")
>     @DefaultHandler
>     public Resolution updateState()
>     {
>         final StringBuffer buf = new StringBuffer();
>         String line = null;
>         try {
>             final BufferedReader reader =
> getContext().getRequest().getReader();
>             line = reader.readLine();
>             while (line != null) {
>                 buf.append(line);
>                 line = reader.readLine();
>             }
>             StateBeanAction.LOG.info("StateBeanAction.updateState: " +
> buf.toString());
>             return new StreamingResolution(MimeTypes.JSON, "");
>         } catch (final IOException e) {
>             final String msg = "Error tring to parse JSON state string. "
>                     + e.getMessage();
>             StateBeanAction.LOG.error(msg, e);
>         }
>         return null;
>     }
> 
> 
> Charles:
> POST /agenda/action/state/update HTTP/1.1
> Host: localhost:8080
> User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
> rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
> Accept: */*
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
> X-Requested-With: XMLHttpRequest
> Referer: http://localhost:8080/agenda/dashboard/index.jsp
> Content-Length: 18
> Cookie: JSESSIONID=D3894E672B6A00D6277BFD6C74DF0CA1
> Pragma: no-cache
> Cache-Control: no-cache
> 
> [[0,"2"],["2",-1]]
> 
> 
> I can set breakpoints and see log entries to confirm that the ActionBean
> is
> hit. It's just that reader.readLine() is returning null on the first
> read.
> 
> 
> Any thoughts would be appreciated. Thanks,
> 
> 
> -Luther
> 
> 
> 
> -- 
> View this message in context:
> http://old.nabble.com/Reading-JSON-in-an-ActionBean-tp27749822p27749822.html
> Sent from the stripes-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to