RE: Handling Date objects in ActionForm gracefully
Since I just wrestled greatly with this particular beast, my $.02 follows. Subclass whatever flavor of ActionForm you use, and give it a method with a footprint like- java.util.Date StringToDate(String) { } This way you can do something like this in your action: public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Myform mf = (Myform) form; BizObject bo = new BizObject(); String dateText = mf.getDateString(); bo.setDate(mf.StringToDate(dateText); // etc } This works very well unless internationalizing your app because the converter needs a DateFormat defined to read the String correctly. And I am, so I need to come up with something. I don't suppose there is a version of BeanUtils that lets the user pass a DateFormat into copyProperties :-)??? -Joe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, March 26, 2004 3:58 AM To: Struts Users Mailing List Subject: RE: Handling Date objects in ActionForm gracefully +1 I also suggest this approach to keep the date as string during posts and convert them to date object when porcessing the entered dates, surely not in the Form. Depends on what you really want to achieve. Would suggest the KISS rule..:-) Robert Taylor [EMAIL PROTECTED] on 03/25/2004 08:53:31 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] cc:(bcc: Anuj Upadhyay/Jeppesen/TMC) Subject: RE: Handling Date objects in ActionForm gracefully +1 -Original Message- From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Thursday, March 25, 2004 2:36 PM To: Struts Users Mailing List Subject: Re: Handling Date objects in ActionForm gracefully Have it as a string and convert it to a date or calendar when you pass it back to the model. On 25 Mar 2004, at 20:28, Sreenivasa Chadalavada wrote: All, We are facing a problem when we define java.util.Date field in ActionForm. Is there any way to override the default behavior provided by Struts? I very much appreciate your help!! Thanks and Regards, Sree/- --- - This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. -- - - - 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]
DynaForm Type Conversion
I have a bean I persist with Hibernate. It's properties are: 2 Floats 1 Integer (the key) 2 Dates Now, relying on my handy dandy copies of Struts KickStart, Struts In Action, and all of the Web, I'm apparently supposed to declare these methods in the Form I am using as Strings since automatic type conversion can fubar them. But Since the JSP I am using is getting these fields with html:text fields, I apparently am supposed to have methods in form to do the type conversion for me. Okay, that's light years better than putting this in the business layer, but fine. Is there an Automatic way I can get a DynaBean to do this for me? Maybe a Get (prop, type) and get(prop, type, value) for the types youd find in java.lang? If not, there should be, because it limits what a DynaBean can do in a big kinda way. Why have a type declaration in the DTD if youre only ever going to want to use String and String[] ? :-) I mean, it's not like I couldnt add such a set of methods to my DynaValidatorActionForm subclass, but what I'd want is for the framework to use them for me without me needing to know about it. (I dont ask for much, do I???). If not, I'd like to continue to use my Subclassed DynaValidatorActionForm anyway, but I am wondering if it is going to be self-defeating to declare custom getters and setters for properties that are declared in struts config? Should I just use it as a non-dyna form? Maybe I've been up too late (okay, I have) but it's the little things like this that makes me feel like Struts is creating work for me rather than saving me from it. Tx for indulging my sleepy rant. -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynaform Type Conversion
Well, I was using copyProperties...or rather I\'d want to. I\'m just trying to avoid having to declare my Transfer Objects the hard way. Say I use Mark Lowe\'s idea of the Nested Form Bean (makes sense in alot of ways), but I want to do it dynamically. i.e. DynaForm A has a List property of what will be a bunch of DynaBean B\'s. So riddle me this, how do I instantiate a DynaBean myself as it is defined in the struts-config.xml? When it\'s passed in to the Action as the form, it\'s all prepped and ready to go. If I instantiate an instance of the class myself, it\'s got no dynaproperties. I know BeanUtils will provide functionality to do this, but I would hope there\'s an exposed method that does based straight out of the contents struts-config. Does Struts provide a method where I provide it the name of the bean defined in the struts-config.xml and it return me an instance of the appropriate class, with all the dyna properties set up? -Joe -Original Message- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Thursday, March 25, 2004 8:38 AM To: Struts Users Mailing List Subject: Re: DynaForm Type Conversion Take a look at BeanUtils.copyProperties. By default, though, it doesn\'t support conversion of dates, since it wouldn\'t know how you\'d want your dates formatted. Check the archives of this list, there\'s been some discussion on that. Another archive you can check is that of the commons-user list. If you\'re looking for further reduction in code, take a look at http://www.rabago.net/struts/formdef which I\'m working on. It\'s alpha, but an initial release is coming real soon (and I\'m looking for folks to help me develop/maintain it). I believe the Struts dev team has plans to include functionality like this in a future version of Struts. For now, we either make do with BeanUtils, or do the conversion ourselves, or through third party plugins like what I\'m working on. If you feel strongly enough about it, you can rant some more on http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27321 though like I said, the dev team has plans for supporting this functionality in a future version. How near or far into the future might be influenced by user requests. :) --- Joe Hertz [EMAIL PROTECTED] wrote: I have a bean I persist with Hibernate. It\'s properties are: 2 Floats 1 Integer (the key) 2 Dates Now, relying on my handy dandy copies of Struts KickStart, Struts In Action, and all of the Web, I\'m apparently supposed to declare these methods in the Form I am using as Strings since automatic type conversion can fubar them. But Since the JSP I am using is getting these fields with html:text fields, I apparently am supposed to have methods in form to do the type conversion for me. Okay, that\'s light years better than putting this in the business layer, but fine. Is there an Automatic way I can get a DynaBean to do this for me? Maybe a Get (prop, type) and get(prop, type, value) for the types youd find in java.lang? If not, there should be, because it limits what a DynaBean can do in a big kinda way. Why have a type declaration in the DTD if youre only ever going to want to use String and String[] ? :-) I mean, it\'s not like I couldnt add such a set of methods to my DynaValidatorActionForm subclass, but what I\'d want is for the framework to use them for me without me needing to know about it. (I dont ask for much, do I???). If not, I\'d like to continue to use my Subclassed DynaValidatorActionForm anyway, but I am wondering if it is going to be self-defeating to declare custom getters and setters for properties that are declared in struts config? Should I just use it as a non-dyna form? Maybe I\'ve been up too late (okay, I have) but it\'s the little things like this that makes me feel like Struts is creating work for me rather than saving me from it. Tx for indulging my sleepy rant. -Joe __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.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: There *has* to be an easy way to do this..
In a word, Doh! I'm using a DynaForm, and frankly, wanted this as a form property, but well...Let's just say I was brainwashed by my previous paradigm. Rather than using a List in the dynaform, I'm going to create a bunch of String[] properties. Not even so much for the decoupling aspect (which isn't AS big of a deal as it usually is because this JSP by definition is going to be a maintenance screen for this particular Object regardless) but I'm going to need sic the validator onto the fields on the screen, so string arrays it is. JOC, is it kosher for me to be setting the form properties in the Action that leads into the JSP, or should I be doing it somewhere in the form's class. (This seems like a basic question, but in the home grown framework I was raised on, this concept was a bit of a no-no. Much like chaining actions is in Struts. Thanks for your help. -Joe -Original Message- From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Monday, March 22, 2004 4:20 AM To: Struts Users Mailing List Subject: Re: There *has* to be an easy way to do this... Your using OM objects and stuffing them into your view but this should still work anyhow. CreditCost newCost = new CreditCost(); creditCostList.add(newCost); Have an add action do the above, I assume you're scoping to session as you're iterating through a scoped array/list and not a form property. IMO you want to have things looking more like this logic:iterate id=item name=costsForm property=creditCosts and in your actions CreditCostsForm theForm = (CreditCostsForm) form; List costList = theForm.getCreditCosts(); costList.setCrediCost(costList.size(),new CreditCostForm()); Notice CreditCostForm not CreditCost from you OM, although you could get away with using CreditCost as a form property it will make life harder if you ever want to decouple the web and model tiers. If you cant be arsed having webtier beans/forms then perhaps use a map or dynabean to do the same thing. On 22 Mar 2004, at 08:42, Joe Hertz wrote: I have a simple iterate in a piece of JSP (snippet follows) that provides an interface inside of an HTML table to modify items that came out of the database. What I want to do is provide an extra row or two for new items to be inserted into the database. Short of embeddeding scriptlet code to generate the property identifiers (which are in a List), is there a good way to do this? Basically the ideal answer would be to have a way to tell logic:iterate to go for an extra round, with the tag being smart enough to do the needful. tia -Joe table border=1 cellpadding=1 tr thMinimum Purchase/th thCost Per Credit/th thBegin Date/th thEnd Date/th /tr logic:iterate id=item name=creditCost indexId=index type=bb.hibernate.Creditprice trtdhtml:hidden name=item property=id indexed=true / html:text maxlength=5 name=item property=minPurchase size=5 indexed=true //td tdhtml:text maxlength=5 name=item property=creditCost size=5 indexed=true //td tdhtml:text maxlength=10 name=item property=beginDate size=10 indexed=true //td tdhtml:text maxlength=10 name=item property=endDate size=10 indexed=true //td/tr /logic:iterate - 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]
There *has* to be an easy way to do this...
I have a simple iterate in a piece of JSP (snippet follows) that provides an interface inside of an HTML table to modify items that came out of the database. What I want to do is provide an extra row or two for new items to be inserted into the database. Short of embeddeding scriptlet code to generate the property identifiers (which are in a List), is there a good way to do this? Basically the ideal answer would be to have a way to tell logic:iterate to go for an extra round, with the tag being smart enough to do the needful. tia -Joe table border=1 cellpadding=1 tr thMinimum Purchase/th thCost Per Credit/th thBegin Date/th thEnd Date/th /tr logic:iterate id=item name=creditCost indexId=index type=bb.hibernate.Creditprice trtdhtml:hidden name=item property=id indexed=true / html:text maxlength=5 name=item property=minPurchase size=5 indexed=true //td tdhtml:text maxlength=5 name=item property=creditCost size=5 indexed=true //td tdhtml:text maxlength=10 name=item property=beginDate size=10 indexed=true //td tdhtml:text maxlength=10 name=item property=endDate size=10 indexed=true //td/tr /logic:iterate - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SV: Form Validation
Check the Bugzilla. I believe it works in the html:errors tag, but you won't get a javascript popup. If memory serves, there's a security concern about using minlength in password fields -- basically the logic goes something like, Do you really want to be providing a front end validation that tells a cracker how long his randomly guessed password attempts must be. If you *really* want this though, you can just go ahead and modify the javascript you'll find in the validation-rules.xml file. -Original Message- From: Jignesh Patel [mailto:[EMAIL PROTECTED] Sent: Monday, March 15, 2004 5:55 AM To: Struts Users Mailing List Subject: Re: SV: Form Validation I am trying to use min length in javascript for password, but it is not working. I am just wondering why it works for all the fields but not password. Can I have any input. -Jignesh On Monday 15 March 2004 16:14, Nina Bertilsdotter wrote: Sorry, yes, it does extend ValidatorForm : ) -Ursprungligt meddelande- Från: Otto, Frank [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:41 Till: 'Struts Users Mailing List' Ämne: AW: Form Validation Does your form class extend the ValidatorForm? -Ursprüngliche Nachricht- Von: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Gesendet: Montag, 15. März 2004 11:39 An: 'Struts Users Mailing List' Betreff: SV: Form Validation Thanks Budi, but that didn't seem to do the trick either. When I enter 4 (min range is 1900) in the year field I still don't get an error. -Ursprungligt meddelande- Från: Budi Rostiarso [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:31 Till: Struts Users Mailing List Ämne: RE: Form Validation Try putting max arg, because i think range validation must be supplied with min and max (range) value. arg1 name=intRange key=${var:min} resource=false/ arg2 name=intRange key=${var:max} resource=false/ var var-namemin/var-name var-value${minYear}/var-value /var var var-namemax/var-name var-value${maxYear}/var-value /var CMIIW, bdr. -Original Message- From: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Sent: Monday, March 15, 2004 5:25 PM To: 'Struts Users Mailing List' Subject: SV: Form Validation Thank you, Frank, I was indeed missing the validation='true' but that didn't seem to fix my problem... must be something else; I guess I've got to keep digging. Nina -Ursprungligt meddelande- Från: Otto, Frank [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:13 Till: 'Struts Users Mailing List' Ämne: AW: Form Validation Hi Nina, you had to set validation=true in your action definition (struts-config.xml). Regards, Frank -Ursprungliche Nachricht- Von: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Gesendet: Montag, 15. Marz 2004 11:09 An: 'Struts Users Mailing List' Betreff: Form Validation Hi People, I'm pulling my hair out trying to get form validation to work through the validator, any help will be much appreciated. In this example I'm trying to validate a single field (year of type int), should be pretty easy, one might think, but alas, I'm stuck and I can't get it to work. I'm sure it is something simple but I've gone blind from looking at it. Thanks. JSP: html:form action=MyAction.do html:errors/ html:text property=year/ Struts-config: form-beans form-bean name=myForm type=myForm/ /form-beans action path=MyAction type=packageName/MyAction scope=request name=myForm input=myPage.jsp forward name=success path=myPage.jsp/ /action Validation.xml: form name=MyAction field property=year depends=required,integer,intRange arg0 key=MyAction.year/ arg1 name=intRange key=${var:min} resource=false/ var var-namemin/var-name var-value1900/var-value /var /field /form - 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]
Ridiculously simple (I hope) question about url patterns
I'm trying to an application in progress to use a /do/* url pattern instead of a *.do. I'm finding some strange behavior I haven't quite isolated, but the least of it is that each successive mouseclick is prepending an extra /do to the uri portion of the url. Is there something I need to put into the controller portion of struts config to get this to work correctly? TIA -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Tomcat and Aliases
I went thru this myself with Windows and IIS -- If it's a *nix install, you can use a symbolic link. If it's a Windows install (2K) or later, see the following URL about Junctions which are more or less the same thing. http://www.sysinternals.com/ntw2k/source/misc.shtml HTH, Joe -Original Message- From: Eric Dahnke [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 09, 2004 3:24 PM To: 'Struts Users Mailing List' Subject: Tomcat and Aliases I have searched the archives as well as google with no lick. Is the answer use apache? We're running TC in a standalone configuration. Short of putting Apache in front of it, and running mod_jk is there a way in server.xml, web.xml or otherwise to do aliasing like the following httpd.conf entry? Alias /images/ /usr/local/product/images/ Directory /usr/local/product/images Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all /Directory Regards, Eric - 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: Validation help for same Form, multiple pages/tabs
Wendy, I'm not getting something (and it's me being dense I'm sure). It sounds to me like you've found yourself in a position where you are pushing the limits of the validation framework. What would be the problem with biting the bullet and implementing validate() in your ActionForm and calling super.validate(mapping, request) if it was appropriate to hit the xml file for the validation rules? -Joe -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Friday, March 05, 2004 1:24 PM To: Struts Users Mailing List Subject: Validation help for same Form, multiple pages/tabs I'm using the same [dynamic] ActionForm on all my pages. Which was just *fine* until I wanted to use validation. :( I need separate validation per tab which is essentially a forward tag in struts-config. I have a Struts-Menu tab that has fields for fund, function and cost center, which are elements of an account, and I string the bits together later. Another tab has radio buttons where they pick an account. On the first, I need all three fields to be required. But if I do that in validation.xml, then the second page complains that the three fields are required. I understand what's happening, I just don't know the best way to fix it. I'm using 1.2.0, if there's something new that might be of use. I found this, advocating DynaValidatorActionForm http://www.mail-archive.com/[EMAIL PROTECTED]/msg93220.html But it seems to be controlled by the path, which is going to be the same in both cases. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - 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]
[OT] JBulder X users?
I currently use JBuilder 8 Enterprise and I'm eval'ing JBuilder X. Anyone else using X for Struts dev? I'm curious as to your thoughts. Personally, I'm underwhelmed. I so wanted to see the validator framework being leveraged...or even addressed. It's existence is barely acknowledged. Is it my imagination or (with the notable exception of Struts Console, thank you James) does every GUI tool aimed at Faster Struts Development really mean Faster Struts Learning Curve and then just gets in your way once you know what youre doing? (Or worse, replace one learning curve with another -- theirs!) If I'm not alone, I might just consider doing something about it once this project finishes... Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] Looking for junior Java/Struts developers
Herndon is a pretty sweet place. I used to work in Reston, actually on the top floor at Reston Town Center, and that area is tops. It sure does beat this place that I'm at now, hands down! A salary of $50K would be pretty meager living though, especially in that area. You'd most likely have to live elsewhere and commute. I grew up in Reston (and you've made me nauseous by calling it tops! tyvm :- ). I mean, any place that has zoning laws telling you you cannot paint your house the color you want, can fine you for not mowing your lawn, has outlawed street lights and tells McDonalds it cannot have Golden Arches, and that Convience Stores must not face the roads (all in the name of keeping property values up), it a little bit up uptight for me. Anyway, I live in the area still. To give people an idea of price points: Fairfax County VA is a Washington DC suburb and has gone through a huge population growth in the last few years. Something like 1/9 of all the people in the entire state live there. Fairfax is ranked like #3 in the US for median family income, and has housing prices to match. It's no San Francisco, but still pricy. Rent on a nice single family home costing $2000 a month is probably only a little on the pricy side for the area, and certainly isn't outrageous by local standards. What's affordable in the area? Money Magazine recently rated Sugarland Run, a community about 10 miles away in Sterling, VA as being one of the best places to live in the US because it had good schools (by US stds), near Civil War landmarks, more or less reasonable housing prices for the area, and proximity to good employment. TownHomes in this community run about 150-170K, Single Family Homes push 300K and thats after a *significant* run-up in the last few years. On the plus side, you can by a Camry for the low $20K range I believe, and gas (like all places in the states is cheap) cost me $1.69/gal for regular the other day. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Email with file created on the fly
I see an action that uses the JavaMail API in your future. Nice little QuickStart article can be found here: http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-javamail-p1.html -Original Message- From: hhlow [mailto:[EMAIL PROTECTED] Sent: Thursday, January 29, 2004 9:41 PM To: Struts Users Mailing List Subject: Email with file created on the fly How can I send email with a file created on the fly using Struts? Thank you Clement - 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: Validator
I assume your goal is to say If this operation, DON'T use the rules defined in rule_validation.xml? What's in your rule_validation.xml and relevant JSP? Is that your whole validate() method??? Just based on instinct. I suspect the problem may be in the JSP tags vs what errors you are returning. What happens when you change the jsp to have the html:errors / tag instead? -Joe -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 2:08 AM To: 'Struts Users Mailing List' Subject: Validator Hi I have a problem with the validator framework. The procedure I am following is 1. I have code like this in the form public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){ System.out.println( The requested operation is + getOperation() ); if( getOperation().equals( showRuleByStatus) || getOperation().equals( addRule) || getOperation().equals( showRuleDetail) || getOperation().equals( init)){ return new ActionErrors(); } return super.validate( mapping, request ); } 2. My form extends BaseValidatorForm extends ValidatorForm 3. I have plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator-rules.xml, /WEB-INF/rule_validation.xml/ /plug-in in the config. 4. I have bean:message tags and resource properties file which is working. 5. I have html:errors property=errors.required / in the JSP. My error messages never appear if I call any method other than those mentioned in the validate method. What could be the problem ? Mohan - 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]
DynaFormBean property list retrieval
Based upon choices the user makes, he finds himself at a one of four possible screens with fields for him enter. Once he enters his stuff, I take the data and then, using BeanUtils, dump it all into a nicely formatted string and email it. The data all comes in on a DynaValidatorActionForm- All four screens use the same form, just displaying a various subset of the range of possible properties). All four screens send the user into the same action. My problem is that the properties of the dynabean don't come in any logical order. By logical, I don't mean sorted alphabetically or some such. I want them in the order that makes sense for them to appear, which is the order that they appear in my struts-config. The Map returned by form.getMap() doesn't give me what I want. The array of DynaProperties returned by form.getDynaClass.getDynaProperties() isn't in the order I want either. How do I get back what I told struts at config time? Do I need to declare set- properties in struts-config to tell me the order and sort it myself? I'd be surprised if I was the only one with this problem. Ideas? TIA -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DynaFormBean property list retrieval
Scuse me, I *wanted* to use BeanUtils. It doesn't do this though. I've tried two ways of doing this. 1) Getting the keySet from form.getMap() and using an iterator from it to get the corresponding value from the form.getMap() 2) Using the getDynaClass.getDynaProperties() method of my dynaform, and adding each of the DynaProperty.getName()'s into a Vector or List, so I can use the same code from 1) that gets an iterator. The order I get them out seems consistent. Just wrong. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator
Just out of curiosity, what happens with html:errors / if you make this change in your message resources declaration, assuming you haven't already. message-resources null=false ... -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 4:30 AM To: \'Struts Users Mailing List\' Subject: RE: Validator Yes. That is what I am assuming. I tried html:errors / too The other methods are blocked. I can see that. The messages are not appearing though. Mohan -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 1:20 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Validator I assume your goal is to say \If this operation, DON\'T use the rules defined in rule_validation.xml\? What\'s in your rule_validation.xml and relevant JSP? Is that your whole validate() method??? Just based on instinct. I suspect the problem may be in the JSP tags vs what errors you are returning. What happens when you change the jsp to have the html:errors / tag instead? -Joe -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 2:08 AM To: \'Struts Users Mailing List\' Subject: Validator Hi I have a problem with the validator framework. The procedure I am following is 1. I have code like this in the form public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){ System.out.println( \The requested operation is \ + getOperation() ); if( getOperation().equals( \showRuleByStatus\) || getOperation().equals( \addRule\) || getOperation().equals( \showRuleDetail\) || getOperation().equals( \init\)){ return new ActionErrors(); } return super.validate( mapping, request ); } 2. My form extends BaseValidatorForm extends ValidatorForm 3. I have plug-in className=\org.apache.struts.validator.ValidatorPlugIn\ set-property property=\pathnames\ value=\/WEB-INF/validator-rules.xml, /WEB-INF/rule_validation.xml\/ /plug-in in the config. 4. I have bean:message tags and resource properties file which is working. 5. I have html:errors property=\errors.required\ / in the JSP. My error messages never appear if I call any method other than those mentioned in the validate method. What could be the problem ? Mohan - 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]
Re: Validator
Mohan- This means that Struts is unable to find the definition for errors.required in your Message Resources. I suspect it's going to be something on this order. Cant find the file. The Locale it's using isn't the one you specified. Something like that. Based on my experience, I'd suggest double checking that the property file with the messages is actually in the location Struts really thinks it is. HTH -Joe -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 8:08 AM To: 'Struts Users Mailing List' Subject: RE: Validator I see this. ???en_US.errors.required??? ???en_US.errors.required??? ???en_US.errors.required??? ???en_US.errors.required??? I matched bean:message with the JSP and the resource properties and validator.xml. They are all the same. Mohan -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 4:43 PM To: [EMAIL PROTECTED] Subject: RE: Validator Just out of curiosity, what happens with html:errors / if you make this change in your message resources declaration, assuming you haven't already. message-resources null=false ... -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 4:30 AM To: \'Struts Users Mailing List\' Subject: RE: Validator Yes. That is what I am assuming. I tried html:errors / too The other methods are blocked. I can see that. The messages are not appearing though. Mohan -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 1:20 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Validator I assume your goal is to say \If this operation, DON\'T use the rules defined in rule_validation.xml\? What\'s in your rule_validation.xml and relevant JSP? Is that your whole validate() method??? Just based on instinct. I suspect the problem may be in the JSP tags vs what errors you are returning. What happens when you change the jsp to have the html:errors / tag instead? -Joe -Original Message- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Saturday, January 24, 2004 2:08 AM To: \'Struts Users Mailing List\' Subject: Validator Hi I have a problem with the validator framework. The procedure I am following is 1. I have code like this in the form public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){ System.out.println( \The requested operation is \ + getOperation() ); if( getOperation().equals( \showRuleByStatus\) || getOperation().equals( \addRule\) || getOperation().equals( \showRuleDetail\) || getOperation().equals( \init\)){ return new ActionErrors(); } return super.validate( mapping, request ); } 2. My form extends BaseValidatorForm extends ValidatorForm 3. I have plug-in className=\org.apache.struts.validator.ValidatorPlugIn\ set-property property=\pathnames\ value=\/WEB-INF/validator-rules.xml, /WEB-INF/rule_validation.xml\/ /plug-in in the config. 4. I have bean:message tags and resource properties file which is working. 5. I have html:errors property=\errors.required\ / in the JSP. My error messages never appear if I call any method other than those mentioned in the validate method. What could be the problem ? Mohan - 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] - 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: JSP to static html...
I had a requirement like this once, but the reports were generated by Seagate Crystal. It generated the static HTML. JSP seems like the wrong tool to be using here. I would think (speaking out of my hat here) if the report itself was a JSP page what you MAY be able to do is something like, in your action, making an HTTP request yourself to the JSP, receive the HTML that gets generated in response into a text buffer, save it some place, and then send the user to it. If he pushes the button, you have an HTML file you can send him to. It's a complete and utter hack, but hey. - Original Message - From: Jacob Wilson To: Struts Users Mailing List Sent: Friday, January 23, 2004 12:30 PM Subject: JSP to static html... Hi All... I have a specific requirement in my project... I want to convert the JSP pages to static html pages and save them in a local directory... How do I achieve this functionality??? Any suggestions appreciated. Thanks much. -Jacob - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Action to JSP
Craig, I agree with everything you said, but would absolutely love a clarification from you on the following: Other folks will disagree with me on this, of course, but in my general response is show me where the back button and bookmarks window are in a Swing app, and I'll make them available in my web app. :-) I share your philosophy about how web^H^H^H applications should work, but there's a place where this philosophy abandons me. So I respond: If it's supposed to work like a swing app, then get rid of the bookmarks window and back button. Either that or make them unobtrusive. And now you know why I hate Web UI design. :-/ As such, this makes me an utter newb for the more esoteric front end issues involving a browser. So since my pre-struts experience put me mostly on the back end of web applications, what would you say are the best options for dealing with these things (struts or not) in a web application? I mean, I don't care if the back button still exists, but I don't want the user cursing my name every time he presses it without thinking about it. I personally _really_ hate it when this happens to me on my bank's site. TIA, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javax.servlet.ServletException: Exception creating bean of class
To borrow from the title of a movie: Dude, where's my constructor? this is my newitemForm.java newitemForm.java = package net.foong; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; public class newitemForm extends ActionForm { private String itemName; private int quantity; public void setItemName(String itemName) { this.itemName=itemName; } public void setQuantity(int quantity) { this.quantity=quantity; } public String getItemName() { return itemName; } public int getQuantity() { return quantity; } public void reset(ActionMapping mapping, HttpServletRequest request) { this.itemName = null; this.quantity = 0; } } -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please Help - ClassCastException
Not at all. First off, set(String, String) is predefined for you. You don't need to create any of that. In fact, what you will find in a DynaValidatorForm is that your form classes start to get very sparse. Here's really what it could look like. public class PostForm extends BaseDynaForm { public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { // throw new UnsupportedOperationException(Method is not implemented); } public PostForm () { } } In your ActionForm itself, beanUtils would work something like this. All you need is to get the right formBean object. public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PostForm pForm = (PostForm) form; // other code you write here BeanUtils.copyProperties(yourBean, pForm); // etc Doing it yourself without beanUtils? Instead of calling getSender() and having a String returned, you call get (sender) and it will return an Object (cast it yourself to whatever type the sender form property really is). I made a base form class with a getString method that calls get() and does the String cast for me to save the tediom. Making sense now? -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Sunday, January 04, 2004 2:46 AM To: Struts Users Mailing List Subject: RE: Please Help - ClassCastException I am still confused... I have a jsp that provides text fields for user to fill out information. All the information is passed via HttpRequest and to be validated. And all the properties in my PostForm are populated by the information retrieved from those text fields. And my PostForm is of type=org.apache.struts.validator.DynaValidatorForm Therefore, in my PostForm.java, I should do something like this? I just do not think the following code is correct. == import org.apache.struts.validator.DynaValidatorForm; public class PostForm extends DynaValidatorForm { private String receiver; private String sender; public void set(String receiver, String receiver); public void set(String sender, String sender); public String get(String receiver, String receiver); public String get(String sender, String sender); } == And you are saying that in my action class, I should ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.commons.beanutils.BeanUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.artimus.message.PostForm; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.utility.DateUtil; public final class StoreMessage extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int parentPostID; int threadID; String memberName = request.getRemoteUser(); Timestamp now = DateUtil.getCurrentGMTTimestamp(); parentPostID = Integer.parseInt( request.getParameter( parent ) ); ActionForm postForm = ( ActionForm )form; ThreadHandler thandler = new ThreadHandler(); ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); if (parentPostID == 0 ) // new topic { threadBean.setLastPostMemberName( memberName ); threadBean.setThreadCreationDate( now ); . . threadID = thandler.insertThread( threadBean ); } ... ... } } --- Joe Hertz [EMAIL PROTECTED] wrote: Well, first off: In your (dyna) form, you don't create setters and getters for the properties though. With DynaForms you would say set(myPropertyName, myString) instead of calling setMyPropertyName(myString). This is the Dyna part of DynaForms. It's much less tedious IMHO. In your action, you absolutely want to cast the form to PostForm. Otherwise the form variable has no way to know properties are associated with it. So yes, once you cast it to PostForm calls to BeanUtils.copyProperties() can and will work properly. Hope this helps, -Joe -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Sunday, January 04, 2004 1:42 AM To: Struts Users Mailing List Subject: RE
RE: Please Help - ClassCastException
Well, first off: In your (dyna) form, you don't create setters and getters for the properties though. With DynaForms you would say set(myPropertyName, myString) instead of calling setMyPropertyName(myString). This is the Dyna part of DynaForms. It's much less tedious IMHO. In your action, you absolutely want to cast the form to PostForm. Otherwise the form variable has no way to know properties are associated with it. So yes, once you cast it to PostForm calls to BeanUtils.copyProperties() can and will work properly. Hope this helps, -Joe -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Sunday, January 04, 2004 1:42 AM To: Struts Users Mailing List Subject: RE: Please Help - ClassCastException I think that there are a lot more mistakes in my code than I originally thought. The root of the problem is that I do not know how to use DynaValidatorForm. If you could help me in learning how to code when I am working with DynaValidatorForm. 1. in my struts-config.xml, I have: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean 2. My PostForm.java is like: import org.apache.struts.validator.DynaValidatorForm; import org.apache.struts.action.ActionMapping; public class PostForm extends DynaValidatorForm { private String receiver; private String sender; .. public void setReceiver( String receiver ) { this.receiver = receiver; } public void setSender( String sender ) { this.sender = sender; } public String getReceiver() { return receiver; } public String getSender() { return sender; } . . } 3. in my action class (see the code below) 3.1. do I cast the form to DynaActionForm? or I should cast the form to DynaValidatorForm? 3.2. Can I use the copyProperties() method of the BeanUtils to convert the form to a bean? BeanUtils.copyProperties( threadBean, postForm ); ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.struts.action.DynaActionForm; import org.apache.commons.beanutils.BeanUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.artimus.message.PostForm; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.utility.DateUtil; public final class StoreMessage extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int parentPostID; int threadID; String memberName = request.getRemoteUser(); Timestamp now = DateUtil.getCurrentGMTTimestamp(); parentPostID = Integer.parseInt( request.getParameter( parent ) ); DynaActionForm postForm = ( DynaActionForm )form; ThreadHandler thandler = new ThreadHandler(); ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); if (parentPostID == 0 ) // new topic { threadBean.setLastPostMemberName( memberName ); threadBean.setThreadCreationDate( now ); . . threadID = thandler.insertThread( threadBean ); } ... ... } } 4. the action mapping in my struts-config.xml is like: action roles=administrator,editor,contributor path=/message/NewTopic type=org.apache.artimus.message.StoreMessage name=postForm scope=request validate=true input=.message.Form forward name=success path=.article.View/ /action Thank you. --- David Friedman [EMAIL PROTECTED] wrote: Here is what I see (opinions vary)... I see you are defining your form bean in your struts-config.xml as type 'org.apache.struts.validator.DynaValidatorForm'. So, why are you trying to cast it as this 'org.apache.artimus.message.PostForm' class. Does that class extend DynaValidatorForm? If it doesn't, you'll get a ClassCastException like you're getting now. Personally, I expected you to cast it as: DynaValidatorForm postForm = (DynaValidatorForm) form; Or us it as-initially defined (not casting like above) and use BeanUtils such as:
Annoying Validation issue
I am passing in an object my JSP page needs in with request scope. Works fine. I'm also using the Validator, which also, individually, works fine. They however, fight with eachother. Here's how: When you use the validator and put a depends=required on a form's select box, the check isn't caught by the generated javascript. It's caught in the validator's back end logic. This would be fine except that said back end logic has no way to know my JSP page needs some things passed in on the request. I'd like to keep it out of the httpSession if at all possible. Is there a place to tell the validator what it needs to do to generate data the page needs before it tries to send the user back there?? TIA -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: .NET: We are just like Struts... only better.
It was left handed bashing. To paraphrase- Bill was announcing .NET when Struts was only a glimmer in Craig's eye. Microsoft is committed to .NET and therefore .NET is Windows. With Struts/J2EE you are at the mercy of whoever develops the implementation of the Servlet Container, et al, or maybe one day does a bad job, or stops entirely maybe. I chuckled at the 2nd line of thought. Most of us consider this a benefit of J2EE Dev. But it also implies this wasn't potentially a problem with .NET and Windows. To para-paraphrase, We ARE the implementation, therefore however it works it how it works. We dont need no stenking BugZilla. Grunt Grunt. Competition bad.. I didn't notice any bashing going on. I found it to be a pretty good article pointing out high level differences between developing with Struts vs. an ASP.NET approach. From an agnostic approach, it was a pretty good article. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [SPAM] Your Support Question
Yeah, I get it too. Silly me, I just assumed that it was a legitimate company, and some (probably their only one, IMHO) employee sub'd to the struts list and this was some sort of auto-responder for him. I mainly thought this because it didn't look like Spam. Only in the last WEEK has started to solicit business. I've asked them to turn it off at least twice myself. The solicitation got added after that. The attitude appears to be quite clear. -Joe -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Friday, December 19, 2003 1:34 AM To: Struts Subject: [SPAM] Your Support Question Im starting to get more than a little p***d off with these guys. Im getting several unsolicited messages from them everyday asking me to cough up 250 bucks for a 'struts support license'. Anyone else getting spammed by this mob? -Original Message- From: Support Administrator [mailto:[EMAIL PROTECTED] Sent: Friday, 19 December 2003 12:30 To: [EMAIL PROTECTED] Subject: Your Support Question Dear Sir/Ms, Thank you fo your mail. One of our staffers will review your posting and reply to your enquiries within 24 hours. To cure your JSP,Struts and J2EE headaches why not purchase a support license for the new year? Yearly JSP/Struts support licenses start at only $249!!. For further information, please visit http://www.zphinx.com/support.jsp and use the live support link to connect to one of our support operators for an immediate solution to your problems. You can also click http://www.zphinx.com/hcl/lh/live.php?email=x to access our live support system or create a support ticket. Regards, Support Administrator Zphinx Software Solutions http://www.zphinx.com/support.jsp - 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]
Are httpSessions thread safe?
Not sure how OT this question is. My current plan (unless this is bad for some reason, but if so, Ted H should change his example app :-) is to stash the hibernate Session for a user into his httpSession, and reuse it on each request. A Hibernate Session instance isn't threadsafe. I imagine if two really quick http requests got generated out of the same browser, all hell could break out. I guess I want to know if mortals like me need to worry about this. Does Struts (or the Servlet container FAIK) prevent this from occuring, or do I need to ensure this doesn't happen? If so, how? With a token or is there a better strategy? TIA -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Are httpSessions thread safe?
Yuck. And may I say, Yuck, again? It's not the Session object per se, as much as it is the particular attribute I want to store there. It does strike me that the storage of a Hibernate Session in the httpSession is a fairly common thing, so I doubt this bites people very often. It does seem to have the potential to do so. In the real world why is this not too big of a deal? Or should it be considered one? I suppose that unless you've got time consuming requests, or the user hits some button on the browser twice in rapid succession, it's probably okay. A token could effectively prevent this type of condition I suppose. -J -Original Message- From: Kris Schneider [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 11:12 AM To: Struts Users Mailing List Subject: RE: Are httpSessions thread safe? Synchronizing on the session object may cause you all sorts of grief...or it may not. It all depends on your container. The spec makes no guarantees about the identity of the object returned by methods like PageContext.getSession or HttpServletRequest.getSession. For example, here's a test JSP: %@ page contentType=text/plain % % out.println(session: + session); out.println(pageContext.getSession: + pageContext.getSession()); out.println(request.getSession: + request.getSession(false)); out.println(request.getSession: + request.getSession(false)); % Here's the output from TC 4.1.24: session: [EMAIL PROTECTED] pageContext.getSession: [EMAIL PROTECTED] request.getSession: [EMAIL PROTECTED] request.getSession: [EMAIL PROTECTED] And that's just within the same thread! I'm pretty sure TC 4.1.29 does return the same instance, but just remember it's not guaranteed. Quoting Joe Germuska [EMAIL PROTECTED]: At 4:09 PM +0800 12/18/03, Andrew Hill wrote: The sessions essentially just a sort of Map. Access to it may be threadsafe, but the stuff thats in it is another matter entirely. Multiple requests associated with the same session will execute simultaneously. There's nothing in the specs that guarantee threadsafe access to session attributes. A pattern I've become quite fond of is to create a single object (we call it a shell, analogous to an operating system shell) which encapsulates everything you want in session context for a given user; then put just this object into session scope, and use methods on it to do everything else. This helps you apply synchronization where appropriate. There's still a risk of a race condition involving the initial creation of the shell (assuming you do something like check the session to see if there's a value under the key you use for the shell) -- you can put that in a block synchronized on the session object: MyAppShell shell = null; synchronized (session) { shell = (MyAppShell) session.getAttribute(SHELL_KEY); if (shell == null) { shell = new MyAppShell (); session.setAttribute(SHELL_KEY, shell); } } If the shell concept seems like high overhead to you, you can still synchronize accesses on the session object along those lines; you may just have more trouble keeping track of all the places it needs to happen. Joe -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com We want beef in dessert if we can get it there. -- Betty Hogan, Director of New Product Development, National Cattlemen's Beef Association -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.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]
RE: Are httpSessions thread safe?
I saw these. I just had this grand idea of minimizing the Hibernate connections by doing what Ted did in his example -- not actually discarding a user's Hibernate Session until his httpSession expired. I've never messed with ThreadLocals before but I suspect that the attempt to put a ThreadLocal into a httpSession I suspect would be funny to watch. -Original Message- From: Kris Schneider [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 11:45 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Are httpSessions thread safe? Poked aroung on the Hibernate site for a few minutes and found these: http://www.hibernate.org/42.html http://www.hibernate.org/43.html Quoting Joe Hertz [EMAIL PROTECTED]: Yuck. And may I say, Yuck, again? It's not the Session object per se, as much as it is the particular attribute I want to store there. It does strike me that the storage of a Hibernate Session in the httpSession is a fairly common thing, so I doubt this bites people very often. It does seem to have the potential to do so. In the real world why is this not too big of a deal? Or should it be considered one? I suppose that unless you've got time consuming requests, or the user hits some button on the browser twice in rapid succession, it's probably okay. A token could effectively prevent this type of condition I suppose. -J -Original Message- From: Kris Schneider [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 11:12 AM To: Struts Users Mailing List Subject: RE: Are httpSessions thread safe? Synchronizing on the session object may cause you all sorts of grief...or it may not. It all depends on your container. The spec makes no guarantees about the identity of the object returned by methods like PageContext.getSession or HttpServletRequest.getSession. For example, here's a test JSP: %@ page contentType=text/plain % % out.println(session: + session); out.println(pageContext.getSession: + pageContext.getSession()); out.println(request.getSession: + request.getSession(false)); out.println(request.getSession: + request.getSession(false)); % Here's the output from TC 4.1.24: session: [EMAIL PROTECTED] pageContext.getSession: [EMAIL PROTECTED] request.getSession: [EMAIL PROTECTED] request.getSession: [EMAIL PROTECTED] And that's just within the same thread! I'm pretty sure TC 4.1.29 does return the same instance, but just remember it's not guaranteed. Quoting Joe Germuska [EMAIL PROTECTED]: At 4:09 PM +0800 12/18/03, Andrew Hill wrote: The sessions essentially just a sort of Map. Access to it may be threadsafe, but the stuff thats in it is another matter entirely. Multiple requests associated with the same session will execute simultaneously. There's nothing in the specs that guarantee threadsafe access to session attributes. A pattern I've become quite fond of is to create a single object (we call it a shell, analogous to an operating system shell) which encapsulates everything you want in session context for a given user; then put just this object into session scope, and use methods on it to do everything else. This helps you apply synchronization where appropriate. There's still a risk of a race condition involving the initial creation of the shell (assuming you do something like check the session to see if there's a value under the key you use for the shell) -- you can put that in a block synchronized on the session object: MyAppShell shell = null; synchronized (session) { shell = (MyAppShell) session.getAttribute(SHELL_KEY); if (shell == null) { shell = new MyAppShell (); session.setAttribute(SHELL_KEY, shell); } } If the shell concept seems like high overhead to you, you can still synchronize accesses on the session object along those lines; you may just have more trouble keeping track of all the places it needs to happen. Joe -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com We want beef in dessert if we can get it there. -- Betty Hogan, Director of New Product Development, National Cattlemen's Beef Association -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
RE: Are httpSessions thread safe?
I guess creating Hibernate Sessions and Destroying them on every request isn't as bad as I imagine it is? I figured creating the session when the user showed up, destroying it when his httpSession expired, and reconnecting/disconnecting on each request was strictly better. I guess doing this isn't quite worth the effort? No one else seems to mind :) -Joe -Original Message- From: David Erickson [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 12:27 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: Are httpSessions thread safe? That second one actually works great, 43.html. Since each request is running in its own thread it has the possiblity to create a new hibernate session for every request, but it only creates it if you call the getSession method on the filter. And at the end of the request that session is destroyed. -David - Original Message - From: Joe Hertz [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, December 18, 2003 10:20 AM Subject: RE: Are httpSessions thread safe? I saw these. I just had this grand idea of minimizing the Hibernate connections by doing what Ted did in his example -- not actually discarding a user's Hibernate Session until his httpSession expired. I've never messed with ThreadLocals before but I suspect that the attempt to put a ThreadLocal into a httpSession I suspect would be funny to watch. -Original Message- From: Kris Schneider [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 11:45 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Are httpSessions thread safe? Poked aroung on the Hibernate site for a few minutes and found these: http://www.hibernate.org/42.html http://www.hibernate.org/43.html Quoting Joe Hertz [EMAIL PROTECTED]: Yuck. And may I say, Yuck, again? It's not the Session object per se, as much as it is the particular attribute I want to store there. It does strike me that the storage of a Hibernate Session in the httpSession is a fairly common thing, so I doubt this bites people very often. It does seem to have the potential to do so. In the real world why is this not too big of a deal? Or should it be considered one? I suppose that unless you've got time consuming requests, or the user hits some button on the browser twice in rapid succession, it's probably okay. A token could effectively prevent this type of condition I suppose. -J -Original Message- From: Kris Schneider [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 11:12 AM To: Struts Users Mailing List Subject: RE: Are httpSessions thread safe? Synchronizing on the session object may cause you all sorts of grief...or it may not. It all depends on your container. The spec makes no guarantees about the identity of the object returned by methods like PageContext.getSession or HttpServletRequest.getSession. For example, here's a test JSP: %@ page contentType=text/plain % % out.println(session: + session); out.println(pageContext.getSession: + pageContext.getSession()); out.println(request.getSession: + request.getSession(false)); out.println(request.getSession: + request.getSession(false)); % Here's the output from TC 4.1.24: session: [EMAIL PROTECTED] pageContext.getSession: [EMAIL PROTECTED] request.getSession: [EMAIL PROTECTED] request.getSession: [EMAIL PROTECTED] And that's just within the same thread! I'm pretty sure TC 4.1.29 does return the same instance, but just remember it's not guaranteed. Quoting Joe Germuska [EMAIL PROTECTED]: At 4:09 PM +0800 12/18/03, Andrew Hill wrote: The sessions essentially just a sort of Map. Access to it may be threadsafe, but the stuff thats in it is another matter entirely. Multiple requests associated with the same session will execute simultaneously. There's nothing in the specs that guarantee threadsafe access to session attributes. A pattern I've become quite fond of is to create a single object (we call it a shell, analogous to an operating system shell) which encapsulates everything you want in session context for a given user; then put just this object into session scope, and use methods on it to do everything else. This helps you apply synchronization where appropriate. There's still a risk of a race condition involving the initial creation of the shell (assuming you do something like check the session to see if there's a value under the key you
RE: [OT] I didn't know Struts was an antipattern
I read that and my reaction was, It was suggested all of three months ago.. How can the author make a determination as to why it *wasn't* added if no new features have come out since then? Was there some discussion on the dev list he was referring to? Even if he's right, that's a complaint with the underlying design of struts itself, and not with how it's used. -Joe -Original Message- From: Gus Heck [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 5:02 PM To: Struts Users Mailing List Subject: Re: [OT] I didn't know Struts was an antipattern Interesting, I'm not sure I agree, but the patch that he complains about not being added sounds useful... Robert Taylor wrote: A coworker sent me this link and said it was an interesting read. http://today.java.net/pub/a/today/2003/12/11/mvc.html?page=1 Personally I don't think the author put much research into Struts or Java Server Faces (which he doesn't mention at all) before writing this article which has some interesting points and history about MVC, but basically is written to support his new ground breaking Shocks Servlet Framework. robert - 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: Newbie can't get saveErrors() working
My (newbie also) I'd suggest that in your struts-config.xml you mess with the null property for your message resource. message-resources null=true|false parameter=ApplicationResources/ Configured the right way, instead of null results, you'll see what message resource it was trying for. -Original Message- From: Sheldon Hearn [mailto:[EMAIL PROTECTED] Sent: Saturday, December 13, 2003 5:56 AM To: [EMAIL PROTECTED] Subject: Newbie can't get saveErrors() working Hi folks, I'm in love with the validation framework included with Struts. The fact that I can do validation with regular expressions and have client-side JavaScript created for me automatically is fantastic. However, there's one error that I have to catch on the server-side in some cases: an attempt to create a duplicate entity. In this case, I'd like an error message to appear close to the form input for which it applies. So I'm creating an ActionError in my Action and saving it as follows: } catch (DuplicateDomainAliasError e) { ActionErrors errors = new ActionErrors(); ActionError error = new ActionError(error.domainAliasName.exists); errors.add(domainAliasName, error); saveErrors(request, errors); } I have error.domainAliasName.exists in my message bundle: error.domainAliasName.exists=A domain alias with that name already exists. Because domainAliasName is a property of the ActionForm associated with the html:form/ I have in my JSP, I expect the message to be displayed with the following tag: html:errors property=domainAliasName/ However, that tag renders the empty string. Can someone point out what I'm doing wrong here? I can get the error displayed at the top of the page by using declarative exception handling, but the page has a lot of stuff on it, and I'd like the error displayed close to the form input that it relates to. Thanks, Sheldon. - 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: [OT] Beer
Normally I agree. American Laagers are pretty much identical. I've been known to ask what is on tap, hear the list, and then order a pepsi. A Sam Adam's Double Bock however, and I am quite happy. I think Sam Adams at one point claimed to be the only American brewer who exported to Germany. -Original Message- From: Chappell, Simon P [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 10:13 AM To: Struts Users Mailing List Subject: RE: [OT] Beer I still stand by my original assertion: ALL American beer is recycled! Is it any wonder that I quit drinking the stuff when I moved from England to America. -Original Message- From: Ben Anderson [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 9:05 AM To: [EMAIL PROTECTED] Subject: RE: [OT] Beer alright, didn't think I'd need to chime in, but someone's gotta defend the black gold: representing the great city of Pittsburgh: Iron City Beer From: Chappell, Simon P [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: RE: [OT] Beer Date: Fri, 12 Dec 2003 08:57:50 -0600 I think that these replies kinda prove my point! :-) (Notice how no one ever defends American beer!) Simon snip - 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]
Validator for dates
I want to have a date entry validated using the date format based on the locale. When datePattern is unspecified (what Struts in Action led me to believe would accomplish the above goal), I get no javascript validations to happen. With some experimentation, I find that I get no javascript popups when I use datePattern, but I do when I use dataPatternStrict. How does this thing really work? TIA, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator for dates
Okay, so the datePattern issue is a bug. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16810 Is the Locale issue one as well? I can just make a new formset for the languages I'll support. It's not a huge deal, but still, would be nice to know. -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 4:48 PM To: 'Struts Users Mailing List' Subject: Validator for dates I want to have a date entry validated using the date format based on the locale. When datePattern is unspecified (what Struts in Action led me to believe would accomplish the above goal), I get no javascript validations to happen. With some experimentation, I find that I get no javascript popups when I use datePattern, but I do when I use dataPatternStrict. How does this thing really work? TIA, Joe - 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: Validator for dates
Damn, I hate when I keep finding answers right after I post. Not supported in 1.1 -Joe Never Mind - Emily Litella -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 6:07 PM To: 'Struts Users Mailing List' Subject: RE: Validator for dates Okay, so the datePattern issue is a bug. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16810 Is the Locale issue one as well? I can just make a new formset for the languages I'll support. It's not a huge deal, but still, would be nice to know. -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 4:48 PM To: 'Struts Users Mailing List' Subject: Validator for dates I want to have a date entry validated using the date format based on the locale. When datePattern is unspecified (what Struts in Action led me to believe would accomplish the above goal), I get no javascript validations to happen. With some experimentation, I find that I get no javascript popups when I use datePattern, but I do when I use dataPatternStrict. How does this thing really work? TIA, Joe - 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: logic tag using locale
I agree entirely. A pointer bean to the right data in the request. I'm so there. Thanks Ted. YTH -Joe -Original Message- From: Tsang, F (Fred) [mailto:[EMAIL PROTECTED] Sent: Thursday, December 11, 2003 5:06 AM To: Struts Users Mailing List Subject: RE: logic tag using locale Thanks Ted, Doesn't this mean creating another bean/object though? For instance, right now I have two fields in the object that have this sort of requirement (ie. there are about 12 fields that don't have a language requirement). I was thinking it would be more efficient to just let the tile/jsp do the presentation work. You could be right though... maybe a simple presentation bean that just handles internationalised fields. cheers, Fred -Original Message- From: Ted Husted [mailto:[EMAIL PROTECTED] Sent: 10 December 2003 20:04 To: Struts Users Mailing List Subject: Re: logic tag using locale I'd suggest resolving this type of language choice in the Action. For example, there could be one product bean that is populated with whatever language is preferred by the client. The page could then just write whatever has been placed into the bean. HTH, Ted. _ This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing. If this email contains an offer, that should be considered as an invitation to treat. _ - 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: logic tag using locale
I've got a similar problem. You could write a scriptlet function that appended the correct languageCode onto your default property name and use the result of that string in the bean:write tag. Please let me know if you find a more elegant way around this. -Original Message- From: Tsang, F (Fred) [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 10, 2003 10:01 AM To: [EMAIL PROTECTED] Subject: logic tag using locale All, I'm trying to do a bean:write based on the user's current language. Before you ask, this isn't just internationalization using the properties files. I'm displaying item attributes stored in a database, where there are german and english descriptions. I know I can set a bean in my action and access the tag like so: request.setAttribute(currentLanguage, getLocale(request).getLanguage()); logic:equal name=currentLanguage value=en bean:write name=product property=specialFeatures ignore=true / /logic:equal logic:equal name=currentLanguage value=de bean:write name=product property=specialFeaturesDE ignore=true / /logic:equal is there a bean for locale by default which removes the need to set the currentLanguage bean I have above? something like: logic:equal name=userlocale value=en bean:write name=product property=specialFeatures ignore=true / /logic:equal Are there any special beans which have default names? Any help is appreciated. cheers, Fred _ This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing. If this email contains an offer, that should be considered as an invitation to treat. _ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Property Declaration Annoyances
As of JSP 1.1 (and apparently 1.2 as I'm experiencing this with Tomcat 4.x) the following does not work: bean:write name=myBean property=myMap.%=myKey%.myProperty/ One has to declare the entire String and implement it like this: bean:write name=myBean property=%=myString%/ Anyone know if this has changed since 1.2? Is there a better approach? Can EL help me get around this more gracefully? -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Dynamica generation of mapped property names
Is there (now) a better way to dynamically specify a property name than the method outlined here? http://www.mail-archive.com/[EMAIL PROTECTED]/msg21090.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Stupid Bean tricks
Martin- Can you point me to the correct docs for how this works? I don't find anything regarding using maps within beans this way. Tx -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Martin Cooper Sent: Friday, December 05, 2003 3:58 PM To: [EMAIL PROTECTED] Subject: Re: Stupid Bean tricks Assuming your User object is stored in the request under the key user, the language you want is en (English), and the UserData property you want is message, you would do: bean:message name=user property=en.message/ -- Martin Cooper Joe Hertz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] oss.local... I considered that, but (and I'm an utter newbie so I apologize here) How would I refer to an element of UserData in a bean:message tag? -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Martin Cooper Sent: Friday, December 05, 2003 12:32 PM To: [EMAIL PROTECTED] Subject: Re: Stupid Bean tricks Why not convert your Set into a Map keyed by language / locale? Then get(locale) is effectively provided for you. -- Martin Cooper Joe Hertz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] oss.local... Probably a very basic question, and infinitely dealableI hope. I have a User object, which itself contains a Set of UserData objects (the UserData is stuff that needs to be multilingual. Each instance has the part of the user's data that would vary when presented in each language). So, in my JSP, how do I get to a specific instance of UserData? I can write a getter than could take a locale or even just a language code, but since it's not a numeric, the taglib chokes on it, or at least it appears to - 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]
Maps within Beans (was Stupid Bean Tricks)
This example relates how to _implement_ things in your own taglibs. It doesn't mention Maps at all (the part I'm being befuddled by). It's not even specific to struts. Actually, all I need is a reference on usage of the struts taglibs beyond the foo.bar.baz example. I want to see how one can refer to Maps contained in beans like Martin explained: bean:message name=user property=en.message/ I have to admit, I found this confusing also because in my User object (session key as user) there would be a map of UserData objects. The above example doesn't mention userdata at all, so I'm guessing Martin meant this: bean:message name=user property=en.UserData.message/ But in the interest of saving bandwidth, just the reference on how to get to maps within beans. -Original Message- From: Martin Gainty [mailto:[EMAIL PROTECTED] Sent: Sunday, December 07, 2003 10:59 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: Stupid Bean tricks a complete example on how to use this concept is located at http://www.orionserver.com/tutorials/taglibs/8.html viel Glueck, Martin - Original Message - From: Joe Hertz [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Sunday, December 07, 2003 5:58 PM Subject: RE: Stupid Bean tricks Martin- Can you point me to the correct docs for how this works? I don't find anything regarding using maps within beans this way. Tx -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Martin Cooper Sent: Friday, December 05, 2003 3:58 PM To: [EMAIL PROTECTED] Subject: Re: Stupid Bean tricks Assuming your User object is stored in the request under the key user, the language you want is en (English), and the UserData property you want is message, you would do: bean:message name=user property=en.message/ -- Martin Cooper Joe Hertz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] oss.local... I considered that, but (and I'm an utter newbie so I apologize here) How would I refer to an element of UserData in a bean:message tag? -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Martin Cooper Sent: Friday, December 05, 2003 12:32 PM To: [EMAIL PROTECTED] Subject: Re: Stupid Bean tricks Why not convert your Set into a Map keyed by language / locale? Then get(locale) is effectively provided for you. -- Martin Cooper Joe Hertz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] oss.local... Probably a very basic question, and infinitely dealableI hope. I have a User object, which itself contains a Set of UserData objects (the UserData is stuff that needs to be multilingual. Each instance has the part of the user's data that would vary when presented in each language). So, in my JSP, how do I get to a specific instance of UserData? I can write a getter than could take a locale or even just a language code, but since it's not a numeric, the taglib chokes on it, or at least it appears to - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Very Troubled in Finding Ways to Pass a Variable to a Class
Actually, you haven't illustrated it. You've just stated it. In the ActionForm there are methods like validate() that accept as parameters an ActionMapping and an httpServletRequest, and from the httpServletRequest you can call getSession(). Same holds true in the Action class' execute() method. So what is the problem with your class? Why can't you utilize it from one of these places that you do have access to these things? What exactly is stopping you here? Once you tell us, then you will have illustrated the problem. -J -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Saturday, December 06, 2003 1:47 PM To: Struts Users Mailing List Subject: Re: Very Troubled in Finding Ways to Pass a Variable to a Class I know how to pass a hidden field. The problem is how to retrieve it in my Java class. I have illustrated that my Java class does not extend HttpServlet or Action. This Java class has a mapping in the struts-config.xml file: type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm -Caroline --- Timo [EMAIL PROTECTED] wrote: Caroline, The best way I use it to pass parameters to the action class is via a hidden attribute in the form, in your case the articleForm you can define the hidden attribute using input type=hidden name=hiddenField value=%=request.getRemoteUser();%/ Good luck. - Original Message - From: Caroline Jen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 05, 2003 8:17 PM Subject: Very Troubled in Finding Ways to Pass a Variable to a Class I have a class FindEditorData.java. I want to pass a vairable 'username' to this class for some processing. This class is invoked from a JSP: html:form action=/find/Category html:submitView Articles/html:submit and the value of the 'username' is obtained this way: String username = request.getRemoteUser(); Due to my limited knowledge in Struts, I cannot figure out what to do. Let me explain the problem: 1. This class has this method: public Object execute() throws Exception { ... } I do not make this class extends HttpServlet or extends Action. I cannot nest a method inside a doGet/doPost or the Action's excute(). 2. The action mapping in the struts-config.xml is this way: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm validate=false forward name=success path=.article.Result/ /action I am stuck because I do not know how to pass 'username' to the FindEditorData.java. I cannot state: String username = request.getRemoteUser(); or String username = (String)session.getAttribute( EditorName ); because the FindEditorData is not a servlet and does not extend Action. I cannot pass a hidden variable from the JSP because I do not know how to retrieve the value of a hidden variable in a Java class. Need clever ideas. Please help. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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]
RE: Very Troubled in Finding Ways to Pass a Variable to a Class
Actually, you haven't illustrated it. You've just stated it. In the ActionForm there are methods like validate() that accept as parameters an ActionMapping and an httpServletRequest, and from the httpServletRequest you can call getSession(). Same holds true in the Action class' execute() method. So what is the problem with your class? Why can't you utilize it from one of these places that you do have access to these things? What exactly is stopping you here? Once you tell us, then you will have illustrated the problem. -J Apologies if this goes out more than once. I'm having mail weirdness -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Saturday, December 06, 2003 1:47 PM To: Struts Users Mailing List Subject: Re: Very Troubled in Finding Ways to Pass a Variable to a Class I know how to pass a hidden field. The problem is how to retrieve it in my Java class. I have illustrated that my Java class does not extend HttpServlet or Action. This Java class has a mapping in the struts-config.xml file: type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm -Caroline --- Timo [EMAIL PROTECTED] wrote: Caroline, The best way I use it to pass parameters to the action class is via a hidden attribute in the form, in your case the articleForm you can define the hidden attribute using input type=hidden name=hiddenField value=%=request.getRemoteUser();%/ Good luck. - Original Message - From: Caroline Jen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 05, 2003 8:17 PM Subject: Very Troubled in Finding Ways to Pass a Variable to a Class I have a class FindEditorData.java. I want to pass a vairable 'username' to this class for some processing. This class is invoked from a JSP: html:form action=/find/Category html:submitView Articles/html:submit and the value of the 'username' is obtained this way: String username = request.getRemoteUser(); Due to my limited knowledge in Struts, I cannot figure out what to do. Let me explain the problem: 1. This class has this method: public Object execute() throws Exception { ... } I do not make this class extends HttpServlet or extends Action. I cannot nest a method inside a doGet/doPost or the Action's excute(). 2. The action mapping in the struts-config.xml is this way: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm validate=false forward name=success path=.article.Result/ /action I am stuck because I do not know how to pass 'username' to the FindEditorData.java. I cannot state: String username = request.getRemoteUser(); or String username = (String)session.getAttribute( EditorName ); because the FindEditorData is not a servlet and does not extend Action. I cannot pass a hidden variable from the JSP because I do not know how to retrieve the value of a hidden variable in a Java class. Need clever ideas. Please help. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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]
Stupid Bean tricks
Probably a very basic question, and infinitely dealableI hope. I have a User object, which itself contains a Set of UserData objects (the UserData is stuff that needs to be multilingual. Each instance has the part of the user's data that would vary when presented in each language). So, in my JSP, how do I get to a specific instance of UserData? I can write a getter than could take a locale or even just a language code, but since it's not a numeric, the taglib chokes on it, or at least it appears to - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] Athentication filter doesn't filter actions
Why is this necessary? Isn't /*.do a subset of /* ??? -Original Message- From: Ralf Rapude [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 6:28 AM To: Struts Users Mailing List Subject: Re: [OT] Athentication filter doesn't filter actions Hi, just repeat the filter-mapping tag like: filter-mapping filter-nameauthenticationFilter/filter-name url-pattern/*/url-pattern /filter-mapping filter-mapping filter-nameauthenticationFilter/filter-name url-pattern/*.do/url-pattern /filter-mapping Ralf Rapude __ WEB.DE FreeMail wird 5 Jahre jung! Feiern Sie mit uns und nutzen Sie die neuen Funktionen http://f.web.de/features/?mc=021130 - 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: Stupid Bean tricks
I considered that, but (and I'm an utter newbie so I apologize here) How would I refer to an element of UserData in a bean:message tag? -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Martin Cooper Sent: Friday, December 05, 2003 12:32 PM To: [EMAIL PROTECTED] Subject: Re: Stupid Bean tricks Why not convert your Set into a Map keyed by language / locale? Then get(locale) is effectively provided for you. -- Martin Cooper Joe Hertz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] oss.local... Probably a very basic question, and infinitely dealableI hope. I have a User object, which itself contains a Set of UserData objects (the UserData is stuff that needs to be multilingual. Each instance has the part of the user's data that would vary when presented in each language). So, in my JSP, how do I get to a specific instance of UserData? I can write a getter than could take a locale or even just a language code, but since it's not a numeric, the taglib chokes on it, or at least it appears to - 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: .do's come back as 404 file not found
What's the url pattern for your action servlet defined in web.xml? -Original Message- From: Dhaliwal, Pritpal (HQP) [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 1:48 PM To: Struts Users Mailing List Subject: .do's come back as 404 file not found Hello Everyone, I am using: Struts and Resin 2.1.11 All of sudden my index.do, or any other .do is not being recognized by resin anymore. It was working fine two days ago, all of sudden I am getting 404s In the logs I see that its picking up the correct struts-config.xml and it is that ActionServlet runs its init function.. So has anyone seen it before, is it generally app server problem or I could have messed something up in struts also? TIA, Paul Dhaliwal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] IE problem. stumped
IE 5.X and 6.0 are very different beasts. 6.0 in some ways is *less* compliant with the specs then 5.2. -Original Message- From: Jarnot Voytek Contr AU HQ/SC [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 1:59 PM To: 'Struts Users Mailing List' Subject: RE: [OT] IE problem. stumped -Original Message- From: Prabhat Kumar (IT) [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 12:57 PM To: [EMAIL PROTECTED] Subject: [OT] IE problem. stumped I'm wondering if anyone has come across this. We have this struts application that is about to be deployed and it works fine, shows all the HTML pages as expected in IE 6.0. As part of our final tests, we began testing the application on IE 5.01 SP1. This is where the application gets all messed up. Text gets displayed all over the page very randomly. We used HTML tables to layout pages and format content. Thoughts? Two thoughts, try this: http://validator.w3.org/ and do this sort of testing earlier in your lifecycle... -- Voytek Jarnot Quantum materiae materietur marmota monax si marmota monax materiam possit materiari? - 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: Validator Backend Issues
David, Yes it does. Thank you. I wanted to use the DynaActionValidatorForm (ow! Ow! Ow! :-) because I do want it validated off of the Action, but when I saw the formName property, I didn't want to lie to it on general principles. Tx again. -Original Message- From: David Friedman [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 2:03 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Validator Backend Issues Joe, Nope. I was writing to you about that but you found your solution faster than I could type (my poor aching fingers at 2AM!). When you said your 'formName=UserLoginForm', that suggests you're keying off the action's ActionForm name 'name='UserLoginForm' for your validation. That's why you would use DynaValidatorForm. Using DynaValidatorActionForm is just like a DynaValidatorForm with one exception: it validates of the name of the action. So if your action is called /edit.do, it would need a form name of '/edit' such as: form name=/edit field ... ... /field /form I also got stuck on this when I first started using the Struts Validator. I hope this explanation helps. Regards, David -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 2:07 AM To: 'Struts Users Mailing List' Subject: RE: Validator Backend Issues Curious. Changing the ActionForm from a DynaValidatorActionForm to a DynaValidatorForm gets me backend validation. Have I just stumbled onto a bug? -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 1:46 AM To: 'Struts Users Mailing List' Subject: Validator Backend Issues I'm probably misunderstanding this woefully. Hope someone can set me straight. For my login, I'm using a UserLoginForm class that extends DynaValidatorActionForm. The Action class is an extension of DispatchAction (it handles all User related actions). If in my Login.jsp, I remove the html:javascript formName=UserLoginForm/ tag,I get no javascript validations happening, which I would expect, but I also find that I *never* get any back end validation checks happening. Nothing shows up where the html:errors / tag was. Is there something I have to do to get the validator to do it's magic outside of the client? -Joe - 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]
Struts Developed Sites and Google
URL's with session state information will cause search engines problems in trying to index the content. (Makes sense -- the generated URLs wont be valid for anyone else). Google isn't about to store cookies as it indexes content, I'm sure. So doesn't this make Struts a poor choice for developing a site when Search Engine visibility is important? As I understand it, if your client doesn't support cookies, you will get a jsessionid in your urls, which is the embodiment of the above scenario. Am I mistaken? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Password Validation MinLength not checked, not going to be?
Depends=required,minlength doesn't work (despite the example in SIA and all over the net now...). According to http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19595 this bug is marked as WontFix as Password fields are deliberately not checked in this way for security reasons Should I interpret this as declarative that any javascript validation of a password length is inherently insecure I have a hard time believing that given javascript supports this in the language. People keep submitting this one, obviously not getting it (like me!). What's the logic here?? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Password Validation MinLength not checked, not going to be?
Of course, right after I send it, I find the updated bug report under Commons Validator, still open: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23652 -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Sunday, November 23, 2003 6:55 AM To: 'Struts Users Mailing List' Subject: Password Validation MinLength not checked, not going to be? Depends=required,minlength doesn't work (despite the example in SIA and all over the net now...). According to http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19595 this bug is marked as WontFix as Password fields are deliberately not checked in this way for security reasons Should I interpret this as declarative that any javascript validation of a password length is inherently insecure I have a hard time believing that given javascript supports this in the language. People keep submitting this one, obviously not getting it (like me!). What's the logic here?? - 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: DynaValidator can't get validation to work
Marc, I'm doing largely the same thing as you are and having a bit more success, but not complete success. Some thoughts: 1) Are you *really* sure that validator.xml is loading? Your depends=required,minLength makes me wonder since the identifier is really minlength. 2) I can't get minLength to work for password fields at all. Yes, it's not supposed to generate javascript for it (so BugZilla says), but I don't even get a backend validation error. (Anyone able to explain this???) 3) dynamic=true is deprecated. You using struts 1.1? 4) Put an html:errors / tag on the page at least to test with for now. If the JS works, at least you'll know that youre not going crazy. I'm using Hibernate too. I'm using a DispatchAction for all User related stuff, but otherwise, what I'm doing looks a lot like yours. Email me offline and we can compare notes. -Joe -Original Message- From: M.Schipperheyn [mailto:[EMAIL PROTECTED] Sent: Sunday, November 23, 2003 5:29 PM To: [EMAIL PROTECTED] Subject: RE: DynaValidator can't get validation to work Still problems. I have used the debugger to step through the chain of events. In org.apache.commons.validator.Validator in the validate method at line 577, it returns null for the form. As far as I can see, this means that it doesn't get any validation rules for the form from the framework. I also noticed that some locale issues with the validator were reported on Bugzilla . My locale is nl (for the Netherlands). Could this be it? I tried adding the locale and country variables to my formset key in validator.xml. To no avail. Any ideas? I'm getting a bit desperate here. Kind regards, Marc - 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: Hibernate plugin
I got it working when I started with the struts-hibernate example that Ted Husted wrote. Used the plugin from it. I believe JNDI is avoided entirely with it. I get some Hibernate SessionFactory Errors on startup occasionally, but they stopped me cold. Fix the addClass() calls here, but otherwise, it goes a little bit like this: package struts; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import net.sf.hibernate.HibernateException; import net.sf.hibernate.MappingException; import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.cfg.Configuration; import org.apache.struts.action.ActionServlet; import org.apache.struts.action.PlugIn; import org.apache.struts.config.ModuleConfig; /** * Initialize the Hibernate SessionFactory for this project * as an application scope object. * * @author Ted Husted * @version $Revision: 1.3 $ $Date: 2003/03/14 21:59:41 $ */ public class HibernatePlugIn implements PlugIn { /** * A field to store the reference to our SessionFactory. * Can close and dispose if not null. */ private SessionFactory sf; /** * A public identifer for the persistence session, * kept in servlet session (client) scope * [HIBERNATE_SESSION]. */ public static String SESSION = HIBERNATE_SESSION; /** * A public identifer for the session factory, * kept in application (global) scope * [HIBERNATE_SESSION_FACTORY]. */ public static String SESSION_FACTORY = HIBERNATE_SESSION_FACTORY; /** * Fetch the SessionFactory from application scope. * @param request The requeste we are servicing * @return The SessionFactory for this application session * @throws HibernateException */ public static SessionFactory sessionFactory(HttpServletRequest request) throws HibernateException { Object sf = request.getSession().getServletContext().getAttribute(SESSION_FACTORY); if (null == sf) { throw new HibernateException(SESSION_FACTORY); } return (SessionFactory) sf; } /** * Open a new session with the application-scope SessionFactory. * Session is not retained, only returned. * * @param request The requeset we are servicing * @return An open session * @throws HibernateException */ public static Session open(HttpServletRequest request) throws HibernateException { return sessionFactory(request).openSession(); } /** * Open a new Session and cache it in the HttpSession or * fetch the existing Session. * * @param request The requeset we are servicing * @return An open session * @throws net.sf.hibernate.HibernateException if session cannot be instantiated */ public static Session reconnect(HttpServletRequest request) throws HibernateException { Session s = (Session) request.getSession(true).getAttribute(SESSION); if (null != s) { s.reconnect(); } else { s = open(request); request.getSession().setAttribute(SESSION, s); } return s; } /** * Expire the Session, to ensure fresh data or to switch approaches. * * @param request The requeset we are servicing * @return An open session * @throws net.sf.hibernate.HibernateException if session cannot be instantiated */ public static void expire(HttpServletRequest request) throws HibernateException { HttpSession httpSession = request.getSession(); if (null!=httpSession) { Session s = (Session) httpSession.getAttribute(SESSION); if (null != s) { s.close(); httpSession.removeAttribute(SESSION); } } } /** * The classes with mappings to add to the Configuration are enumerated here. * There should be a ${class}.hbm.xml mapping file for each class * stored with each compiled class file. * p * To complete the Hibernate setup, there must be a valid hiberate.properties * file under the classes folder (root of the classpath), * which specifies the details of the database hookup. * p * The mapping documents and properties file is all that Hibernate requires. * p * A JDBC Driver is not included in this distribution and *must* be * available on your server's or container's classpath * (e.g., the Tomcat common/lib directory). * * @return A Configuration object * @throws net.sf.hibernate.MappingException if any the mapping documents can be rendered. */ private static final Configuration createConfiguration() throws MappingException { return new Configuration() .addClass(bb.hibernate.Eyecolorcode.class)
Validator Backend Issues
I'm probably misunderstanding this woefully. Hope someone can set me straight. For my login, I'm using a UserLoginForm class that extends DynaValidatorActionForm. The Action class is an extension of DispatchAction (it handles all User related actions). If in my Login.jsp, I remove the html:javascript formName=UserLoginForm/ tag,I get no javascript validations happening, which I would expect, but I also find that I *never* get any back end validation checks happening. Nothing shows up where the html:errors / tag was. Is there something I have to do to get the validator to do it's magic outside of the client? -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hibernate plugin
Scuse me. I typoed. I meant to say, Havent shut me down cold. The happen, and I'd like to know why, but for now, I'm not complaining. The reason I didn't go to the Hibernate site (don't laugh too loud) is that I had problems getting the one from the hibernate site to work too, and there are things in the struts hibernate example that 1) Need it and 2) I don't feel confident enough to mess with. Specifically, it uses a DispatchAction class, but defines execute() to do all of it's hibernate related stuff (again, which I don't feel I understand terribly well). I scratch my head every time I see this. Why would you have execute in a DispatchAction? Does it get called before you do super.execute()? I'd prefer to go to the one from Hibernate if I knew what I was doing better :-/ -Original Message- From: David Friedman [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 1:27 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Hibernate plugin Shh I don't think I've ever seen any Hibernate errors on startup using the code from the Hibernate site. And it works fine accessing it either through JNDI or a Servlet attribute named SESSION_FACTORY_KEY. :) http://www.hibernate.org/105.html Regards, David -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 1:29 AM To: 'Struts Users Mailing List' Subject: RE: Hibernate plugin I got it working when I started with the struts-hibernate example that Ted Husted wrote. Used the plugin from it. I believe JNDI is avoided entirely with it. I get some Hibernate SessionFactory Errors on startup occasionally, but they stopped me cold. Fix the addClass() calls here, but otherwise, it goes a little bit like this: package struts; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import net.sf.hibernate.HibernateException; import net.sf.hibernate.MappingException; import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.cfg.Configuration; import org.apache.struts.action.ActionServlet; import org.apache.struts.action.PlugIn; import org.apache.struts.config.ModuleConfig; /** * Initialize the Hibernate SessionFactory for this project * as an application scope object. * * @author Ted Husted * @version $Revision: 1.3 $ $Date: 2003/03/14 21:59:41 $ */ public class HibernatePlugIn implements PlugIn { /** * A field to store the reference to our SessionFactory. * Can close and dispose if not null. */ private SessionFactory sf; /** * A public identifer for the persistence session, * kept in servlet session (client) scope * [HIBERNATE_SESSION]. */ public static String SESSION = HIBERNATE_SESSION; /** * A public identifer for the session factory, * kept in application (global) scope * [HIBERNATE_SESSION_FACTORY]. */ public static String SESSION_FACTORY = HIBERNATE_SESSION_FACTORY; /** * Fetch the SessionFactory from application scope. * @param request The requeste we are servicing * @return The SessionFactory for this application session * @throws HibernateException */ public static SessionFactory sessionFactory(HttpServletRequest request) throws HibernateException { Object sf = request.getSession().getServletContext().getAttribute(SESSION_ FACTORY); if (null == sf) { throw new HibernateException(SESSION_FACTORY); } return (SessionFactory) sf; } /** * Open a new session with the application-scope SessionFactory. * Session is not retained, only returned. * * @param request The requeset we are servicing * @return An open session * @throws HibernateException */ public static Session open(HttpServletRequest request) throws HibernateException { return sessionFactory(request).openSession(); } /** * Open a new Session and cache it in the HttpSession or * fetch the existing Session. * * @param request The requeset we are servicing * @return An open session * @throws net.sf.hibernate.HibernateException if session cannot be instantiated */ public static Session reconnect(HttpServletRequest request) throws HibernateException { Session s = (Session) request.getSession(true).getAttribute(SESSION); if (null != s) { s.reconnect(); } else { s = open(request); request.getSession().setAttribute(SESSION, s); } return s; } /** * Expire the Session, to ensure fresh data or to switch approaches. * * @param request The requeset we are servicing * @return An open
RE: Validator Backend Issues
Curious. Changing the ActionForm from a DynaValidatorActionForm to a DynaValidatorForm gets me backend validation. Have I just stumbled onto a bug? -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 1:46 AM To: 'Struts Users Mailing List' Subject: Validator Backend Issues I'm probably misunderstanding this woefully. Hope someone can set me straight. For my login, I'm using a UserLoginForm class that extends DynaValidatorActionForm. The Action class is an extension of DispatchAction (it handles all User related actions). If in my Login.jsp, I remove the html:javascript formName=UserLoginForm/ tag,I get no javascript validations happening, which I would expect, but I also find that I *never* get any back end validation checks happening. Nothing shows up where the html:errors / tag was. Is there something I have to do to get the validator to do it's magic outside of the client? -Joe - 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]
requiredif NULL doesn't seem to work.
Anyone see anything wrong with this validation.xml snippet? I have 3 fields on my login page. User Id, Email Address and PW. I want to allow the user to enter *either* his email address or user id. (okay, I'm not stopping him from entering both yet. It seems my attempt to say this field is requiredif the other field is null doesn't work at all. Basically, I've decided that this is *not* a job for the validator framework because it's too complex for a requiredif (which I think is kinda sad actually. This shouldn't be that tough), but I'm still curious why the simple case fails. My next question: Any idea on when Struts 1.2 comes out with requiredWhen? Apologies if this has been asked before. -Joe form name=UserLoginForm field property=userId depends=requiredif arg0 key=UserLogin.userId.label / var var-namefield[0]/var-name var-valueemailAddress/var-value /var var var-namefieldTest[0]/var-name var-valueNULL/var-value /var /field field property=emailAddress depends=requiredif arg0 key=UserLogin.emailAddress.label / var var-namefield[0]/var-name var-valueuserId/var-value /var var var-namefieldTest[0]/var-name var-valueNULL/var-value /var /field field property=password depends=required, minlength varvar-nameminlength/var-name var-value5/var-value /var arg0 key=UserLogin.password.label / /field /form - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Still no reply for :Problem in grouping using logic iterate logic equal
Your doing a bean:write of the team name inside of your iterate, so yeah, the team name is going to show up on every iteration. What approaches have you tried already? Which is the part your not getting? -Original Message- From: Shakti [mailto:[EMAIL PROTECTED] Sent: Saturday, November 22, 2003 4:11 AM To: Struts Users Mailing List Subject: Still no reply for :Problem in grouping using logic iterate logic equal Hi, MyTeamFormBean contains an arraylist allTeams having MyTeamRowBean with attributes : String teamName, first, middle last logic:iterate id=myteam name=myTeamFormBean property=allTeams tr td Bbean:write name=myteam property=teamName //B/td tdnbsp;/td /tr tr tdnbsp;/td tdnbsp;bean:write name=myteam property=Firstname/nbsp;bean:write name=myteam property=Midinitial/nbsp;bean:write name=myteam property=Lastname/ /td /tr /logic:iterate Which produces something like this Team Name 1 Firstname1 1 Midinitial1 1 Lastname 1 1 Team Name 1 Firstname1 2 Midinitial1 2 Lastname 1 2 Team Name 1 Firstname1 3 Midinitial1 3 Lastname 1 3 Team Name 2 Firstname2 1 Midinitial2 1 Lastname 2 1 Team Name 2 Firstname2 2 Midinitial2 2 Lastname 2 2 Team Name 2 Firstname2 3 Midinitial2 3 Lastname 2 3 Team Name 3 Firstname3 1 Midinitial3 1 Lastname 3 1 Team Name 3 Firstname3 2 Midinitial3 2 Lastname 3 2 Team Name 3 Firstname3 3 Midinitial3 3 Lastname 3 3 Team Name 4 Firstname4 1 Midinitial4 1 Lastname 4 1 Team Name 4 Firstname4 2 Midinitial4 2 Lastname 4 2 Team Name 4 Firstname4 3 Midinitial4 3 Lastname 4 3 Team Name 5 Firstname5 1 Midinitial5 1 Lastname 5 1 Team Name 5 Firstname5 2 Midinitial5 2 Lastname 5 2 Team Name 5 Firstname5 3 Midinitial5 3 Lastname 5 3 but i want something like this. .. Team Name 1 Firstname1 1 Midinitial1 1 Lastname 1 1 Firstname1 2 Midinitial1 2 Lastname 1 2 Firstname1 3 Midinitial1 3 Lastname 1 3 Team Name 2 Firstname2 1 Midinitial2 1 Lastname 2 1 Firstname2 2 Midinitial2 2 Lastname 2 2 Firstname2 3 Midinitial2 3 Lastname 2 3 Team Name 3 Firstname3 1 Midinitial3 1 Lastname 3 1 Firstname3 2 Midinitial3 2 Lastname 3 2 Firstname3 3 Midinitial3 3 Lastname 3 3 Team Name 4 Firstname4 1 Midinitial4 1 Lastname 4 1 Firstname4 2 Midinitial4 2 Lastname 4 2 Firstname4 3 Midinitial4 3 Lastname 4 3 Team Name 5 Firstname5 1 Midinitial5 1 Lastname 5 1 Firstname5 2 Midinitial5 2 Lastname 5 2 Firstname5 3 Midinitial5 3 Lastname 5 3 can anyone plz help me out in this ... Thanks in advance .. Shakti.. - 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]
Struts-validator.dtd, or why lame newbie questions happen.
Struts in Action says to copy struts-validator.dtd into WEB-INF. Couldn't find it. So I checked Manning's site for errata to this (since it was beta at the time) like the book suggested. Nothing. So I googled (imagine!). This changed since in the final release, to be part of struts-html.tld, did it not? If so, can errata get posted to Manning's site? I tried to report it on Author Online, but couldn't reach it. See, without newbies like me, what would you guys do? :-) -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts-validator.dtd, or why lame newbie questions happen.
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, November 21, 2003 5:02 AM To: [EMAIL PROTECTED] Subject: Re: Struts-validator.dtd, or why lame newbie questions happen. So I googled (imagine!). This changed since in the final release, to be part of struts-html.tld, did it not? As I understand it is in org.apache.struts.resources and it is called validation_1_1.dtd So why you have to copy in WEB-INF? Do not use books without thinking about it! I think the point is that, wherever it wound up, the usual config brought it along for the ride, but you raise an interesting point -- does validator-rules.xml need to go there (again like the book said) or are you saying that's wrong too? One way or another, errata is needed. I think youre mistaken about something though. Without googling, reading a book, or asking here, what set of thoughts would have made that particular factoid clear to a new struts user? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JBuilder Servlet path issue
I'm using JBuilder 8 Enterprise and Tomcat 4.1. Whenever you use JB to build a servlet application, it defaults to building the project such that the root directory is named after the project itself. This is especially annoying in struts as I'm finding I need to name all my actions /projectname/ActionMappingName.do Anyone have experience with how to get JBuilder to let me have the root tree for my web app, or if there is a way to make a generic prefix for my ActionMappings? TIA, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to create an error message with a filter
Suggestion: In your filter, stick the current timestamp as an attribute in the httpSession. Before you do that though, check the timestamp that got stuck there on the last request. If the delta threshold, bounce the user to the right page. If you *really* wanted, you could generate an ActionError inside of the filter I suppose, so the login page displays the reason he wound up there, but I've never tried that, and my newbie self kind of shudders at that. -Joe -Original Message- From: Arne Brutschy [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2003 4:11 AM To: [EMAIL PROTECTED] Subject: how to create an error message with a filter Hello, I want to create a error message with my authentication filter. The filter checks for an idle timeout. If this occours, it invalidates the session. At this point, the filter should create a error message, i.e. you have been idle for too long!. After that the filter redirects to the login jsp (as always if the session is not valid). The jsp page should use the common struts tags, to display this error message. How can I do this? how can I store such a message in my request? How can I forward that to my redirect? Regards, Arne - 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: JBuilder Servlet path issue (solved)
Figured out how to get at the Default WebApp. And IDE's were supposed to makes things intuitive... -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2003 4:07 AM To: [EMAIL PROTECTED] Subject: JBuilder Servlet path issue I'm using JBuilder 8 Enterprise and Tomcat 4.1. Whenever you use JB to build a servlet application, it defaults to building the project such that the root directory is named after the project itself. This is especially annoying in struts as I'm finding I need to name all my actions /projectname/ActionMappingName.do Anyone have experience with how to get JBuilder to let me have the root tree for my web app, or if there is a way to make a generic prefix for my ActionMappings? TIA, Joe - 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: JBuilder Servlet path issue (solved)
The directory JBuilder makes is named after the WebApp, (which isn't necessarily the project name, but it was for me (and probably your colleague). The WebApp Name is actually optional. RightClick on the node for the WebApp, select properties, clear out the name field and press the Okay Button. (For a new WebApp, just don't name it to begin with) You'll see node for the WebApp in the project tree will now say Default WebApp instead of the name you had before. The behavior will be what you expect. I'm glad it wasn't such a newbie question after all. I kinda felt like an ACE Certified Mechanic who couldn't get the hood opened. -J -Original Message- From: James Neville [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2003 4:56 AM To: Struts Users Mailing List Subject: Re: JBuilder Servlet path issue (solved) Joe, If you have any tips on how to configure this, I have a colleague experiencing the same issue. Personally, i'm using IDEA... no problems here ;) Thanks in advance, James. Joe Hertz wrote: Figured out how to get at the Default WebApp. And IDE's were supposed to makes things intuitive... -Original Message- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2003 4:07 AM To: [EMAIL PROTECTED] Subject: JBuilder Servlet path issue I'm using JBuilder 8 Enterprise and Tomcat 4.1. Whenever you use JB to build a servlet application, it defaults to building the project such that the root directory is named after the project itself. This is especially annoying in struts as I'm finding I need to name all my actions /projectname/ActionMappingName.do Anyone have experience with how to get JBuilder to let me have the root tree for my web app, or if there is a way to make a generic prefix for my ActionMappings? TIA, Joe - 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]
RE: Large scale Internationalization using struts
The problems/questions I can see are: As a single textfile is used, when there are several thousand entries it will become difficult to manage. Can updates be made, during operation, to the content ? What happens if a user requests the files content while it is being edited ? Why would a large web site be configured such that maintenance happened in such a fashion?? Is the textfile cached for performance, or will concurrent calls compete for the same file-resource ? I would *think* it's loaded at servlet.init() time, but that's me guessing. Like you say, for performance reasons, I'd kind of hope so. Should be easy enough to test. As I'm probably not the first person who is trying to use Struts on a larger scale for internationalization issues I thought someone might have a better solution. Suggestions ? In this case, you shouldn't be putting everything into one file. I'd be creating message bundles that corresponded to various sections of the web site. If nothing else, it's easy on the CM System if you've got a lot of developers. -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Utter Newbie Question
I'm making using struts for more or less than first time. I read the FAQ on how to handle logins to an application and I'm left with one question: Why stop a storing a Boolean in the session to determine logged-inness? Why not just store the (validated) User object in the session and check for it's presence? That way, if it's there, one can utilize the data in the User object for whatever sordid little purpose said developer comes up with. Is this a good idea? If so, how do I go about doing this in the view? (I told you I was a newbie!). I mean using bean:write tags of the User object seems straightforward enough, but what about the List of Children objects that is part of the User object? TIA -Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]