Struts 2.2.1.1 : reload .properties files
Hi, I cannot get auto-reload of .properties files to work with struts 2.2.1.1. (with the mail sample app) Steps to reproduce: - Download Struts 2.2.1.1 : http://struts.apache.org/download.cgi#struts2211 - Extract - cd src/apps/mailreader - change pom.xml: 0 - change src/main/java/struts.xml - mvn jetty:run - load http://localhost:8080/struts2-mailreader/Welcome.do - change ./target/classes/mailreader2/MailreaderSupport.properties index.heading=MailReader Demonstration Application Options CHANGED DYNAMICALLY - reload in the browser - => the displayed value does not reflect ./target/classes/mailreader2/MailreaderSupport.properties => So, my question is : what did I miss ? Sami - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2.2.1.1 : reload .properties files
Hi, Since I believe it is a bug in Struts2 (or at least, a bug in the documentation), I created a JIRA issue https://issues.apache.org/jira/browse/WW-3602 So, let's continue the discussion directly on JIRA. Disabling scanIntervalSeconds is exactly what I wanted to do, because I do not want jetty to redeploy. I directly edit the files in target/classes, otherwise jetty tries to completely restart the webapp. Sami On 11-04-01 01:28 AM, Lukasz Lenart wrote: 2011/3/31 Sami Dalouche: - change pom.xml:0 "scanIntervalSeconds Optional. The pause in seconds between sweeps of the webapp to check for changes and automatically hot redeploy if any are detected. By default this is 0, which disables hot deployment scanning. A number greater than 0 enables it." Kind regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
overriding struts.xml settings from web.xml
Hi, http://struts.apache.org/2.x/webxml.html explains how to set struts2 params from web.xml. I have several questions regarding this : 1/ If the same setting is declared both in web.xml and in struts.xml, which one wins ? 2/ the example sets the setting on StrutsPrepareAndExecuteFilter. What happens if I happen to run StrutsPrepareFilter and StrutsExecuteFilter separately ? Should I set the variables for both filters ? Thanks, Sami - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
[Struts 2] : Zero Configuraiton : some feedback
Hi, On http://struts.apache.org/2.x/docs/release-notes-209.html, I can read : "Please help us test these brave new features. Feedback appreciated". So, here is some feedback about Zero configuration : - the feature is pretty cool, though not much documented. For instance, it was not obvious to me what the "params" parameter meant in the @Result annotation, and I had to dig into the source code to understand that odd indexes where the keys and even ones where the values... So, a freemarker view that would return XML would be described as @Results( { @Result(name = "success", value = "/WEB-INF/views/blabla.ftl", type = FreemarkerResult.class, params = { "contentType", "text/xml" }) }) - I have been looking for a way to specify the default package, but it looks like I have to manually copy / paste the following line for my actions to use the "default" package settings : @ParentPackage("default") - And last, I am experiencing some weird problems... Basically, 9 times out of 10, everything is fine, but sometimes, for no particular reason, the @ParentPackage("default") line in my actions seem to have no effect and the zero-conf Actions use the struts provided default stack, not the one that I defined in my default package.. (either the web application boots correctly and works for its whole uptime, or it doesn't work at all. When it doesn't work, the only way to get it working it by rebooting the web application). I have absolutely no idea about the reasons that could cause that... Have you heard of anything similar before ? Regards, Sami Dalouche - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Has anyone developed a web app using struts 2 and agegi security framework?
Hi, I guess that by "integrating acegi and struts 2", you mean, "integrating acegi URL security with struts 2". So, here are some tips... 1] Configure Acegi however you would do it using pure JSP / servlets 2] Create an interceptor using the instructions given here http://struts.apache.org/2.0.9/docs/can-we-use-acegi-security-with-the-framework.html 3] Additionally, if you use freemarker and you cannot make your action implement the AuthzAware interface (or if you want to use some Acegi code inside Sitemesh, for instance), you can use the JSP Taglib provided by sitemesh <#assign authz=JspTaglibs["/WEB-INF/tld/authz.tld"] /> <@authz.authorize ifNotGranted="ROLE_USER"> ... And that should be enough to get acegi working with struts2.. Regards, Sami Dalouche Le dimanche 07 octobre 2007 à 15:12 +0700, Tuyen Dinh Van a écrit : > I am now developing my own management suite using struts 2, and I also > intend to use acegi for security, but very few document available for such > integration. > > Has any one successfully integrated the acegi framework into struts 2? > Any suggestion is appreciated. > > Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to keep object from action to action
Hi, you should take a look at Spring Web Flow (http://www.springframework.org/webflow) and its Struts2 plugin (http://cwiki.apache.org/S2PLUGINS/spring-webflow-plugin.html). Regards, Sami Dalouche Le lundi 08 octobre 2007 à 15:03 +1000, Zoran Avtarovski a écrit : > Action chaining isn't just to access logic in two separate action classes, > but is often necessary when intermediate input is required from the user, > for example complex forms which need to be broken down into multiple pages, > wizards if you like. > > Since Struts 1 we have been sticking the user entered data in the session > scope, which poses its own problems. I thought the big advantage of S2 was > the ability to "easily" implement action chaining and let the framework deal > with how to persist the data across multiple requests. But I'm finding that > it's not the case. > > Z. > > > This is usually called "action chaining" > > > > * http://struts.apache.org/2.x/docs/action-chaining.html > > > > Experience shows that chaining should be used with care. If chaining > > is overused, an application can turn into "spaghetti code". Be sure to > > ask yourself why you need to chain from Action1 to Action2. Could the > > logic in Action2 be pushed back to a support class or business facade > > so that Action1 can call it too? > > > > Ideally, Action classes should be as short as possible. All the core > > logic should be pushed back to a support class or a business facade, > > so that Actions only call methods. Actions are best used as adapters, > > rather than as a class where coding logic is defined. > > > > -- HTH, Ted > > <http://www.husted.com/ted/blog/> > > > > > > > > On 10/4/07, ros <[EMAIL PROTECTED]> wrote: > >> > >> Hi! > >> > >> I use struts2 and want to load object in action1 and then access in in > >> action2 and result jsp, like on drawing > >> > >> my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit > >> -(myobject)-> my2.jsp -> my2.html > >> > >> I do not want to load this object in action2.edit if it was already loaded > >> in action1.save. > >> > >> Can struts2 pass objects from action to action? > >> > >> Thanks. > >> > >> > >> -- > >> View this message in context: > >> http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html > >> #a13040888 > >> Sent from the Struts - User mailing list archive at Nabble.com. > > > > - > > 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] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: actionPackages parameter provokes PermGen memory error
Hi, have you tried spring's IntrospectionCleanupListener ? http://www.springframework.org/docs/api/org/springframework/web/util/IntrospectorCleanupListener.html It looks like the problem you are experiencing is the one the listener claims to solve. Regards, Sami Dalouche On Mon, 2007-10-08 at 02:10 -0700, wild_oscar wrote: > Should this be reported as a possible bug? > > > > wild_oscar wrote: > > > > Dear all, > > > > I've been struggling with a Permgen error on my application's development: > > after a number of re-deployments, I get a permgen memory error in Tomcat 6 > > (described in more detail here > > http://www.nabble.com/forum/ViewPost.jtp?post=12984476&framed=y > > http://www.nabble.com/forum/ViewPost.jtp?post=12984476&framed=y ). > > > > After a few days analizing with Jprofiler (and learing more about memory > > leaks in http://blogs.sun.com/fkieviet/entry/how_to_fix_the_dreaded Frank > > Kieviet's useful blog post), I got to no conclusion about the origin of > > the leak. So I conducted a test. Starting from Struts2's blank > > application, I made a script that deployed and undeployed the application > > in Tomcat so it would fill the permgen space. If it all was ok, once > > permgen space was full it would release unlinked objects (thus increasing > > permgen's free space). If something went wrong, it would give me the > > permgen error. > > > > To my suprise, I built my application and got the Permgen space when I > > added: > > > > > > actionPackages > > com > > > > > > to my Struts2 filter. > > > > I had this parameter so I could annotate my actions. > > > > I tried deleting all my .com package classes. So, even with an empty > > package, putting the actionPackages parameter will give me a PermGen error > > on re-deployment and removing it will make Permgen memory be managed > > alright. > > > > Does anyone know why this happens and how to solve it? Can you reproduce > > this error? > > > > All input appreciated, this permgen error is driving me crazy! > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2 Freemarker Templates
Hi, you should be able to access your start and stop variables using : ${parameters.start} and ${parameters.stop} expressions in your FTL template. Regards, Sami Dalouche Le lundi 08 octobre 2007 à 12:59 -0400, Jason Deffenbaugh a écrit : > I'm trying to make a custom template for the checkboxlist struts tag to > only write out the html for the checkboxes in the list between two > parameter values I send to the template. > > I want to pass parameters from the jsp file into the freemarker template > but I'm not sure how to do it. > > > So, I'm thinking that in the jsp I do something like: > > templateDir="WEB-INF/freemarker"> > > > > > Can I access that in the template somehow? > > Thanks, > Jason > > > > > - > 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: Struts 2 Themes
Hi, your best bet is to look at S2's source code. You can start by looking at org.apache.struts2.views.freemarker.tags.StrutsModels. Each of the tags have an associated "Model", and S2 taglib's models are registered in this class. So, for instance, if you look for TextField's template name : 1] There is a "TextFieldModel" instance declared 2] So, you look at org.apache.struts2.views.freemarker.tags.TextFieldModel#getBean() : 3] You can see "return new TextField(stack, req, res);" 4] So, you look at org.apache.struts2.components.TextField 5] You can see : final public static String TEMPLATE = "text"; => So, the template name is "text" ;) Regards, Sami Dalouche Le mardi 09 octobre 2007 à 13:07 -0400, Jiang, Jane (NIH/NCI) [C] a écrit : > Sorry, my fault. I did not notice the code I used to test checkbox > defined the theme inside the tag. So checkbox.ftl is the template for > s:checkbox. I would still like to find out if there is a general rule > for map the tag to template and other resource to learn about theme. > > -Original Message- > From: Jiang, Jane (NIH/NCI) [C] > Sent: Tuesday, October 09, 2007 12:57 PM > To: Struts Users Mailing List > Subject: Struts 2 Themes > > I am trying to get a better understanding of S2 themes. I read the > document and the create themes page in the cookbook. > > My question is how I can find the right template file for a tag. I > tried to change text.ftl and found that ties to s:textfield. I am now > trying to figure out what is the one for checkbox. I thought it would > be the checkbox.ftl. But s:chechbox does not change at all when I > changed the checkbox.ftl. What about s:property? > > Where can I find more information if I want to get more into the themes? > > Thanks a lot for your help, > > Jane > > - > 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] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dojo version in struts 2.0.11?
If anyone is interested, I have created my own dojo 1.0.0 theme for standard Struts 2 tags. (works on Dojo 2.0.11). It's far from being *clean*, far from being complete, uses undocumented attributes, but is a good starting guide to create progressive JavaScript enhancement (falls back to pure HTML widgets if JS is not enabled). So, do not hesitate to drop me an email if you want to look at the code, or plan to cleanly repackage it for Struts, it's available under whatever open source license you prefer. Regards, Sami Dalouche On Fri, 2007-11-09 at 21:25 +1100, Jeromy Evans wrote: > Does anyone know -exactly- which revision of dojo is bundled in Struts > 2.0.11? > > A diff of the src dirs reveals it's not the tagged 0.4.2 release or > tagged 0.4.3 release. I believe it's near 0.4.2 but can't find a match. > > The dojo plugin in Struts 2.1.x definitely uses the 0.4.3 tagged release. > > Max Pimm wrote > > Which is the dojo version that was used in the build of > struts2-core-0.011.jar? > > - > 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: dojo version in struts 2.0.11?
Hi, it would be awesome to build a production-quality version on top of what I started. as Antonio suggested, I created a JIRA feature request for that : https://issues.apache.org/struts/browse/WW-2311 and attached the theme here. The code is currently built against struts 2.0.11, which is the version I currently use. Alvaro- Which version are you targetting ? Regards, Sami Dalouche Le vendredi 09 novembre 2007 à 12:25 +0100, Alvaro Sanchez-Mariscal a écrit : > Hi Sami, > > My company (Salenda) is willing to contribute to get a > production-quality version. > > Perhaps sharing source code in a cvs/subversion may be a good starting point. > > Anybody else interested? > > Alvaro. > > On Nov 9, 2007 12:09 PM, Sami Dalouche <[EMAIL PROTECTED]> wrote: > > If anyone is interested, I have created my own dojo 1.0.0 theme for > > standard Struts 2 tags. (works on Dojo 2.0.11). > > > > It's far from being *clean*, far from being complete, uses undocumented > > attributes, but is a good starting guide to create progressive > > JavaScript enhancement (falls back to pure HTML widgets if JS is not > > enabled). > > > > So, do not hesitate to drop me an email if you want to look at the code, > > or plan to cleanly repackage it for Struts, it's available under > > whatever open source license you prefer. > > > > Regards, > > Sami Dalouche > > > > > > > > On Fri, 2007-11-09 at 21:25 +1100, Jeromy Evans wrote: > > > Does anyone know -exactly- which revision of dojo is bundled in Struts > > > 2.0.11? > > > > > > A diff of the src dirs reveals it's not the tagged 0.4.2 release or > > > tagged 0.4.3 release. I believe it's near 0.4.2 but can't find a match. > > > > > > The dojo plugin in Struts 2.1.x definitely uses the 0.4.3 tagged release. > > > > > > Max Pimm wrote > > > > Which is the dojo version that was used in the build of > > > struts2-core-0.011.jar? > > > > > > - > > > 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] > > > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts2 : create URLs programmatically
Hi, In order to generate some emails (and other similar things), I would need to output the URL of some Struts2 actions. Of course, the URLs depend on the chosen ActionMapper, and I'd like my generated URLs to be compliant with the configured ActionMapper. The Component class seems to contain the "determineActionUrl" method, that would fit my needs, but it is protected, so I guess the right way to determine an Action URL is something different... So, can anyone tell me how to achieve that using the Public API of Struts2 ? If it is not possible, I can always copy the few methods on which determineActionUrl() depends, but it needs an ActionmMapper instance that is normally @Inject'ed. How am I supposed to fetch this instance ? Thanks for your help, Sami Dalouche - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2 tag property calls with arguments?
Hi, Not sure if I understand your question correctly, but it seems you are trying to make a Java method call from your View. In Struts2, properties are accessed using the OGNL language. The OGNL reference is available from http://www.ognl.org/. In particular, it is possible to make any method call using OGNL, using the simple syntax : myMethod(param1, param2) so, in your case, it could be getVehicles('car') Hope that helps, Regards, Sami Dalouche Le dimanche 27 mai 2007 à 20:15 +0200, Torsten Römer a écrit : > I guess this has been asked before but I have trouble finding an answer, > if it is somehow possible to give arguments to property calls in tags. > For example, if I'd have "vehicles" as list attribute in , > that I could give literal arguments like "car" or "motorcycle" and have > a method like getVehicles(String type) { ... } in my backing bean. > > A simple "yes" or "no" would already be very helpful :-) > > Torsten > > - > 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: S2 tag property calls with arguments?
Hi, OGNL is yet another language that one can use to access properties and methods. You can see it as a simplified language (like Groovy or Java itself) that is focused on data binding. To KISS, in Java, you would access your properties using : obj.getProperty1().getProperty2().methodCall() in OGNL, the syntax would be : obj.property1.property2.methodCall() In Java, you choose the object on which you apply the getProperty1() method. In OGNL, the object is implicit, and is called a context map. A context Map is just a simple Hash Map where one of the objects is chosen as the ROOT. Struts2 has arbitrarily chosen to choose the Value Stack as the ROOT. So, that means that all the properties you call and your action's properties. Another popular web framework, Tapestry, also uses OGNL. The Component / Page in Tapestry is the OGNL ROOT. Hope that helps, Sami Dalouche Le lundi 28 mai 2007 à 01:21 +0200, Torsten Römer a écrit : > Thanks Sami, > > That did definetely help, was just what I was looking for! > > > In Struts2, properties are accessed using the OGNL language > > Somehow I haven't really realized what this actually means... > > Torsten > > Sami Dalouche schrieb: > > Hi, > > > > Not sure if I understand your question correctly, but it seems you are > > trying to make a Java method call from your View. > > > > In Struts2, properties are accessed using the OGNL language. The OGNL > > reference is available from http://www.ognl.org/. > > > > In particular, it is possible to make any method call using OGNL, using > > the simple syntax : > > myMethod(param1, param2) > > > > so, in your case, it could be > > getVehicles('car') > > > > Hope that helps, > > Regards, > > Sami Dalouche > > > > Le dimanche 27 mai 2007 à 20:15 +0200, Torsten Römer a écrit : > >> I guess this has been asked before but I have trouble finding an answer, > >> if it is somehow possible to give arguments to property calls in tags. > >> For example, if I'd have "vehicles" as list attribute in , > >> that I could give literal arguments like "car" or "motorcycle" and have > >> a method like getVehicles(String type) { ... } in my backing bean. > >> > >> A simple "yes" or "no" would already be very helpful :-) > >> > >> Torsten > >> > >> - > >> 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] > > > > > > > > - > 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]
& characters are encoded as & in OGNL parameters
Hi, When creating a URL using the Struts2 JSP tag, and then, later in the page, reusing the url #id in some OGNL parameter, it seems the "&" characters in the URL are encoded as & Is this supposed to be a feature or a bug ? Is it possible to disable this behaviour somehow ? Thanks for your help, Sami Dalouche - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: & characters are encoded as & in OGNL parameters
Hi, > > Is it possible to disable this behaviour somehow ? > > Depends how you're using the URL. Are you sure you even *want* to > disable the behaviour? Encoding ampersands is generally the right thing > to do. > Well, yeah, I do want to disable it. Basically, I need to generate the fully qualified (hostname, port, context, action) URL of the current page (with different parameters), so that I can encode it (using URLEncoder), append it to http://maps.google.com/q={myUrl} The problem is that URLEncoder WILL encoder & correctly, so I don't want struts to process it before I do. So, is it possible to disable this & encoding ? Thanks, Sami Dalouche - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: & characters are encoded as & in OGNL parameters
Hi, 1] Yes, I can pre-process the value, using something like string replace... It's just hackish, and I wondered if there were a "right" way of doing this 2] encode doesn't work; In fact, it seems this parameter only maps to HttpServletResponse, which only adds the ;jsessionid pseudo-parameter to the URLs.. Regards, Sami Le mardi 29 mai 2007 à 15:35 -0400, Laurie Harper a écrit : > Sami Dalouche wrote: > > Hi, > > > >>> Is it possible to disable this behaviour somehow ? > >> Depends how you're using the URL. Are you sure you even *want* to > >> disable the behaviour? Encoding ampersands is generally the right thing > >> to do. > > > > Well, yeah, I do want to disable it. > > Basically, I need to generate the fully qualified (hostname, port, > > context, action) URL of the current page (with different parameters), so > > that I can encode it (using URLEncoder), append it to > > http://maps.google.com/q={myUrl} > > > > The problem is that URLEncoder WILL encoder & correctly, so I don't want > > struts to process it before I do. > > > > So, is it possible to disable this & encoding ? > > Hmm, well, you haven't described how you're using the url produced with > the s:url tag other than 'reusing the url #id in some OGNL parameter'; > that's a bit vague. Assuming you're using OGNL to pass the URL value to > a method you've written, you can pre/post process the value any way you > want. > > The s:url tag has an 'encode' attribute to control whether the URL > should be encoded [1], which is true by default. Perhaps all you need is > to set that appropriately. > > L. > > [1] http://struts.apache.org/2.x/docs/url.html > > > - > 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: [S2] Design patterns
Hi, I personally : 1] Do NOT use inheritance, besides ActionSupport that provides the basic methods (getText, ..) to work with Struts2. 2] Group all methods of a form inside the same Action. Usually, I need the same code to prepare the input and the validation of the form, so why would I bother with inheritance and additional classes when I can find two clean methods in the same class ? 3] Never ever put business logic (besides validation, that should belong to the domain, but Struts2 doesn't provide any adapter for Hibernate Validator, so I have to live with that for now) inside the Actions. The Actions are just here to either query services/domain or create business objects and save them. (See Domain Driven Design recommendations for more information) 4] I only implement SessioNAware, ValidationAware, and so on when I need to. I do not want to clutter ALL my classes with useless stuff I only use 10% of the time. Just KISS :) Regards, Sami Dalouche On Mon, 2007-06-11 at 05:52 -0700, meeboo wrote: > Hey all > > How do you build up your Struts 2 applications architecture wise? Say for > instance that you have a User model object. Do you create an action class > (e.g. UserAction.java) for all User actions, or do you separate them into > UpdateUser.java/CreateUser.java etc...? We thought Struts 2 was a big mess > at first since it allows you to construct your web-tier in virtually any way > you want. But after a couple of weeks we started using a "pattern" where > each JSP page has its own java action class and all action classes inherit > from a superclass which implements SessionAware, ValidationAware and so > forth. Do you think this is a good approach? It's worked great for us so > far. > > Cheers! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Binding Java 5 Enums..
Hi, I've been trying to bind Java 5 enums, but I get some weird problem xwork-conversion.properties java.lang.Enum = funala.web.action.typeconverters.TestTypeConverter TestTypeConverter extends EnumTypeConverter and just adds some logs, to make sure the converter is actually used. (I get the same problem by using the EnumTypeConverter directly) So, the weird thing is that binding from the Enum to String works perfectly, but the opposite doesn't work.. (the Enum is SexTraitType, and contains MALE, FEMALE) [INFO] [2007-02-11 20:58:39,959] [funala.web.action.typeconverters.TestTypeConve rter] (btpool0-3,) : convertValue: [Ljava.lang.String;@16bfded:class funala.doma in.entity.profile.traitTypes.SexTraitType [INFO] [2007-02-11 20:58:39,959] [funala.web.action.typeconverters.TestTypeConve rter] (btpool0-3,) : convertFromString: FEMALE:class funala.domain.entity.profil e.traitTypes.SexTraitType [ERROR] [2007-02-11 20:58:39,964] [com.opensymphony.xwork2.interceptor.Parameter sInterceptor] (btpool0-3,) : ParametersInterceptor - [setParameters]: Unexpected Exception catched: Error setting expression 'sexTrait' with value '[Ljava.lang. String;@16bfded' (and I do have my get/set sexTrait() on the action. { .. } Does anyone know what could cause the problem ? Thanks for your help, Sami Dalouche - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts2 : TypeConverter and Null Values
Hi, Let's consider we have a S2 select box that is not required (s:select required="false" ). The property to which it is bound can be null. However, by default, Struts2 complains using the invalid field error message. One way to circumvent this would be, I guess, to use some NullSafeTypeConverter, associated to the java.lang.Object type. Several questions : 1] Is this the best approach ? 2] Why doesn't Struts ship NullSafeTypeConverter by default ? Regards, Sami Dalouche - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cross site scripting issue
Hi, If you want to escape HTML, you can use Jakarta Commons-Lang StringEscapeUtils class : http://jakarta.apache.org/commons/lang/apidocs/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String) Personally, I am using the Radeox Wiki engine (http://www.radeox.org/space/start) to render all of my free-form text areas. Regards, Sami Le jeudi 15 mars 2007 à 01:15 -0400, Joseph McGranaghan a écrit : > Are you allowing the user to redisplay any entered HTML ala myspace? > > I'm working on a solution for this right now. For this situation, I'm > filtering it in action before it is saved to DB. > > Here are some REs and a simple function: > > > private final static String XSS_BIG_OBJECTS_FILTER = > "(((<\\s*[Aa][Pp][Pp][Ll][Ee][Tt].*>.*<\\s*/.*[Aa][Pp][Pp][Ll][Ee][Tt]\\s*>)|(<\\s*[Aa][Pp][Pp][Ll][Ee][Tt].*/\\s*>))|"+ > > > "((<\\s*[Oo][Bb][Jj][Ee][Cc][Tt].*>.*<\\s*/.*[Oo][Bb][Jj][Ee][Cc][Tt]\\s*>)|(<\\s*[Oo][Bb][Jj][Ee][Cc][Tt].*/\\s*>))|"+ > > > "((<\\s*[Ss][Cc][Rr][Ii][Pp][Tt].*>.*<\\s*/.*[Ss][Cc][Rr][Ii][Pp][Tt]\\s*>)|(<\\s*[Ss][Cc][Rr][Ii][Pp][Tt].*/\\s*>))|"+ > > > "((<\\s*[Ee][Mm][Bb][Ee][Dd].*>.*<\\s*/.*[Ee][Mm][Bb][Ee][Dd]\\s*>)|(<\\s*[Ee][Mm][Bb][Ee][Dd].*/\\s*>))|"+ > > > "(=\\s*[\"\']*\\s*[Jj][Aa][Vv][Aa][Ss][Cc][Rr][Ii][Pp][Tt]\\s*:.*[\"\']))"; > > > private final static String XSS_BIG_TAGS_FILTER = > "(((<\\s*[Ss][Ee][Rr][Vv][Ee][Rr].*>.*<\\s*/.*[Ss][Ee][Rr][Vv][Ee][Rr]\\s*>)|(<\\s*[Ss][Ee][Rr][Vv][Ee][Rr].*/\\s*>))|"+ > > > "((<\\s*[Ff][Rr][Aa][Mm][Ee].*>.*<\\s*/.*[Ff][Rr][Aa][Mm][Ee]\\s*>)|(<\\s*[Ff][Rr][Aa][Mm][Ee].*/\\s*>))|"+ > > > "((<\\s*[Ii][Ff][Rr][Aa][Mm][Ee].*>.*<\\s*/.*[Ii][Ff][Rr][Aa][Mm][Ee]\\s*>)|(<\\s*[Ii][Ff][Rr][Aa][Mm][Ee].*/\\s*>))|"+ > > > "((<\\s*[Ff][Rr][Aa][Mm][Ee][Ss][Ee][Tt].*>.*<\\s*/.*[Ff][Rr][Aa][Mm][Ee][Ss][Ee][Tt]\\s*>)|(<\\s*[Ff][Rr][Aa][Mm][Ee][Ss][Ee][Tt].*/\\s*>)))"; > > > > /* > * No relative URLs > * No cross-domain URLs > * > * Tags ( a,img,form,ilayer ) > */ > private final static String XSS_NOT_HTTP_RE = > "([^Hh]|[Hh][^Tt]|[Hh][Tt][^Tt]|[Hh][Tt][Tt][^Pp])*"; > > private final static String > XSS_NOT_RELATIVE_NOR_XDOMAIN_LINKS_FILTER = > "((<\\s*[Aa].*[Hh][Rr][Ee][Ff]\\s*=.*"+XSS_NOT_HTTP_RE+".*>.*>)|"+ > > "(<\\s*[Aa].*[Hh][Rr][Ee][Ff]\\s*=.*[Ee]-[Cc][Oo][Aa][Ll][Ee][Ss][Cc][Ee].*>.*>))"; > > > > /* > * handle img|ilayer src attributes > */ > private final static String XSS_NOT_RELATIVE_NOR_XDOMAIN_SRC_FILTER > = > "((<\\s*[Ii]([Mm][Gg]|[Ll][Aa][Yy][Ee][Rr]).*[Ss][Rr][Cc]\\s*=.*"+XSS_NOT_HTTP_RE+".*>.*>)|"+ > > "(<\\s*[Ii]([Mm][Gg]|[Ll][Aa][Yy][Ee][Rr]).*[Ss][Rr][Cc]\\s*=.*[Ee]-[Cc][Oo][Aa][Ll][Ee][Ss][Cc][Ee].*>.*>))"; > > > > > /* > * form tags allowed, but action cannot be relative or xdomain > */ > private final static String XSS_FORMS_FILTER = > "((<\\s*[Ff][Oo][Rr][Mm].*[Aa][Cc][Tt][Ii][Oo][Nn]\\s*=.*"+XSS_NOT_HTTP_RE+".*>.*<\\s*/\\s*[Ff][Oo][Rr][Mm]\\s*>)|"+ > > "(<\\s*[Ff][Oo][Rr][Mm].*[Aa][Cc][Tt][Ii][Oo][Nn]\\s*=.*[Ee]-[Cc][Oo][Aa][Ll][Ee][Ss][Cc][Ee].*>.*<\\s*/\\s*[Ff][Oo][Rr][Mm]\\s*>))"; > > > > > /* > * target attributes need to be replaced with target='_blank' > */ > private final static String XSS_TARGET_ATTRIBUTES_FILTER = > "\\s*[Tt][Aa][Rr][Gg][Ee][Tt]\\s*=\\s*((\'.*\')|(\".*\")|(_.*\\s*))"; > > private final static String BLANK_TARGET = " target=_blank "; > > > private String filterForHTMLRedisplay(String html){ > > String filtered = null; > > try{ > > RE reObjects = new RE(FormUtils.XSS_BIG_OBJECTS_FILTER); > filtered = reObjects.subst(html," "); > > RE reTags = new RE(FormUtils.XSS_BIG_TAGS_FILTER); > filtered = reTags.subst(filtered," "); > > RE reLinks = new > RE(FormUtils.XSS_NOT_RELATIVE_NOR_XDOMAIN_LINKS_FILTER); > filtered = reLinks.subst(filtered," "); > > RE reSrc = new > RE(FormUtils.XSS_NOT_RELATIVE_NOR_XDOMAIN_SRC_FILTER); > filtered = reSrc.subst(filtered," "); > > RE reForms = new RE(FormUtils.XSS_FORMS_FILTER); > filtered = reForms.su