hi,
could you post your solution? i'm struggling with a similar problem.

thx

On Tue, 06 May 2008 18:54:42 +0200, Guy Bashan <[EMAIL PROTECTED]> wrote:

Hi Simon,

I was trying Andrew's "on-load" phase listener and it seems to be working
fine.

Thanks.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 06, 2008 2:30 PM
To: MyFaces Discussion
Subject: Re: Postback

Where are you calling getRenderKit from? You don't show it anywhere in
this piece of code.

It might not work when called from a bean constructor, because that is
being implicitly called when processing the component bindings.
Component bindings are initialized very early in a request cycle, and I
would guess that at that time no renderKit has yet been selected to
handle this request.

The renderKit might be the html renderkit, the xhtml renderkit, the pdf
render kit, etc. And that is specified (in JSF1.2) as a property of the
UIViewRoot - which only exists *after* the restore-view process has
completed. But bindings are processed during restore-view.

Solution: don't call it from a backing bean constructor.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Yes
Q: Is top-posting bad


Guy Bashan schrieb:
I am currently using 1.2.3.

It seems like there may be a problem when using hidden field binding and
trying to get postback indication.
Example code:
-------------
<html>
<head><title>Simple jsp page</title></head>
<body>
<f:view>
  <h:form>
    <h:inputHidden value="#{testBean.xx}"
binding="#{testBean.htmlInputHidden}"/>
    <h:commandButton value="Ok" action="#{testBean.someAction}"  />
  </h:form>
</f:view>
</body>
</html>

Bean code:
----------
public class TestBean
{
  private String xx;

  public TestBean()
  {
    xx = "5";

    System.out.println(FacesUtil.isPostBack());
  }

  public String someAction()
  {
    return null;
  }

  public String getXx()
  {
    return xx;
  }

  public void setXx(String xx)
  {
    this.xx = xx;
  }

  private HtmlInputHidden htmlInputHidden;

  public HtmlInputHidden getHtmlInputHidden()
  {
    return htmlInputHidden;
  }

  public void setHtmlInputHidden(HtmlInputHidden htmlInputHidden)
  {
    this.htmlInputHidden = htmlInputHidden;
  }
}

Page loads ok. After pressing the "Ok" button, there is a null pointer
exception, because:
FacesUtil.getFacesContext().getRenderKit() returns "null".
When binding is removed, all works ok.

Guy.



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 06, 2008 12:01 PM
To: MyFaces Discussion
Subject: Re: Postback

Guy Bashan schrieb:

Hi,



Is this a legitimate way of checking postback request?



  public static boolean isPostBack()

  {

    return



FacesUtil.getFacesContext().getRenderKit().getResponseStateManager().isPostb
ack(getFacesContext());

  }



Yep, that's the correct public API as far as I know (btw, it is JSF1.2
or later).






Reply via email to