You are making the same mistake I see so many new web programmers make, you are getting confused about which pieces in the client-server system do what, and when.

Relax, and take a deep breath and forget what you think you know. Let's look at this situation logically:

Given the above facts, lets think about what happens when you enter a URL into your browser that points to a frameset containing some text and pictures.

  1. 1. You tell the browser to go to http://example.com/frameset.html
  2. Your browser requests the /frameset.html document from the example.com server.
  3. The server does whatever magic it does and spits out some http headers and some HTML.
  4. Your browser reads the HTML file and presents it to you. In this case you've got a frameset document that looks something like:
    <HTML> <frameset rows=80%,> <frameset> <Frame src="/frame1.html"> </frameset> <frameset> <Frame src="/content/frame2.html"> </frameset> </frameset> </HTML>
    The browser draws the empty frames (or at least prepares to) and then requests the documents specified in the frame tags: /frame1.html and /content/frame2.html.
  5. The server processes each document request and returns headers plus HTML files to the browser.
  6. The browser reads the html files and stuffs them into the appropriate frames for display.

In your case you are going to be using Mason to the magic URL to HTML transformation on the server side. So let's see what your components will generate: my_file.html

<HTML> <head><title>My File</title></head> <body><H1>This is my file.</H1></body> </HTML>
footer.html
<hr> <p>This is my site. This site is mine. Ehem. I made it and it is mine +, this site that is.</p>
autohandler
<HTML> <Frameset rows="80%,20%"> <Frameset> <Frame src="<% $m->call_next(%args) %>"> </Frameset> <Frameset> <Frame src="footer.html"> </Frameset> </Frameset> </HTML>

If you request my_file.html you will get:

<HTML> <Frameset rows="80%,20%"> <Frameset> <Frame src="<HTML> <head><title>My File</title></head> <body><H1>This is my file.</H1></body> </HTML>"> </Frameset> <Frameset> <Frame src="footer.html"> </Frameset> </Frameset> </HTML>
Which will cause your browser to ask for footer.html. footer.html will come back as:
<HTML> <Frameset rows="80%,20%"> <Frameset> <Frame src="<hr> <p>This is my site. This site is mine. Ehem. I made it and it is mine +, this site that is.</p>"> </Frameset> <Frameset> <Frame src="footer.html"> </Frameset> </Frameset> </HTML>
Which will in turn request footer.html again and you get an infinite number of broken frames. Not quite what you were looking for, I think.

Mason is a great way to avoid the need to use frames. Consider this autohandler and example components. Here's how the pieces should be laid out:

/          <-- This is the mason component root.
|- html/   <-- This is Apache's document root.
|  |- autohandler
|  |- frame.html
|  \- index.html
\- cmp/
   \- footer.mas
 

footer.mas can be the exact same as the footer above. I won't repeat that here. Let's look at index.html:

<h1>My Content</h1> <p>I am content content.</p> <%attr> title => 'Content' </%attr>
Now for the autohandler:
<HTML> <head><title>Content</title></head> <body> <% $m->call_next %> <& /cmp/footer.mas &> </table></body> </HTML>

A request for main.html will get html that looks like:

<HTML> <head><title><% $m->comp->attr('title') %></title></head> <body> <h1>My Content</h1> <p>I am content content.</p> <hr> <p>This is my site. This site is mine. Ehem. I made it and it is mine +, this sit +e that is.</p></td></tr> </body> </HTML>

If you must use a frameset, think about it some more, you probably don't. If you still must, then you need to make sure that your autohandler does not perform content wrapping on your frames file. Here's what that looks like:

<HTML> <Frameset rows="80%,20%"> <Frameset> <Frame src="/somedoc.html"> </Frameset> <Frameset> <Frame src="/somefooter.html"> </Frameset> </Frameset> </HTML> <%flags> interit => undef # Or you could use a special frames autohandler ins +tead of the normal one </%flags>

Remember that the documents called up by the frames will use mason's content wrapping and will be processed through any autohandlers that might apply.

Check out the Mason book that just came out. It is quite good. The online docs are also excellent. As a bonus, the folks on the mailing list are quite helpful, too. You can find out about all this stuff at MasonHQ.

PS, I haven't tested any of this code, I just wrote it off the top of my head, so you'll want to make sure I haven't mixed anything up. For example, I tend to use methods instead of attributes to handle things like the page title in the autohandler, but in this case (read the manual to see why) attribs are more than sufficient, so I may have goofed up the semantics for calling them and the way they behave in respect to inheritance. Read the developers manual, read it six or seven times. I had to before I really got some of the concepts right.


TGI says moo


In reply to Re: HTML::Mason and Frames by TGI
in thread HTML::Mason and Frames by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.