You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tmaus <lo...@yahoo.com> on 2012/08/16 12:16:23 UTC

Read POST based request from external site

I was looking up all available threads, but did not find an answer. 

I have an app deployed to a mobile device that should communicate with my
service via REST. 

As part of the flow the user can upload a new picture to the service. 

My page is able to read GET based requests, but no POST based onces. 

Im using wicket 1.5.7

RequestCycle.get().getRequest().getPostParameters() is empty 

My page extends "WebPage"

Tried to use constructor with and without PageParameters without any
success.

I mounted my page (mountPage("/upload",UploadPage.class)) with
WebApplication. 

Any ideas ?

Any hints ?

Regards

Thorsten 





--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Read-POST-based-request-from-external-site-tp4651269.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Read POST based request from external site

Posted by Andrea Del Bene <an...@gmail.com>.
I think there's a bug with class WebApplication which doesn't create a 
MultipartServletWebRequestImpl when the original request is multipart. 
In the meantime a possible workaround is to override method 
newWebRequest of your application class and put the following code 
inside it:

{
         ServletWebRequest newWebRequest = new 
ServletWebRequest(servletRequest, filterPath);
         String contentType = servletRequest.getContentType();

         if (!Strings.isEmpty(contentType) &&
contentType.toLowerCase().contains("multipart/form-data"))
         {
             try
             {
                 return newWebRequest.newMultipartWebRequest(
getApplicationSettings().getDefaultMaximumUploadSize(), "externalForm");
             }
             catch (FileUploadException e)
             {
                 throw new RuntimeException(e);
             }
         }

         return newWebRequest;
     }

this should solve your problem with post parameters.
> Thanks for your replies:
>
> This is my plain html code:
>
>   <form action="/upload" method="POST" enctype="multipart/form-data">
>              <input type="text" name="id"/>
>              <br/>
>              <input type="file" name="file"/>
>              <br/>
>              <input type="submit" value="ab dafür"/>
>          </form>
>
> This is my Wicket class:
>
> public class UploadPage extends WebPage {
>
>      final Logger LOG = LoggerFactory.getLogger(getClass());
>
>      public UploadPage() {
>         
>         for(String str :
> getRequest().getRequestParameters().getParameterNames()){
>             LOG.debug("==> " + str);
>         }
>
>      }
> }
>
>
> I cannot read a single param.
>
> Pls. keep in mind:
> The form is NO wicket form as I try to simulate an external access to my
> page.
>
> Thanks for your help
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Read-POST-based-request-from-external-site-tp4651269p4651279.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Read POST based request from external site

Posted by tmaus <lo...@yahoo.com>.
Thanks for your replies:

This is my plain html code:

 <form action="/upload" method="POST" enctype="multipart/form-data">
            <input type="text" name="id"/>
            <br/>
            <input type="file" name="file"/>
            <br/>
            <input type="submit" value="ab dafür"/>
        </form>

This is my Wicket class:

public class UploadPage extends WebPage {

    final Logger LOG = LoggerFactory.getLogger(getClass());

    public UploadPage() {
       
       for(String str :
getRequest().getRequestParameters().getParameterNames()){
           LOG.debug("==> " + str);
       }

    }
}


I cannot read a single param. 

Pls. keep in mind:
The form is NO wicket form as I try to simulate an external access to my
page. 

Thanks for your help




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Read-POST-based-request-from-external-site-tp4651269p4651279.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Read POST based request from external site

Posted by Andrea Del Bene <an...@gmail.com>.
Hi,

try getRequestParameters() instead of getPostParameters(). This method 
returns all request parameters. I don't know why getPostParameters() 
return an empty result, maybe it is an issue...
> I was looking up all available threads, but did not find an answer.
>
> I have an app deployed to a mobile device that should communicate with my
> service via REST.
>
> As part of the flow the user can upload a new picture to the service.
>
> My page is able to read GET based requests, but no POST based onces.
>
> Im using wicket 1.5.7
>
> RequestCycle.get().getRequest().getPostParameters() is empty
>
> My page extends "WebPage"
>
> Tried to use constructor with and without PageParameters without any
> success.
>
> I mounted my page (mountPage("/upload",UploadPage.class)) with
> WebApplication.
>
> Any ideas ?
>
> Any hints ?
>
> Regards
>
> Thorsten
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Read-POST-based-request-from-external-site-tp4651269.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Read POST based request from external site

Posted by Thomas Götz <to...@decoded.de>.
This normally means that there *are* no POST parameters. Are you sure you're doing a POST request to your page, and not a GET?

   -Tom


On 16.08.2012, at 12:16, tmaus <lo...@yahoo.com> wrote:

> 
> I was looking up all available threads, but did not find an answer. 
> 
> I have an app deployed to a mobile device that should communicate with my
> service via REST. 
> 
> As part of the flow the user can upload a new picture to the service. 
> 
> My page is able to read GET based requests, but no POST based onces. 
> 
> Im using wicket 1.5.7
> 
> RequestCycle.get().getRequest().getPostParameters() is empty 
> 
> My page extends "WebPage"
> 
> Tried to use constructor with and without PageParameters without any
> success.
> 
> I mounted my page (mountPage("/upload",UploadPage.class)) with
> WebApplication. 
> 
> Any ideas ?
> 
> Any hints ?
> 
> Regards
> 
> Thorsten 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org