Tim:

That's really good to know. Thanks for the demo. I may use that in another 
scenario.

Unfortunately, in the case I mentioned, I am implementing an abstract method 
that takes a Representation as the argument and since Form doesn’t extend 
Representation I can't use it as the argument. I may just create the Form on 
the fly without Spring as in:

@Post
public Representation doPost(Representation entity) {
    Form form = new Form(entity);
    doSomethingWithForm(form);
    // etc.
}

I'm new to Spring and so I always seek to know how to construct an object via 
Spring rather than calling "new" in my code but I'm not sure how much value DI 
gives me in this case especially since it's just an object created locally, 
passed to another private method, and then trashed.

Of course, if you or anyone else have any insights about this, I'm all ears.

Thanks again.

From: Tim Peierls <[email protected]<mailto:[email protected]>>
Reply-To: discuss 
<[email protected]<mailto:[email protected]>>
Date: Mon, 8 Aug 2011 11:55:47 -0500
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: Spring inject a Form constructed using the requestEntity

The org.restlet.data.Form instance is created automatically from the entity. 
Run this demo server:

http://pastebin.com/G0t4ExYP

and use whatever submission technique you choose (see the curl suggestion in 
the class comment) to post some data, and you can verify that it works without 
any special configuration.

--tim


On Mon, Aug 8, 2011 at 10:18 AM, Paul Morris 
<[email protected]<mailto:[email protected]>> wrote:
It's a publicly exposed HTTP call so I won't be getting an 
org.restlet.data.Form passed in. I'll be getting an entity body with params as 
in:

param=value&otherparam=value

Paul Morris

On Aug 8, 2011, at 8:32 AM, "Tim Peierls" 
<<mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]>>[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
 wrote:

I'm probably missing something, but why isn't the following acceptable?

@Post public Representation doPost(Form form) {
   // do stuff with form
}

--tim

On Sun, Aug 7, 2011 at 11:54 PM, Paul Morris 
<<mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]>><mailto:[email protected]<mailto:[email protected]>>[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
 wrote:
I might also mention that I'm trying to keep my bean from being Spring aware so 
I'm looking for the solution that is as least Spring-invasive as possible. 
Thanks.

> This may be more of a Spring question than a Restlet question but can someone 
> advise on the best way to handle the following in Restlet/Spring:
>
> I want to create a Form dynamically when a POST is called as in:
>
> @Post
> public Representation doPost(Representation entity) {
>     Form form = new Form(getRequestEntity());
>     // do stuff with the parameters in the form
> }
>
> But how do I inject the Form into my ServerResource object in the Spring 
> context file since it won't have what it needs (namely the requestEntity) to 
> get instantiated until after the POST gets called?

------------------------------------------------------
<http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812411><http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812411><http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812411>http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812411

This message and any included attachments are intended only for the addressee. 
The information contained in this message is confidential and may constitute 
proprietary or non-public information under international, federal, or state 
laws. Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812526

This message and any included attachments are intended only for the addressee. 
The information contained in this message is confidential and may constitute 
proprietary or non-public information under international, federal, or state 
laws. Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2812576

Reply via email to