File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes What technique to use in place of a pop up? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "What technique to use in place of a pop up?" Watch "What technique to use in place of a pop up?" New topic
Author

What technique to use in place of a pop up?

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
I have heard that it is considered bad to use javascript pop ups in struts/jsp code due to pop up blockers.
I am not sure what a good alternative would be. I have a struts app running under Tomcat 5. Someone recommended using hidden div's, and then when the user clicks on an icon, the div becomes visible, but this seems like a lot of unecessary code in the jsp since you never know what will be clicked on (I have about 30 rows of data, and each row would need its own div if I did it this way).
Any recomendations?
Thanks,
Kim
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

Since the JSP is generating the HTML for those rows, it should be able to generate a div for each of them. It's just a matter of programming, isn't it? Doesn't matter if there's one row or 30 or 150.
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Yes, but I was under the impression that a jsp page that gets too big may have trouble compiling. So, I thought having one pop up that all of the rows could use would keep the jsp much smaller than having one div per row.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've used popup windows in programming web applications, and have found that as long as your popup window is triggered by some action of the user such as clicking on a link, most popup blockers won't interfere. They will interfere if there is some sort of automatic process that opens up a popup when the page is loaded or in some other way that was not directly initiated by the user.

I've also used the hidden div technique, and that's a good option as well. If you want to use the same hidden div for all your popups, you can do that as well. Just use JavaScript to dynamically change the size, location, and content of the div.

However, I wouldn't worry about hitting the upper size limit on your JSP just based on the hidden divs unless your page is otherwise very large or complex.
[ September 05, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Thanks so much for everyone's input. I would like to stick with the div method since I have it working, I just keep worrying that at some point I am going to tip the scales with this big JSP file.

It is definately the most complex jsp I have ever had to write. The file kim.jsp compiles to kim_jsp.java 505KB, and kim_jsp.class 236 KB. This seems very big to me but the page does render fine and behave fine, so guess it is OK. I thought I had read someplace that a compiled jsp shouldn't exceed 64 KB. Have you heard this or do I have the number wrong ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

It's definitely true that there's an upper limit to the size of a Java class (which is what you end up with after you compile your JSP). I'm not sure of the nature of that limit.

However if you have a loop in your JSP, that just compiles to a loop in the Java class. It doesn't matter how many times the loop is executed when you run the JSP. (If that was a factor in your concern.)

But complexity is a problem in itself, even if it does compile successfully. JSPs are hard to read at the best of times. It's not easy to break up a JSP into modules, but could you for example write a custom tag to do things that appear repetitively in your JSP code? I don't believe that would reduce the size of the compiled class, but it would reduce the complexity of the code.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Another aspect of size is how large the generated HTML page is. Particularly if you have any users on dialup. Even if it is a loop in the JSP, it gets downloaded one character at a time.

I echo the above in that sometimes a pop-up makes sense. I haven't had any issues with launching pop-ups in response to the user clicking a link (tested through IE 7.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What technique to use in place of a pop up?
 
Similar Threads
Need help selecting a value from a list with multiple ids that are the same
Assignment 1.1: literals
Too many window.open calls cause problem?
pop up in jsp
Creating a masked popup in JavaScript