See you wednesday nite at fenway http://boston.redsox.mlb.com/index.jsp?c_id=bos
Martin-- ----- Original Message ----- From: "Ted Husted" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Friday, October 19, 2007 7:45 AM Subject: Re: JSON RPC > I've been doing some work with Struts and JSON, but I don't know > anything about using JSON RPC with Swing. > > For Struts, you don't really need to use full-blown JSON RPC. You can > use an ordinary XHR submit, and then use the JSON plugin for the > result. The tricky part is handling exceptions. Without RPC, it's > helpful to setup a base Action support class that exposes the > Exception messages as properties. > > In the Action support class, we add properties like this: > > public String getExceptionMessage() { > ActionContext context = ActionContext.getContext(); > Object value = context.getValueStack(). > findValue("exception.message"); > if (value==null) return null; > return value.toString(); > } > > public String getExceptionStack() { > ActionContext context = ActionContext.getContext(); > Object value = context.getValueStack(). > findValue("exceptionStack"); > if (value==null) return null; > return value.toString(); > } > > and add an exception handler to struts.xml > > <global-results> > <result name="error"/> > </global-results> > > <global-exception-mappings> > <exception-mapping > exception="java.lang.Exception" result="error"/> > </global-exception-mappings> > > Then, on the client-side, we check for the exception. Here's the code > we use for YUI: > > my.asyncRequest = function (sAction, fnCallback) { > return YAHOO.util.Connect.asyncRequest("POST", sAction, { > success : function(o) { > var oPayload = eval("(" + o.responseText + ")") ; > if (oPayload.exceptionMessage) { > my.asyncRequestException(o.responseText); > } > fnCallback(oPayload); > }, > failure : function(o) { > my.asyncRequestError(o.responseText); > } > }); > }; > > This is working for now, but we'd like to refine the approach so that > it looks more like JSON RPC. > > I'll be speaking more about this approach at the Ajax Experience in > Boston next week. > > -- HTH, Ted > <http://www.husted.com/ted/blog/> > > > On 10/19/07, Frans Thamura <[EMAIL PROTECTED]> wrote: > > hi > > > > anyone have successdevelop JSON on Struts but the apps is not read but > > submit data > > > > i know this is JSON RPC > > > > but anyone success create it? > > > > i want the client is not javacsript buat swing > > > > any glue for me all? > > > > Frans > > Indonesia > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]