Managed beans are created when they are referenced. Any time the EL
VariableResolver is asked for a variable like "#{foo}", and there is no
such variable then it checks the managed bean config info. If foo is
declared there, then an instance of the specified type is created and
stored in the specified scope under that name.
As EL expressions will only ever be evaluated after the "restore view"
phase is complete, managed beans can always assume the current view is
valid.
Regards,
Simon
Andrew Robinson wrote:
To be honest, I have not covered the part of the specification that
talks about bean initialization time. I would not be surprised if it
depends on the bean's scope. In general, I always feel that it is a
good decision to not put business code in a constructor. However,
since JSF may set managed properties, that brings up another question.
In this case, with a request-scoped variable, I would guess that the
bean would be created in the render response phase, but as I said, I
don't know (although I am curious).
Does anyone know?
On 12/5/05, Julián García <[EMAIL PROTECTED]> wrote:
Is there any approach to access the url when the bean is initializing?
Andrew Robinson wrote:
It is set right after the view is created. This differs based on if
there is queued action. If there is an action, the new view is created
during the application invoke phase. If the view is new (new request
or a redirect), then the view is created earlier in the lifecycle (I
can't remember for sure, but I think I remember it being during the
restore view phase).
Once the view is created, getViewRoot() will not return null. Get view
ID on the view root should always return a value to my knowledge
(unless you have an odd view handler). The new view ID is always
available at the render response phase.
On 12/5/05, Julián García <[EMAIL PROTECTED]> wrote:
Andrew Robinson wrote:
Are you looking for:
FacesContext.getCurrentInstance().getViewRoot().getViewId()?
When is this id set....I am trying to access this method just after
setting the values configured in my config xml, and it is always showing
null.....
Thanks-.
On 11/28/05, Julián García <[EMAIL PROTECTED]> wrote:
How can I access the url that is being currently displayed for the user
using the FacesContext? I need this to do a custom filter for
authorization using acegi.....Any experiences to share with that?
Thanks a lot.
Julian