David G. Friedman wrote:
I'm getting lost in how to make a custom lifecycle (NOT a phase listener) after 
searching through the MyFaces v1.1.1
code.   I was thinking of changing the lifecycleImpl.java class to alter 
execute()'s restoreView() to try setting
different values between setViewId(String) and setViewRoot(String).  The more I 
look into things the more I'm confused.
My 3 big questions right now are:

1. Why can't I set the lifecycle class directly in the config file?  What is 
the point of having the factory class
instead of just setting (in JSF v1.1) the lifecycle implementation in the 
<application /> section of the faces config?

I don't know. It would seem to be sensible to me for the config file to allow:
  <lifecycle id="myLifecycle" class="example.MyLifecycle"/>
or some-such. However it doesn't appear to.

You could write a simple servlet with just an initialisation method, which runs before the FacesServlet init, and creates/registers your own lifecycle object with the standard factory. Of course you'll need to configure the FacesServlet to use the id for your custom Lifecycle object.

Or just write a custom LifecycleFactory. The class is pretty simple.


2. Why is there a webapp init variable for the lifecycleFactory when stuff only gets 
added as the string "DEFAULT"?  Is
this so you can put he MyFaces jars in a central location then each webapp's 
listener can add it's own lifecycle factory
under it's own key?  That way /appone can use one lifecycleFactory different 
from /apptwo so they do different things in
different steps but use the same generic myfaces jar/classes?  I understand 
this is in the spec for JSF v1.2 for that
very purpose plus additionally letting different servlet mappings in the same 
webapp set which lifecycle to use (i.e.
for mapping different JSF servlets for *.jsf, *.ajax, *.source, etc.) but 
MyFaces isn't there yet.  (Note: just found a
java/ibm developerworks page on patterns so the factory idea makes a little 
more sense I just wish I knew where I should
add my own factory.)

Sorry don't know.


3. Are there any examples for changing the lifecycle (not adding 
PhaseListeners) or lifecycleFactory because I'm not
finding them in the MyFaces codebase (not on the keywords I'm using to search 
in via Eclipse 3.1.1) or with the keywords
I've been trying in various search engines.

I doubt you'll find any examples. Changing the lifecycle is really a pretty unusual thing to do.


Regards,

Simon

Reply via email to