I'd suggest seeing a stacktrace to find out what phase this is being invoked in. RequestContext.isPostback() doesn't work until the end of Restore View phase, and I suspect your code is being called during Restore View.
-- Adam On 6/4/07, Francisco Passos <[EMAIL PROTECTED]> wrote:
Actually yes, I was using JSF 1.2 but since my application server (Weblogic 9.2) doesn't support J2EE 5, I decided to switch to 1.1 for full compatibility. The full scenario is this: I have request-scoped beans that need to be initialized (load properties from database). I'm using t:saveState to keep the values between subsequent requests. In order for my init method to be called for these beans, I created an abstract bean (which my concrete beans extend) with the following: protected boolean initialized = false; public abstract void init() throws Exception; public final void setInitialization(String value) { if (!isPostback()) { initialize(); } } public final void initialize() { if (!initialized) { try { init(); initialized = true; } catch (Exception e) { ... } } } protected final boolean isPostback() { RequestContext context = RequestContext.getCurrentInstance(); if (context == null) { return false; } return context.isPostback(); } The entry point is the setInitialization method. To ensure it gets called, I created a managed-property in each of my beans (in faces-config.xml). I don't know which phase it gets called in, but a while ago it worked extremely well and in conjunction with Tomahawk's saveState, for subsequent requests only the first would be initialized, whereas now, all of them are :( Should I switch back to 1.2? Is there anything I can do to use 1.2 in a non-J2EE compliant app-server with any degree of confidence? Thank you, Francisco On 6/1/07, Adam Winer <[EMAIL PROTECTED]> wrote: > > I don't think there've been any changes in Trinidad. Have > you changed the version of JSF you're using? At > what point in the JSF lifecycle are you calling > isPostback()? > > -- Adam > > > On 6/1/07, Francisco Passos < [EMAIL PROTECTED]> wrote: > > Good afternoon. > > > > Have there been any changes to the underlying mechanism of > > RequestContext.isPostback since version 1.0.0-incubating? > > > > I've noticed that returning null after executing an action triggered > by a > > button, for instance, is no longer considered a postback. Is this true > and > > if true, is it intended? > > > > By the way, having a <tr:commandButton text="simulate postback" /> is > no > > longer detected as one :S and it doesn't even define the action... > > > > Thank you, > > Francisco > > >