Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 87301 invoked from network); 8 Feb 2007 22:30:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Feb 2007 22:30:50 -0000 Received: (qmail 66308 invoked by uid 500); 8 Feb 2007 22:30:47 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 66240 invoked by uid 500); 8 Feb 2007 22:30:47 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 66229 invoked by uid 99); 8 Feb 2007 22:30:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Feb 2007 14:30:47 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [216.227.215.170] (HELO chiron.lunarpages.com) (216.227.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Feb 2007 14:30:37 -0800 Received: from zammet2 by chiron.lunarpages.com with local (Exim 4.63) (envelope-from ) id 1HFHmT-0007QC-35; Thu, 08 Feb 2007 14:30:17 -0800 Received: from 170.201.180.136 ([170.201.180.136]) (SquirrelMail authenticated user fzlists@omnytex.com) by webmail.chiron.lunarpages.com with HTTP; Thu, 8 Feb 2007 17:30:17 -0500 (EST) Message-ID: <4731.170.201.180.136.1170973817.squirrel@webmail.chiron.lunarpages.com> In-Reply-To: References: <45CB387A.50105@wfscorp.com> <45079.170.201.180.136.1170948609.squirrel@webmail.chiron.lunarpages.com> Date: Thu, 8 Feb 2007 17:30:17 -0500 (EST) Subject: RE: Struts action call in a JS method returns blank page From: "Frank W. Zammetti" To: "Struts Users Mailing List" Cc: "Struts Users Mailing List" User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - chiron.lunarpages.com X-AntiAbuse: Original Domain - struts.apache.org X-AntiAbuse: Originator/Caller UID/GID - [32746 1232] / [47 12] X-AntiAbuse: Sender Address Domain - omnytex.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked by ClamAV on apache.org On Thu, February 8, 2007 4:46 pm, Christopher Loschen wrote: > Thanks Frank -- I've been reading your posts on JWP with great interest > for quite a while, and I'll bet your book is another good resource. *Of course* it is :) (what, you expected a different answer?!?) FYI, my new book, "Practical JavaScript, DOM Scripting and Ajax Projects", is scheduled to hit shelves in mid-April (never pass up the chance for a little shameless self-promotion I've been told!) > The current project (or at least this piece of it) has to be finished by > tomorrow, so I may not be able to introduce Ajax just yet. However, I'm > definitely interested in learning more about it, and will no doubt use > it more as I learn more. Sounds good. I'd say it's not generally something you want to jump into on a tight deadline if you have't done as much client-side development... many good Java developers have a bit of a rough time early on when trying to do more client-side stuff... seems like it should be simpler most say, but it isn't usually :) > Meanwhile, I'm looking at a possibly related problem. We've got > checkboxes on multiple pages and a JS function which keeps track of > which boxes are checked on which page so that we can go from page to > page and retain the boxes checked on other pages. That works by putting > the checkbox ids into the URL for the page. It's working correctly, more > or less, but now I find that when I actually am ready to use the array > of checkboxes, I'm getting only the ones on the current page, not the > rest. My Java method is getting the correct request parameters, but it > always returns null. Perhaps that's because the request parameters are > associated with one action (which displays the appropriate page of the > list) and my action class is associated with a different action (to > store the checkbox values and process the result)? If that's right, I > guess I need to get those values into my action too. Does that sound > like a reasonable guess? Hmm... I'm not sure I followed the whole thing, but it sure sounds like your dropping the params somewhere... my guess is that you aren't replicating the whole query string with each request, which you'd need to do. However, I'd definitely say you probably want to be storing that info in session in the first place... then it's relatively easy to pass it along with every single request for all pages that need it. > Chris > > -----Original Message----- > From: Frank W. Zammetti [mailto:fzlists@omnytex.com] > Sent: Thursday, February 08, 2007 10:30 AM > To: Struts Users Mailing List > Cc: Struts Users Mailing List > Subject: Re: Struts action call in a JS method returns blank page > > Theres a ton of choice on which AJAX library to use, many of them very > good. However, since your working in Java specifically, and since you > say > you are not all that familiar with JS, you may prefer a solution that > will > (in most cases) require ZERO Javascript coding, and such a thing exists: > > http://javawebparts.sourceforge.net/javadocs/javawebparts/ajaxparts/tagl > ib/package-summary.html > > This is the AjaxParts Taglib (APT), which is a part of Java Web Parts > (JWP): > > http://javawebparts.sourceforge.net > > With this, let's say you want to update a specific
in response to > a > button being clicked on a page with some data returned by the server > without refreshing the page, in your JSP you would have: > >
Response will go here
> ajaxRef="ajaxFunctions/button1" /> > > > That's it, no JavaScript at all! The other piece to the puzzle is an > XML > file like so: > > > > > > > > > > myDiv > > > > > > > The XML file maps via the ajaxRef values to the ajaxRef in the > tag, and it defines what's going to happen in response to > some event (onClick in this case), which in this case is simply an AJAX > request to /myURL with no data passed, and then what happens when the > response comes back, which is it will be inserted into myDiv via > innerHTML. > > There's a whole bunch of request and response handlers available out of > the box which tend to cover most needs, things like submitting forms, > executing some returned Javascript, sending XML automatically > constructed > from form data, transforming returned XML via XLT, and so on. You also > have the ability to write your own handlers (just plain Javascript) if > you > need something that isn't covered. > > hth, > Frank > > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > AIM/Yahoo: fzammetti > MSN: fzammetti@hotmail.com > Author of "Practical Ajax Projects With Java Technology" > (2006, Apress, ISBN 1-59059-695-1) > Java Web Parts - http://javawebparts.sourceforge.net > Supplying the wheel, so you don't have to reinvent it! > > On Thu, February 8, 2007 9:49 am, Musachy Barroso wrote: >> Check Prototype out, here is a good tutorial: >> http://www.sergiopereira.com/articles/prototype.js.html, basically > what >> you need is something like: >> >> |**var myAjax = new Ajax.Request( >> url, >> { >> method: 'get', >> parameters: Form.serialize("formid"), >> onComplete: function() { >> //do something here, or not :) >> } >> });**| >> >> regards >> musachy >> >> Christopher Loschen wrote: >>> I'm not all that familiar with JS, to be honest, and I've never had > the >>> chance to use Ajax (but want to learn). What I have now is working, > but >>> I'd be happy to learn how to do it without refreshing the page -- > that >>> does seem like a more elegant solution to me. What do you suggest? We > do >>> use JS for our app, but no JS framework as such as far as I can tell. >>> >>> Chris >>> >>> -----Original Message----- >>> From: Musachy Barroso [mailto:musachy@gmail.com] >>> Sent: Thursday, February 08, 2007 8:03 AM >>> To: Struts Users Mailing List >>> Subject: Re: Struts action call in a JS method returns blank page >>> >>> Like I said before you can use Ajax to submit the form, and the page >>> won't >>> refresh, how to do it depends on what JS framework you are using, if >>> any. >>> >>> regards >>> musachy >>> >>> On 2/8/07, Christopher Loschen wrote: >>> >>>> Yes, you're right that the form submit was causing the system to >>>> >>> forward >>> >>>> to whatever the action said, which in my case was the blank page. >>>> >>> You'll see >>> >>>> from the later emails in the thread yesterday that I solved that by >>>> forwarding to the action which populated the original page. >>>> >>>> I need the form.submit because I need to get the checked boxes from >>>> >>> the >>> >>>> form and I need to call the action specified in the action attribute >>>> >>> on that >>> >>>> form in order to put those checkbox values into the request in the >>>> >>> form that >>> >>>> my downstream code needs. >>>> >>>> Submitting the form is the only way I know to get the form values > the >>>> >>> user >>> >>>> submits from the HTML page to my Java code -- are you saying that I >>>> >>> have >>> >>>> other alternatives? >>>> >>>> Chris >>>> >>>> ________________________________ >>>> >>>> From: Yee Kai Lai [mailto:yeekai.lai@hotmail.com] >>>> Sent: Thu 2/8/2007 12:24 AM >>>> To: user@struts.apache.org >>>> Subject: RE: Struts action call in a JS method returns blank page >>>> >>>> >>>> >>>> >>>> It returns a blank page might be due to >>>> >>>> form.submit(); in your JS. >>>> >>>> I think if you have a form named >>>> >>> 'service.device.selected-devices-form' >>> >>>> then >>>> it will never be null hence it will always submit. >>>> >>>> May you could enlightened why u need a form.submit() ? >>>> >>>> >>>> >>>>> From: "Christopher Loschen" >>>>> Reply-To: "Struts Users Mailing List" >>>>> To: >>>>> Subject: Struts action call in a JS method returns blank page >>>>> Date: Wed, 7 Feb 2007 14:14:35 -0500 >>>>> >>>>> Hi all, >>>>> >>>>> >>>>> >>>>> I'm honestly unsure if I'm having a problem with Struts (sadly, > 1.1) >>>>> >>> or >>> >>>>> with Javascript, or something else. But my best guess is it's a >>>>> >>> Struts >>> >>>>> issue, and anyway, there are a lot of very knowledgeable people on >>>>> >>> both >>> >>>>> of those technologies here, so I hope someone can help. Bottom > line: >>>>> >>> I'm >>> >>>>> getting the popup with the correct values, but my main page under > the >>>>> popup becomes blank. >>>>> >>>>> >>>>> >>>>> I'm adding some functionality to an existing application. The >>>>> functionality I'm adding takes the values from some checkboxes on >>>>> >>> page >>> >>>>> A, gets the corresponding devices from the checkbox values, and > saves >>>>> the resulting List into the request. Later down the stream, other >>>>> >>> code >>> >>>>> gets those values again and uses them as a list of devices on which >>>>> >>> to >>> >>>>> perform an action. Pretty straightforward. >>>>> >>>>> >>>>> >>>>> All of the actual navigation is happening via Javascript calls, >>>>> >>> starting >>> >>>>> with a link on page A, but outside the form where my checkboxes are >>>>> declared. That link fires a Javascript function which pops up a > small >>>>> window with a list of actions which have been defined. If the user >>>>> >>> then >>> >>>>> clicks on one of those actions, another Javascript function fires >>>>> >>> which >>> >>>>> pops up another window to confirm that the user wants to perform > the >>>>> selected action on the selected devices. >>>>> >>>>> >>>>> >>>>> I have inserted my added functionality into that second script. >>>>> Basically I need to submit the appropriate form on the page. I've >>>>> defined it with the correct action and I've got a mapping in my >>>>> struts-config.xml file: >>>>> >>>>> >>>>> >>>>> >>>> >>>>> name="service.device.selected-devices-form" >>>>> >>>>> type="com.xxx.webapp.common.CheckboxForm"/> >>>>> >>>>> ... >>>>> >>>>> >>>> >>>>> >>>>> type="com.xxx.webapp.service.list.StoreSelectedDevicesAction" >>>>> >>>>> name="service.device.selected-devices-form" /> >>>>> >>>>> >>>>> >>>>> The mapping doesn't have any action forwards defined because it >>>>> >>> doesn't >>> >>>>> actually need to go anywhere (though that might be part of my >>>>> >>> problem). >>> >>>>> The JS function looks like this: >>>>> >>>>> >>>>> >>>>> function popActionConfirm(url) { >>>>> >>>>> >>>>> >>>>> var form = > document.forms['service.device.selected-devices-form']; >>>>> >>>>> if (form!=null) form.submit(); >>>>> >>>>> >>>>> >>>>> var winl = (screen.width - 500) / 2; >>>>> >>>>> >>>>> >>>>> var wint = (screen.height - 350) / 2; >>>>> >>>>> >>>>> >>>>> winprops = >>>>> >>>> > 'height=250,width=375,top='+wint+',left='+winl+',scrollbars=0,resizable >>>> >>> = >>> >>>>> 0'; >>>>> >>>>> >>>>> >>>>> var child = window.open(url,"action_confirm", winprops); >>>>> >>>>> >>>>> >>>>> self.name="main_window"; >>>>> >>>>> >>>>> >>>>> } >>>>> >>>>> >>>>> >>>>> I added the first two lines of the JS method - it worked correctly >>>>> before I put those in (though of course it didn't have my added >>>>> functionality in place). The popup window does appear, and it has > the >>>>> correct values in it (that is, the devices which were selected). > But >>>>> >>> the >>> >>>>> main window goes blank where before it remained unchanged. When > I've >>>>> seen blank pages like this before, it meant there was a bad action >>>>> forward in the struts-config file, but I don't want the main page > to >>>>> change at all, so what I really want is for the main page to just >>>>> >>> stay >>> >>>>> in place as it was before the form was submitted. >>>>> >>>>> >>>>> >>>>> How do I go about doing that? Thanks! >>>>> >>>>> >>>>> >>>>> Chris Loschen >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> _________________________________________________________________ >>>> Receive MSN Hotmail alerts over SMS! >>>> http://en-asiasms.mobile.msn.com/ac.aspx?cid=1002 >>>> >>>> >>>> > --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >>>> For additional commands, e-mail: user-help@struts.apache.org >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> For additional commands, e-mail: user-help@struts.apache.org >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org