views:

22

answers:

1

I haven't ever before created custom components in JSF so I've noticed only now that methods like encodeBegin(), encodeEnd() etc accept FacesContext parameter.

FacesContext instance can usually be received with FacesContext.getCurrentInstance().

So, I wonder whether these methods have FacesContext parameter just for convenience or some different objects can be passed there (maybe from external resources..). If the latter is possible then could you give an example pls.

+2  A: 

They may happen to run in a different thread. FacesContext#getCurrentIsntance() can only for sure be returned from the thread which is executed by the HTTP request since it's stored as a ThreadLocal variable.

BalusC