Solved

frames in perl

Posted on 1998-07-31
7
189 Views
Last Modified: 2010-03-05
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
Comment
Question by:generous
  • 4
  • 2
7 Comments
 
LVL 6

Accepted Solution

by:
alamo earned 50 total points
ID: 1208959
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
 
LVL 5

Expert Comment

by:b2pi
ID: 1208960
alamo, are you referring to style sheets?
(Note, I'm not even close to sure how those work...)
0
 
LVL 6

Expert Comment

by:alamo
ID: 1208961
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:generous
ID: 1208962
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
 
LVL 6

Expert Comment

by:alamo
ID: 1208963
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
 

Author Comment

by:generous
ID: 1208964
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
 
LVL 6

Expert Comment

by:alamo
ID: 1208965
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now