@Andrea,

What about using a IRequestCycleListener that will set the response headers
only if the resolved IRequestHandler is from specific type ?
Is it easy to detect that this is a REST IRequestHandler ?

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jun 27, 2017 at 7:13 PM, Andrea Del Bene <an.delb...@gmail.com>
wrote:

> you can also override onAfterMethodInvoked in your resource class to set
> the header in a single point of your code.
>
> On 27 Jun 2017 18:25, "Maxim Solodovnik" <solomax...@gmail.com> wrote:
>
> > You can use CORS in Tomcat:
> > https://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter
> > (Maybe there anything similar in other app servers)
> >
> > Or wicket CSRF filter:
> > https://ci.apache.org/projects/wicket/apidocs/7.x/
> > org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListener.html
> >
> > On Tue, Jun 27, 2017 at 9:23 PM, Noven <noven_...@yahoo.com.invalid>
> > wrote:
> > > Hi, Marcel,
> > > Thank you very much. Your solution works perfectly.
> > >
> > > With this solution, I have to add the header in every method. Do you
> > know how to set it once, and automatically applied to all the rest
> method?
> > >
> > > Thank you.
> > >
> > >
> > >     On Tuesday, June 27, 2017 9:07 PM, Marcel Barbosa Pinto <
> > marcel.po...@gmail.com> wrote:
> > >
> > >
> > >  Hi,
> > >
> > > I think you could use this:
> > >
> > > getCurrentWebResponse().addHeader("Access-Control-Allow-Origin", "
> > http://localhost:8080";);
> > >
> > >
> > > On Tue, Jun 27, 2017 at 8:24 AM, Noven <noven_...@yahoo.com.invalid>
> > wrote:
> > >
> > > Hello,
> > > Does anyone here face an issue about CORS when consuming wicket rest
> > from javascript ajax?
> > >
> > > The sample errors are :
> > >
> > > Cross-Origin Request Blocked: The Same Origin Policy disallows reading
> > the remote resource at http://localhost:8080/api/ statust. (Reason: CORS
> > header ‘Access-Control-Allow-Origin’ missing).
> > > I am looking for solution to set the ‘Access-Control-Allow-Origin’
> value
> > in Wicket Rest.
> > >
> > > In SpringBoot REST, we can set the value like this :
> > >
> > >   @CrossOrigin(origins = "http://localhost:8080";)
> > >     @GetMapping("/greeting")
> > >     public Greeting greeting(@RequestParam( required=false,
> > defaultValue="World") String name) {
> > >         return new Greeting(counter. incrementAndGet(),
> > String.format(template, name));
> > >     }
> > >
> > > I really need this solution, since I have to do it in Wicket way.
> > >
> > > Thank you.
> > >
> > >
> > >
> > >
> > >
> > > --
> > >
> > > Marcel Barbosa Pinto
> > > 55 11 98255 8288
> > >
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>

Reply via email to