Re: html:cancel usage
andy wix wrote the following on 9/14/2004 6:27 AM: I have tried all the other suggestions in every combination but can't get anything more elegant to work. This works but I'm not looking forward to the code review! Just one more reason that I really like calling the validation manually from my Actions. Forget about having validation called automagically then you don't have to worry about any of the hoops. Plus you have one consistent way to handle all validations. http://www.reumann.net/struts/articles/request_lists.jsp (last section in relation to manually calling validate). -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:cancel usage
Hi, Just for the record, I have contrived a particularly nasty work-around for this problem and share it in case anyone ever ends up as desperate as me! To recap, I have 3 buttons on a form including a cancel button for which there should be no validation. Because I have implemented a LookupDispatchAction class to handle these buttons, I cannot just use the tag 'as is' because I get the following exception (my method param is called 'method'): javax.servlet.ServletException: Request[/createContact] does not contain handler parameter named method If you include property="method" with the tag, you lose the exception but validation still takes place. So what I have done (if you will excuse the fish-heads) is: Use a standard html hidden tag (the struts tag moans about not having getter for the property x) with a dummy name: Have your cancel button call some JavaScript: and the JavaScript is: function sendCancel() { document.forms[0].elements[0].name="org.apache.struts.taglib.html.CANCEL" return true; } I have tried all the other suggestions in every combination but can't get anything more elegant to work. This works but I'm not looking forward to the code review! Regards, Andy _ Stay in touch with absent friends - get MSN Messenger http://www.msn.co.uk/messenger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:cancel usage
andy wix wrote: Hi, Sorry to harp on about this but I am sure html:cancel must work, as it is fundamental to the way sites flow! It says the following about the html:cancel 'property' attribute in the Html Tag Developer Guide: "WARNING - If you set this attribute to a value other than the default, this will NOT be recognized as the cancel key by the Struts controller servlet or the Action.isCancelled() method. You will need to do your own cancel detection". But nearly always a developer will be overriding this property with a value so that they can distinguish which button was clicked by the user to satisfy the Dispatch Action class. (I say this as I assume there will often be a submit button as well that should invoke validation). Why would a developer be overriding the property value for html:cancel? It makes sense to do it for html:submit tags to be able to detect which submit button was clicked when the execute() method of your action class is called. I just set all of the html:submit tags to use the same property name, such as "MyAction", and then I retrieve that from the HTTP request that is passed in to execute(). First, however, I test the return value of isCancelled() to see if html:cancel was clicked, and if it is false, then I test value of "MyAction" to find out which html:submit button was clicked. If you don't override the property value for html:cancel, you are observing that the Struts Validator plug-in still tries to validate the fields on the submitted form? Is this correct? -- Chuck Chopp ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com RTFM Consulting Services Inc. 864 801 2795 voice & voicemail 103 Autumn Hill Road 864 801 2774 fax Greer, SC 29651 Do not send me unsolicited commercial email. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:cancel usage
Hi, Sorry to harp on about this but I am sure html:cancel must work, as it is fundamental to the way sites flow! It says the following about the html:cancel 'property' attribute in the Html Tag Developer Guide: "WARNING - If you set this attribute to a value other than the default, this will NOT be recognized as the cancel key by the Struts controller servlet or the Action.isCancelled() method. You will need to do your own cancel detection". But nearly always a developer will be overriding this property with a value so that they can distinguish which button was clicked by the user to satisfy the Dispatch Action class. (I say this as I assume there will often be a submit button as well that should invoke validation). Does anyone know a way out of this hole I find myself in? Thanks, Andy _ Want to block unwanted pop-ups? Download the free MSN Toolbar now! http://toolbar.msn.co.uk/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:cancel usage
What I usually do is check for isCancelled() in my Action (or BaseAction) before anything else so I can forward to the appropriate place if cancel was clicked. As for the validation, I had to put my validation in a private method in the Action instead of using the one in the ActionForm. On Wed, 08 Sep 2004 08:54:19 +, andy wix <[EMAIL PROTECTED]> wrote: > Hi, > > Has anyone else had a problem with this? > I am using Struts 1.1 but presume it has worked in this and previous > versions as it must come up in almost every project. > I cannot switch validation to false as my submit button does require > validation. > I suppose I could put the cancel and submit buttons inside seperate form > tags but this seems a little contrived. > > Thanks, > Andy > > _ > It's fast, it's easy and it's free. Get MSN Messenger today! > http://www.msn.co.uk/messenger > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- For me to poop on! http://www.formetopoopon.com http://www.nbc.com/nbc/Late_Night_with_Conan_O'Brien/video/triumph.shtml - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html:cancel usage
Hi, Has anyone else had a problem with this? I am using Struts 1.1 but presume it has worked in this and previous versions as it must come up in almost every project. I cannot switch validation to false as my submit button does require validation. I suppose I could put the cancel and submit buttons inside seperate form tags but this seems a little contrived. Thanks, Andy _ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:cancel usage
I believe the validation still happens because the validation step occurs before the appropriate method in the action class in determined. I got around this by turning off automatic validation. On Tue, 07 Sep 2004 16:59:48 +, andy wix <[EMAIL PROTECTED]> wrote: > Hi, > > When using the following tag, my form still gets validated when I click the > cancel button. > > key="button.cancel"/> > > The cancel method gets called correctly in my LookupDispatchAction class. > The tag is within an html:form tag as I believe it should be. > > Does anyone have a working example of this tag or know of a different > approach? > > Thanks, > Andy > > _ > Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html:cancel usage
Which version of Struts are you using? Are you using Struts 1.1 or 1.2.x? The cancel functionality is supported in Struts 1.2.x. I use this functionality and works fine for me. I was using the MappingDispatchAction. Thanks, Venkat -Original Message- From: andy wix [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 07, 2004 10:00 AM To: [EMAIL PROTECTED] Subject: html:cancel usage Hi, When using the following tag, my form still gets validated when I click the cancel button. The cancel method gets called correctly in my LookupDispatchAction class. The tag is within an html:form tag as I believe it should be. Does anyone have a working example of this tag or know of a different approach? Thanks, Andy _ Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] If you have received this e-mail in error, please delete it and notify the sender as soon as possible. The contents of this e-mail may be confidential and the unauthorized use, copying, or dissemination of it and any attachments to it, is prohibited. Internet communications are not secure and Hyperion does not, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses. The views expressed here do not necessarily represent those of Hyperion. For more information about Hyperion, please visit our Web site at www.hyperion.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]