>
> I cheated a bit here and extended the Home service so that it checks for a
> Visit, if there is one - it'll load a page I have called LoggedInHome
> instead of Home. I also extended the Page service so that if it ever sees
a
> request for a page called Home, it deferes the request to the Home
service.
>
I wouldn't call that cheating, I'd call that cannily using the framework in
the way it was intented.
The whole point of having a home service was to enable this kind of hook.
> Geoff.
>
> public class ORCAHomeService extends HomeService {
>
> public boolean service(IEngineServiceView engine, IRequestCycle cycle,
> ResponseOutputStream output)
> throws RequestCycleException, ServletException, IOException {
> Visit visit = (Visit) engine.getVisit();
> boolean isLoggedIn = visit != null && visit.getLoggedInUsername() !=
> null;
> IPage home;
> if (isLoggedIn) {
> home = cycle.getPage("LoggedInHome");
> } else {
> home = cycle.getPage(IEngine.HOME_PAGE);
> }
> home.validate(cycle);
> // If it validates, then render it.
> cycle.setPage(home);
> if (isLoggedIn) {
> engine.renderResponse(cycle, output);
> } else {
> ((ORCAEngine) engine).renderHomePageResponse(cycle, output);
> }
> return true;
> }
> }
>
> public class ORCAPageService extends PageService {
>
> public boolean service(IEngineServiceView engine, IRequestCycle cycle,
> ResponseOutputStream output)
> throws RequestCycleException, ServletException, IOException {
>
> RequestContext context = cycle.getRequestContext();
> String[] serviceContext = getServiceContext(context);
> if (serviceContext == null || serviceContext.length != 1)
> throw new ApplicationRuntimeException(Tapestry.getString(
> "service-single-parameter", IEngineService.PAGE_SERVICE));
> String pageName = serviceContext[0];
> RequestContext rcontext = cycle.getRequestContext();
> HttpServletResponse response = rcontext.getResponse();
>
> if ("Home".equals(pageName) || "LoggedInHome".equals(pageName)) {
> IEngineService hservice =
> engine.getService(AbstractService.HOME_SERVICE);
> reutrn hservice.service(engine, cycle, output);
> }
> IPage page = cycle.getPage(pageName);
> page.validate(cycle);
> cycle.setPage(page);
> engine.renderResponse(cycle, output);
> return true;
> }
>
> }
>
>
> Geoffrey Longman
> Intelligent Works Inc.
>
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
> _______________________________________________
> Tapestry-developer mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/tapestry-developer
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer