Thanks, Ryan. If I'll take the form processor path, it will be based on your code! But right now I'm thinking more freemarker template...
-will On 14.07.2010, at 20:14, Ryan Gardner wrote: > I wrote a dead-simple form processor that does pretty much that, but what the > form processor does is take all the parameters from the magnolia form and > then in turn resubmits them to another server via an HTTP Post using Basic > Auth. (I built my own ghetto-fabulous way for users to submit events to be > included on a calendar which then get posted to the author instance and > dumped in the inbox of someone who can review those events and approve them > to get put on the site) > > The entire form processor looks like this: > > http://pastebin.com/iakcTSYe > > The meat of it, where it loops over the parameters is pretty easy: > > MultipartForm form = MgnlContext.getPostedForm(); > ... > ArrayList<Part> parts = new ArrayList<Part>(); > > // add any attachments that were uploaded > for (String docName : form.getDocuments().keySet()) { > Part foo = new FilePart(docName, > form.getDocument(docName).getFile(), null, null); > parts.add(foo); > } > > // add any string params, including multi-valued params > for (String param : MgnlContext.getParameters().keySet()) { > String[] values = MgnlContext.getParameterValues(param); > for (String value : values) { > parts.add(new StringPart(param, value)); > } > } > Part[] partsArray = new Part[parts.size()]; > parts.toArray(partsArray); > > postMethod.setRequestEntity( new > MultipartRequestEntity(partsArray, postMethod.getParams()) ); > > I am working on cleaning it up a bit more today. If anyone is interested in > tweaking this kind of module more (an event submission module) I could post > the source on github or something and we could play with making it a bit more > robust... but at least this should give you an idea of how to get the values > out of the posted form in an easy way. > > Ryan > > On Jul 14, 2010, at 7:22 AM, Will Scheidegger wrote: > >> Yes, I thought about something like this too, but wanted to test if I could >> simply loop over all parameters from ctx. I think I'll give it a shot... >> although a custom form processor would most likely deliver the better >> looking results. >> >> -will >> >> On 14.07.2010, at 15:06, Grégory Joseph wrote: >> >>> I was hoping to be able to tell that that's what the contact form sample in >>> stk/demo-content does ? (by having something like ${.locals} [1] in the >>> template).. but that doesn't seem to work straight away. Maybe it's a hint >>> though, if you have a few minutes to spare. Or.. simply write another form >>> processor. >>> >>> hth, >>> >>> -g >>> [1] http://freemarker.sourceforge.net/docs/ref_specvar.html >>> From: Will Scheidegger [mailto:willscheideg...@mac.com] >>> To: Magnolia User-List [mailto:user-l...@magnolia-cms.com] >>> Sent: Mon, 12 Jul 2010 08:12:50 +0200 >>> Subject: [magnolia-user] "Easy form", i.e. Mag 3 form functionality? >>> >>> >>> Dear Magnolians >>> >>> Has anyone out there written a from processor for the form module which >>> works pretty much like the form in Mag 3 did, i.e. collecting all data and >>> simply sending it as "key: value" pairs? >>> >>> -will >>> >>> ---------------------------------------------------------------- >>> For list details see >>> http://www.magnolia-cms.com/home/community/mailing-lists.html >>> To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com> >>> ---------------------------------------------------------------- >>> >>> >>> >>> >>> ---------------------------------------------------------------- >>> For list details see >>> http://www.magnolia-cms.com/home/community/mailing-lists.html >>> To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com> >>> ---------------------------------------------------------------- >> >> >> >> ---------------------------------------------------------------- >> For list details see >> http://www.magnolia-cms.com/home/community/mailing-lists.html >> To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com> >> ---------------------------------------------------------------- > > > > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com> > ---------------------------------------------------------------- ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com> ----------------------------------------------------------------