myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg Füchsle <giofy...@googlemail.com>
Subject Re: Distinguish if parameters are sent by POST or GET
Date Wed, 18 Mar 2015 14:46:03 GMT
Hallo Max,

Thanks for replying. My attempt did not work:

I want distinguish GET and POST inside a PhaseListener.

In the PhaseListener I receive the FacesContext from the PhaseEvent. I also
tried to receive the FacesContext from static:

    public void beforePhase(PhaseEvent event)
    {
       if (event.getPhaseId() == PhaseId.RESTORE_VIEW)
        {

        ExternalContext extCtx =
event.getFacesContext().getExternalContext();

        boolean post1 = FacesContext.getCurrentInstance().isPostback();

        boolean post2 = event.getFacesContext().isPostback();

        logger.info("post1: " + post1 + "   - post2: " + post2);



Called With Get:
http://localhost:8080/TextTool/pages/start/texttool.jsf?BEDIENER=Gio
15:41:04,609 INFO  [jsf.StartPhaseListener] (default task-60)
*post1: false   - post2: false*

Called with POST from a form:
15:42:09,045 INFO  [jsf.StartPhaseListener] (default task-69) *post1:
false   - post2: false*


What do I do wrong?

Gio

2015-03-18 15:18 GMT+01:00 Max Starets <max.starets@oracle.com>:

> Georg,
>
> Have you tried isPostback() on FacesContext? If you are not including view
> state as one of the parameters, it will return false for GET requests.
>
> Max
>
>
> On 3/18/2015 9:19 AM, Georg Füchsle wrote:
>
>> Hallo!
>>
>> Is it possible to see if a parameter read in my jsf-app was sent by post
>> or
>> by get?
>>
>> My webapp should be startet calling a starturl with some post parameters.
>> I
>> would like to forebid the use of get parameters. is it possible?
>>
>> thanks
>>
>> Gio
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message