Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 256F5D460 for ; Fri, 5 Oct 2012 16:46:03 +0000 (UTC) Received: (qmail 71754 invoked by uid 500); 5 Oct 2012 16:46:00 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 71632 invoked by uid 500); 5 Oct 2012 16:46:00 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 71622 invoked by uid 99); 5 Oct 2012 16:46:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2012 16:46:00 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL,URIBL_DBL_SPAM X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.214.176] (HELO mail-ob0-f176.google.com) (209.85.214.176) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2012 16:45:55 +0000 Received: by mail-ob0-f176.google.com with SMTP id x4so2421477obh.35 for ; Fri, 05 Oct 2012 09:45:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding:x-gm-message-state; bh=fp7cfgvn0zPNDL5sbAas//vnUz7MeIOvbTBtUuAUCP4=; b=ThuBQonPD8dpnLcAEJvGSX0TXDb2NWwaAVEYBtKoO7jhU956fEbHVxZ52ocqzKK/YT bdu43izH2kcUHc9zfy+gxhL8v5Qq00R1YGNCjWVDQ1x1Myhzdc9Cyl8WEU7bkzOeNunf oMmvsgaxc5vS7rCJzQRiqPDhVtUjA6u7PoE2Dtg0KyVEBZr4xttbrCkFLPq1k2mY4tL7 th/91iIhCWDTdMINbXX+TmruK47QrxLyEGpP5eMTF2UzmjofdAYVOCDX0zM5PxmFaJNf V7eH3La0o9dG1UC7jX2dm6RGTD13p02AIKtj+Ni+82q1FuuDXoS4DgyVUsG2gcIuS+xR 13Lg== Received: by 10.182.38.65 with SMTP id e1mr7505684obk.3.1349455533374; Fri, 05 Oct 2012 09:45:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.148.162 with HTTP; Fri, 5 Oct 2012 09:45:13 -0700 (PDT) In-Reply-To: References: From: Frans Thamura Date: Fri, 5 Oct 2012 23:45:13 +0700 Message-ID: Subject: Re: how to write json/xml output using struts 2 and rest + convention plugin To: Struts Users Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkxqtGAlh1SEB9oIUXBsNTwtkxG9chvGpAd8HSHnBwWN0csu4/uAQZG3uPG0/kqd8IlLghK hi all esp jane let me summarize all our work here. 1. S2 REST Plugins we modify the default S2 REST Plugin, so we dont need SMD anymore, just use @Action and @Resut with type, and you can get full REST , PUT, GET, DELETE, POST. @Action(name =3D "/list", method =3D HttpMethod.GET) -> for REST GET take a look the plugins. http://java.net/projects/s2restplugins/pages/Home 2. Yama We use S2 + REST plugin (no. 1 above), and use Spring + Hibernate, call it = Yama. http://yama.java.net/ this is a project template to start create a CRUD using S2 with REST approach, output can JSON or XML. see my yama run on Azure. http://yama7.cloudapp.net/yama/ and our yama-showcase also in the SVN, and this is the demo. run on Stackato (OpenSTack and Cloud Foundry integration ). http://yama-showcases.atisicloud.net/home user admin, password admin. the key in yama, is DefaultPersistance and several "aware" , take a look inside Spring Context to understand it. 3. Nurdoo We create nurdoo , as a real case implementation using yama. all opensourced under Apache license. enjoy. we create a lot of apps based on yama. -- Frans Thamura (=E6=9B=BD=E5=BF=97=E8=83=9C) Shadow Master and Lead Investor Meruvian. Integrated Hypermedia Java Solution Provider. Mobile: +628557888699 Blog: http://blogs.mervpolis.com/roller/flatburger (id) FB: http://www.facebook.com/meruvian TW: http://www.twitter.com/meruvian / @meruvian Website: http://www.meruvian.org "We grow because we share the same belief." On Fri, Oct 5, 2012 at 9:19 PM, Frans Thamura wrote: > jane > > the way our rest model is not using smd which you can get in s2 default r= est > plugins > > please visit our s2restplugins.java.net > > may be this plugins and small wiki can explain more. > > the category has extended from default persistanc. you must see the sprin= g > injection that handle this > > Frans Thamura > Meruvian > > On Oct 5, 2012 9:13 PM, "Jane Wayne" wrote: >> >> frans, >> >> i'm looking at >> http://java.net/projects/nurdoo/sources/nurdoo-web-svn/content/trunk/src= /main/java/org/nurdoo/prayers/actions/CategoryAction.java?rev=3D3. >> >> could you please point me specifically to how you guys output JSON/XML >> back to the client? >> >> let me see if i got this right. you guys use s2 + rest + convention to >> accomplish the restful features. then, you guys used freemarker to >> output content? where's the code/ability to swap between JSON/XML for >> output? >> >> On Fri, Oct 5, 2012 at 8:22 AM, Frans Thamura wrote= : >> > hi jane >> > >> > all our apps using s2 with rest and json. >> > >> > see our example.at www.nurdoo.org >> > >> > source in nurdoo.java.net >> > >> > Frans Thamura >> > Meruvian >> > On Oct 5, 2012 7:11 PM, "Jane Wayne" wrote: >> > >> >> not really/entirely what i'm looking for. the struts2-json-plugin >> >> supports json. but what about xml? i need the flexibility to alter >> >> between the two for the client/consumer of the rest services. >> >> >> >> On Thu, Oct 4, 2012 at 7:41 PM, Ken McWilliams >> >> >> >> wrote: >> >> > I'm not familiar with this application but simply look at the >> >> > documentation for the struts2-json-plugin, you can specify a json >> >> > result and you can specify include and exclude parameters (so you >> >> > just >> >> > return the part(s) of your Action you want). In this way you could >> >> > define a new map, put a key of "results" with a value of "New order >> >> > created successfully" and return it quite easily. If the struts2 >> >> > document is insufficient there are plenty of examples also on >> >> > StackOverflow, so take a look there too (Including many annotation >> >> > based examples). >> >> > >> >> > On Thu, Oct 4, 2012 at 4:21 PM, Jane Wayne >> >> wrote: >> >> >> i've downloaded the demo apps for struts 2 v2.3.5 SNAPSHOT for >> >> >> today. >> >> >> i am trying to understand and study the rest struts2-rest-showcase >> >> >> webapp. >> >> >> >> >> >> in the rest showcase, the OrdersController class has the following >> >> method. >> >> >> >> >> >> public String editNew() { >> >> >> model =3D new Order(); >> >> >> return "editNew"; >> >> >> } >> >> >> >> >> >> the user is taken to orders-editNew.jsp. on this page, the form >> >> >> posts >> >> >> to: action=3D"%{#request.contextPath}/orders". the action to handl= e >> >> >> this >> >> >> form is as follows. >> >> >> >> >> >> public HttpHeaders create() { >> >> >> ordersService.save(model); >> >> >> addActionMessage("New order created successfully"); >> >> >> return new >> >> >> DefaultHttpHeaders("success").setLocationId(model.getId()); >> >> >> } >> >> >> >> >> >> at this point, the user is taken to orders-index.jsp. however, i d= o >> >> >> not want to take the user to this page. i instead want to write a >> >> >> JSON/XML message back saying something (just like the action >> >> >> message) >> >> >> to indicate success/failure. how do i do this? >> >> >> >> >> >> i imagine my client application posting data to: /orders/new >> >> >> and then receiving some JSON message: >> >> >> { "results" : "New order created successfully" } >> >> >> >> >> >> any help is appreciated. >> >> >> >> >> >> >> >> >> ------------------------------------------------------------------= --- >> >> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> >> >> For additional commands, e-mail: user-help@struts.apache.org >> >> >> >> >> > >> >> > -------------------------------------------------------------------= -- >> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> >> > For additional commands, e-mail: user-help@struts.apache.org >> >> > >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> >> For additional commands, e-mail: user-help@struts.apache.org >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> For additional commands, e-mail: user-help@struts.apache.org >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org