RE: How to pass parameters to actions ? action.do?variable=value
Hi Maris Yes, you can pass parameters in different ways: 1) The most straight forward way is the one that you suggested: a href=www.somelink.com?age=12gender=male Touch me! /a 2) You can also use the html:link tag, which is easy if you only want to pass one parameter (see paramId, paramName paramProperty). For multiple parameters you'll have to define a property on your action-form (something like a 'getParameters' method) that returns a Map consisting of the key-value pairs you want to pass. 3) If you want buttons instead of links use hidden fields to pass parameters [use the 'method' attribute to specify whether you want to use POST (default) or GET] I don't think it makes sense to talk about using the POST method in context with links - these always resolve to a GET-request. Hope that helps with regards, Klaus Bucka-Lassen aragost ag Zurich, Switzerland -Original Message- From: struts-user-digest-help [mailto:[EMAIL PROTECTED]] Sent: Freitag, 8. März 2002 20:35 To: struts-user Cc: M.Orbidans Subject: How to pass parameters to actions ? action.do?variable=value hello I need to create links with different parameters. Can I pass them directly to actions ? like this aaction.do?variable=value/a Does the Struts servlet do POST and GET ? thanx Maris Orbidan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: help with logic:iterate
Hi Maybe I completely lost the context, but as far as I can see, you haven't wrapped the html:text within a html:form tag, right? If you just want to output text to the HTML page you're generating use bean:write name=columnName instead. Using html:text for user-input within an iterator is a completely different story which includes indexed properties and scriptlets. Regards, Klaus Bucka-Lassen aragost, Switzerland -Original Message- From: struts-user-digest-help [mailto:[EMAIL PROTECTED]] Sent: Montag, 25. Februar 2002 17:32 To: struts-user Cc: srinookala Subject: help with logic:iterate I have the following snippet of code in my jsp: logic:iterate id=columnName name=ParticipantImportWizardForm property=columnNameList table border=1 width=80% tr td width=50%h3 align=centerColumn Name/h3 /td td width=50%h3 align=centerType/h3 /td /tr tr td width=50%html:text property=columnName //td td width=50% pnbsp;/p /td /tr I get the error No getter method for property columnName of bean org.apache.struts.taglib.html.BEAN. columnNameList is a collection of Strings. I can't figure out what I have to set the name and property attributes of html:text in this case. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Exception handling in the ActionServlet
Thanks for the feedback to both of you! Subclassing the ServletException is actually what I wanted to avoid. I consider that a hack, if the new exception I'm creating doesn't have anything to do with a Servlet (a UserNotAuthorizedException for instance shouldn't have to inherit from ServletException). Subclassing RuntimeException is kind of the same ball game. Wrapping a project exception in a ServletException seems a slighly cleaner solution, but it requires the developers to do the wrapping in each of the action classes. Then again, it would be easier to just subclass ServletException even though it's a hack. Well, again thanks for the reply. You both deserve a beer, so let me know when you make it to Zurich ;-) /Klaus = Howard Moore wrote: Hi, I would like to catch all of our project specific exceptions in one place (as a last resort, if nobody else catches them earlier on) and handle them in a generic way. The obvious way to do this, I think, is by overriding processActionPerform in our own ProjectActionServlet and catch ProjectException's (superclass for all our own exceptions) there. But the Action.perform method only throws IOException ServletException, so either all our own exceptions will have to inherit from either of those two classes (can't be the right thing to do), or I will have to change the Action.perform definition to also throw our ProjectException's (doesn't seem right either, I'd prefer not to have to alter any struts code)? What should I do? How about having the base class for you project exceptions be a subclass of ServletException? That way, you can throw it if you really want to. Then you could declare an error-page element in your web.xml file to define common handling (if you don't the default will be an ugly stack trace on most containers). Alternatively, if you have a project exception in your Action.perform method, you could just wrap it up in a ServletException and throw that. E.g; try { . } catch (ProjectException e) { throw new ServletException(Some text, e); } Then in your subclassed processActionPerform method you get at your original exception by calling the getRootCause() method of ServletException. This avoids having to base your exceptions on any particular subclass. This actually brings me to another problem that doesn't have anything to do with struts, but is more a general Java question. Anyway, maybe somebody here has an elegant solution to it: Assume the problem above is solved and furthermore that some of the project specific exceptions have to inherit from other existing exception classes (e.g. ServletException, IOException, etc.). Since we don't have multiple inheritance, I can't have a ProjectException that is a superclass to all my own exceptions. I still want to catch all our own exceptions (but no others) in one place. My first though was of course to define a ProjectException interface and let all our own exceptions implement this interface, thus being able only to catch ProjectException's. But Throwable is not an interface (why not? What's the idea behind this design?) that ProjectException could inherit from and thus this approach doesn't work, as the try{}catch(){} statement expects a Throwable object as parameter (try{}catch(ProjectException e){} doesn't compile). Well, as a kind of a hack I then thought I'll catch all exceptions, check if it is a project specific one (ProjectException.class.isInstance(anException)), and if not throw it again, but that can't be right, because the method where this happens then will have to be declared to throw Exception (to generic). I'll appreciate any help, thanks in advance and the best satisfactory answer wins a free beer in Zurich ;-) I'd investigate extending ServletException for your application exception classes. Another off-the-wall idea would be to extend RuntimeException instead -- you can throw such an exception without it being listed in the throws clause. This is how things like IllegalArgumentException and NullPointerException work. Klaus Bucka-Lassen Craig
Exception handling in the ActionServlet
Hi, I would like to catch all of our project specific exceptions in one place (as a last resort, if nobody else catches them earlier on) and handle them in a generic way. The obvious way to do this, I think, is by overriding processActionPerform in our own ProjectActionServlet and catch ProjectException's (superclass for all our own exceptions) there. But the Action.perform method only throws IOException ServletException, so either all our own exceptions will have to inherit from either of those two classes (can't be the right thing to do), or I will have to change the Action.perform definition to also throw our ProjectException's (doesn't seem right either, I'd prefer not to have to alter any struts code)? What should I do? This actually brings me to another problem that doesn't have anything to do with struts, but is more a general Java question. Anyway, maybe somebody here has an elegant solution to it: Assume the problem above is solved and furthermore that some of the project specific exceptions have to inherit from other existing exception classes (e.g. ServletException, IOException, etc.). Since we don't have multiple inheritance, I can't have a ProjectException that is a superclass to all my own exceptions. I still want to catch all our own exceptions (but no others) in one place. My first though was of course to define a ProjectException interface and let all our own exceptions implement this interface, thus being able only to catch ProjectException's. But Throwable is not an interface (why not? What's the idea behind this design?) that ProjectException could inherit from and thus this approach doesn't work, as the try{}catch(){} statement expects a Throwable object as parameter (try{}catch(ProjectException e){} doesn't compile). Well, as a kind of a hack I then thought I'll catch all exceptions, check if it is a project specific one (ProjectException.class.isInstance(anException)), and if not throw it again, but that can't be right, because the method where this happens then will have to be declared to throw Exception (to generic). I'll appreciate any help, thanks in advance and the best satisfactory answer wins a free beer in Zurich ;-) Klaus Bucka-Lassen