[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

frames in perl

Hi,

How do get frames happening in perl?  I have a page that outputs info in a txt file into a table of cells, it is super long and i would like to retain the top headings for greater readabiltiy.  Can i do this somehow, if so how?

Once again, since i haven't a clue about how hard this is, if the answer looks complicated i will boost the pts.
Thanks.

0
generous
Asked:
generous
  • 4
  • 2
1 Solution
 
alamoCommented:
You can't do it with a single call to your script.

A frameset with 2 frames requires the browser to get 3 pages: the main page (frameset) and each of the frames. So what you need to do is have a way in your program to generate each of the 3 pages. (You could have the heading be a static page, not generated dynamically, but the page with the table needs to have its parameters passed to it which means the frameset needs those parameters.

There are two main ways to do this: a different script to generate each page, or a hidden field which tells the same script which page to generate.

Ok, that's how to do frames, but here's why frames aren't necessarily the best idea:

In many cases the table headings won't line up exactly with the table any more, if you separate them. This is because the browser dynamically sizes each column, using the information you give it as a guide but not as absolute dimensions. This won't look good. The solution to that is to re-print your column headings every so many rows in your table, every 25 rows for example.

The idea of one huge table has a big drawback anyway, if it's big enough: it will take a long time to load, and the browser usually won't show any of it until it's all loaded (so it knows how to size it). This means your users are looking at nothing for a while. The solution to this is to break up the table into many smaller tables, for example end the table after 25 rows and start a new one. This is only necessary with really large tables.

One more thought: I think there's a way to get a header which stays visible using pure HTML, without frames. This would only work on the latest browsers but might be the most elegant solution. I don't know the details or if it truly works - I suggest you ask this question over in the HTML section.

Hope this helps!
0
 
b2piCommented:
alamo, are you referring to style sheets?
(Note, I'm not even close to sure how those work...)
0
 
alamoCommented:
Yes, style sheets and layers. I have seen questions asked at EE over in the HTML section that make me think it could work, but I never followed the discussion enough to know myself how to do it.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
generousAuthor Commented:
Wow, what an answer!  Umm, only it does not spell it out for me.  How is this for a strategy.   The script writes the dynmaic info to a file (not completely sure how to do this), then it calls the frameset file (using location:). The thrid file is hard coded with the heading.

Could you provide me with the code to write to that file?  Is it simply
    open(tablefile,"bottom.html");
    print tablefile "<td><b>$currenttotal</b></td>\n";   #this being done for each bit of info
    close(tablefile);

Will this work?

Pls note, the issues you have raised about the table's loading time and apperence are occuring right now, but have been decided to be "liveable".
0
 
alamoCommented:
There's a possible problem there, it all depends on how your generate the information.

The problem arises in the fact that there is a single copy of bottom.html for everyone. That means if two people load the page at the same time, one may get the other's info. And more likely, if someone hits reload (or in some cases uses the Back button) they will get the latest copy of bottom.html, not the one they generated.

In some applications this is no problem, the script just generates a page with the latest info anyway, rather than a different page based on what the user asked for. If yours is like this, then what you propose will work. You need to open the file for output with
open(tablefile,">bottom.html");
so that you can write to it. You also need to print the entire html page, not just  the <td> ... </td> bits.

If however the page you generate is different for each user and each time its loaded, a much better approach is to not use Location: for the frameset but instead for your main script to print the frameset page itself in response to the original request, and make the bottom frame a link to another script (or the same script with an additional parameter). The second script would then dynamically generate the page, just like your current script. This only works for scripts loaded from a GET form or link, not a POST, so that the URL of the bottom frame can include all the info needed to generate the page. If it works for you though, you can avoid dealing with multiple temporary files.

Let me know which approach of the above you will take, and I can provide more info if needed.
0
 
generousAuthor Commented:
Hi,

I got the frames to work by writing the ouput to one of the three frame html files.  The issuse of multiple viewers of bottom.html is not a concern, just as you suggested, it is only a listing of current info.  However in the future i might make the files tmp and be erased upon clicking of a button, if privacy issues do arise.

But the location is not working.  Could it be b/c of it is below the print "content-type: text/html\n\n"; line.  I can never understand how that line effects so much of my code.  Where should the location line go?

Ps.  If you do not answer, Thanks Alamo I have learned alot from this attempt and your advice.
0
 
alamoCommented:
When you use Location it should be the only line you print  and should have \n\n at the end.

print "Location: http://whatever.com/etc\n\n";

You are telling the browser to go somewhere else - the place you send it will set its own Content-type and other headers.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now