Not sure about a way with portlets, but this should work with a servlet
environment:

"POST".equals(((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getMethod())

Note that all command* components post, so this will not tell you if the
page is new or not.

Another way is to store an attribute in the UIViewRoot during rendering. If
it is present, it is the 2nd (or more) time that the page has been renderer,
and if it is not set then it is the first.

FacesContext.getCurrentInstance().getViewRoot().getAttributes().get("myproperty")
!= null
...
FacesContext.getCurrentInstance().getViewRoot().getAttributes().put("myproperty",
true)

-Andrew

On Jan 8, 2008 9:57 AM, Zheng, Xiahong <[EMAIL PROTECTED]> wrote:

> Hi all,
>
> I have a form that is wired with a backing bean. On the initial loading,
> I need to load the backing properties from the DB to be displayed on the
> page, then persist into the DB on submission after user edited the form.
>
> I only want to preload the bean from DB on the initial form loading not
> on the form submission. Is there a way for the backing bean to know
> whether it is created as a result of initial request or a form submit so
> it can act accordingly.
>
> Thanks,
> Xiaohong
>

Reply via email to