On 8/28/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: > Hi all (but specifically Craig perhaps)... > > I'm putting together my first Shale app, and so far I have much of the > basics down, although it winds up being basically just plain JSF at this > point. > > I'm coming up against one thing that I'd like to ask bere... Rick > Reumann was very helpful in providing an answer, but I can't help but > think there must be another... > > The problem, which IIRC was discussed a bit here already, is this > situation... imagine I have the typical index.jsp page that is the > default welcome page in web.xml. This page is nothing but a forward to > summary.faces, which is to be a page to display a list of items a user > will then select from. > > In Struts, you would be forwarding to some Action that presumably pulls > the data from a database and puts it in request scope to be rendered on > summary.jsp. In JSP, it appears I simply wind up on summary.jsp, > without the opportunity to gather that data. > > Now, with Shale, thanks to Rick, I understand you can have a backing > bean extending AbstracyViewController with a prerender() method to do > this, and without even having to explicitly tell anything to use that > backing bean or method. Very nice. > > But, how would one accomplish this with plain JSF? *IS* there a way to > do this, or do I need to approach the problem with a different mindset > perhaps? None of the myriad examples I've looked at seems to mention > this situation, but it is way too common to not be addressed in some > way. Thanks!
Well, Shale itself does it with pure JSF, so you certainly can :-). The secret would be to implement a custom PhaseListener and a custom ViewHandler that lets you detect all of the relevant times to do the event callbacks: * When a view is first created (ViewManger.createView) or restored (ViewManager.restoreView), so you can call init(). * When "Restore View" phase has just been completed, and actually created a view, so you can call preprocess(). * When you are entering "Render Response" phase, so you can call prerender() -- but take care to do this only on the view that will actually be rendered * After "Render Response" phase has been completed, or after any other phase when the "responseComplete" flag has been set, so you can call destroy() on *all* view controllers that you called init() for. Bottom line -- yes, you can certainly do it all with raw JSF APIs, but who in their right mind would want to? Let Shale do it. (This is analogous to writing your own MVC framework instead of using an existing one ... yes, you can do that on top of the servlet API, but why?) As to why JSF didn't go here (yet), there are two important things you need to remember: * It was a 1.0 spec, and we had to cut off adding functionality at some point or we'd all still be waiting. The theme for 1.0 was getting the component APIs right, and we did that. * Adding application level functionality is the sort of thing that makes perfect sense to consider for a JSF 2.0 (along with better support for Ajax, client side validation, and a whole host of other things). For this purpose, Shale serves as a useful experimentation ground on what kinds of things *should* be standardized, and how they might work. So, in answer to "how would one accomplish this with plain JSF?, my answer is "you can do it if you're a masochist ... everyone else should just use Shale :-). Craig > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]