Where to override #prefs in mainResponder

Brian V Hughes brianvh at Dartmouth.EDU
Fri Nov 16 13:53:57 PST 2001


--On 11/16/01, Bill Humphries wrote:
>I'm in the process of moving an existing system from the web 
>scripting framework to mainResponder.

Good choice. mainResponder is far better than the old WSF way of 
dynamic server from Frontier, IMO. In fact, you can really consider 
mR to be Frontier's web application server. At least, that's how I 
describe it to Java people when they ask me how Frontier works. ;->

>In the previous framework, an elaborate responder looked at the 
>requested URL and 'did the right thing' with it where the right 
>thing might be choosing the renderer to use.
>
>What I'd like to do in mainResponder is use searchArgs to override 
>values in #prefs when needed.
>Now, from my understanding of the website and mainResponder 
>frameworks, it would appear that the place to do that would be in 
>#filters.pageFilter.
>
>So I would think the obvious code for that would be:
>
>if string.URLdecode(adrPageTable^.searchArgs) == "preview"
>{
>	adrPageTable^.renderOutlineWith = "previewRenderer"
>}

One minor thing, HTTP search arguments are normally presented as 
"name=value" pairs separated by &'s. If I were doing something like 
what you are trying here, I would be using the HTTP path argument, 
which is everything after a $, not a ?. This, however, has no bearing 
on the functionality of your script code. Just a stylistic convention.

>However, that's not working, and the outline is still rendered using 
>the renderer to which   #prefs.renderOutlineWith points.

Correct. The pageFilter is called after the page has been rendered. 
You need to set that kind of directive in the firstFilter. To be 
honest, the only time I put code in the pageFilter is when I want to 
do stuff relevant to the template, not the object being rendered.

The filters should actually read: before rendering (firstFilter), 
after rendering/before #template (pageFilter), after #template 
(finalFilter).

>There's also a related question.
>
>According to Userland's documentation, outlineRenderers get a copy 
>of the outline without the page directives. If I want to display 
>those directives in a view, then it sounds as if I need to provide a 
>subsitute for bodytext in my template.

Not necessarily, although that is one way to go. All you really need 
to do is reference the directive, by name, as a macro: ie. 
{directiveName}. Place this either in the #template or the outline 
being rendered, and the value of the directive will show on the page 
when it's served back to the browser, or written to disk.

-Brian
-- 
Brian V. Hughes                          <http://www.dartmouth.edu/~comm/>
Webmaster                                Dartmouth College Computing Services
Webmaster Group                          Communications Services




More information about the Frontier-Users mailing list