Matthew Lai
Matthew Lai

Reputation: 217

How to check if a request is GET or POST in Wicket?

Currently I use following way to check if a request is GET or POST in Wicket WebPage:

public DummyPage(PageParameters pageParameters) {
    super(pageParameters);

    final WebRequest wr = (WebRequest) getRequest();
    final HttpServletRequest hsr = wr.getHttpServletRequest();
    if (hsr.getMethod().equalsIgnoreCase("post")) {
    }
}     

Is there better way to do so?

Upvotes: 1

Views: 3202

Answers (1)

Tomasz Dziurko
Tomasz Dziurko

Reputation: 1688

There is no better way as far as I know. The only way to get access to HttpServletRequest is just the way you do it. The only improvement you could do is to invert order of equals parameters. You should compare always-not-null value (as contants) with almost-always null value :)

Upvotes: 1

Related Questions