I need to post the form though to get the value in the textbox. Isn't there a way in java to open a new browser window?
Ed. > From: Christian Bollmeyer <[EMAIL PROTECTED]> > Reply-To: A mailing list about Java Server Pages specification and reference > <[EMAIL PROTECTED]> > Date: Tue, 15 Jul 2003 21:48:57 +0200 > To: [EMAIL PROTECTED] > Subject: Re: Post a form and popup a window. > > Am Dienstag, 15. Juli 2003 20:12 schrieb Ed Ventura: >> That works fine, but I have 3 buttons and I only want to popup a new >> window on 1 of the buttons. All the others should just post the form >> normally. Any ideas? >> >> Thanks, >> Ed. >> > > What I usually do is something like this (note: I'm using Struts and > JSTL): I pass the command string to an Action that puts the search > results (or whatever, read: dynamic data ) in request scope and > forwards to a JSP (the View part) that just takes the results and > displays that. > > Though I usually tend to steer clear from JavaScript, for popup windows > I found it to be just necessary, so I put something like this into the > originating page: > > <script> > <!-- > function popup(targetURL) { > var props = > "scrollBars=yes,resizable=no,toolbar=no,menubar=no,location=no,directories=no, > width=400,height=400"; > var popup = window.open(targetURL, "Details", props); > popup.focus(); > //--> > } > </script> > > Then, I invoke the Action from that page by something like this: > > <a href="javascript:popup('<c:url value="/showDetails.do"><c:param > name="id"><c:out value="${current.id}"/></c:param></c:url>')"> > > The Action now talks to the model, does whatever is possible in Java and > adds the results to the request (sorry for the crappy formatting): > > public ActionForward execute(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) throws > IOException, ServletException { > int id = > ServletUtilities.stringToInt(request.getParameter(Constants.SC_PARAM_ID)); > CustomerBean cb = PersistenceFacade.getInstance().getUserDetails(id); > request.setAttribute(Constants.SC_CUSTOMER_BEAN_TOKEN, cb); > return mapping.findForward(Constants.SC_SUCCESS); > } > > In struts-config.xml, the mapping for the successful scenario finally > forwards to a page that displays the final results. This page just > takes the information passed and displays that in the popup window > created by the JavaScript part (using JSTL), which was invoked via the > link. Should not make any real difference here if you're using POST and > forms instead of mere links or don't make use of Struts at all; even if > you have to deal with several submit buttons, you may tell them apart > from each other because the one the user finally presses ends up as a > parameter (so better keep heed of the 'name' property) in your request. > If you need further help, just send me a mail :-) > > HTH, > > -- Chris (SCPJ2) > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > > Some relevant archives, FAQs and Forums on JSPs can be found at: > > http://java.sun.com/products/jsp > http://archives.java.sun.com/jsp-interest.html > http://forums.java.sun.com > http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com