Re: Struts1 forms with empty Strings
Dave Newton [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Andy [EMAIL PROTECTED] wrote: I was wondering if there is a way to configure Struts1 so Form beans return null values instead of empty String values when a user does not enter data in a text field, for example. The problem is that Hibernate then saves empty Strings to the database instead of nulls. I would like to configure something globally if possible. I don't know if this is possible without writing some code, like a request processor; hopefully somebody else knows more. The issue is that a text field on a form returns an empty string, not null: that's an HTTP thing, not Struts specifically. You could also configure Hibernate data types that convert an empty string in to null and handle the problem on the Hibernate side; if you're using the Hibernate code anywhere else it might be more useful to do it that way, but it's borderline magic and might be confusing down the road. Dave A filter that intercepts the request and removes all parameters with empty values should do the trick. I have used a similar filter to trim all the reqest parameters of white space rather than doing it in the form bean setter methods. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator does not validate!
Ramon Xuriguera i Albareda [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks but, it doesn't work either... Any other ideas? I have worked with an earlier version of the Struts validator and found that the failure mode when there was a syntax error in validation.xml for a particular field was that the field always passed validation (container was OC4J) I'd suggest you add the dtd reference to you validation.xml and validate it somehow - one way is to use the Ant validate task. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logic:iterate how to test the 1st and last iteration ?
piloupy GOTTAPIL [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, What I want to do is quite simple. I'd like to know how to test in a logic:iterate when I'm at the first or last iteration. My present problem is to parse a collection of String and display the results like this : ### CODE : begin ### value1, value2, value3 ### CODE : end ### And as you can see, for the last iteration, I mustn't displey the comma character. My present code is : ### CODE : begin ### logic:iterate id=e name=myCollection bean:write name=e property=name /, /logic:iterate ### CODE : end ### Thanks in advance :) piloupy how about using the length and offset attributes like so: !--display first item of list with no comma-- logic:iterate id=e name=myCollection length=1 bean:write name=e property=name / /logic:iterate !--display remaining items of list with a comma and space prepended to each-- logic:iterate id=e name=myCollection offset=1 , bean:write name=e property=name / /logic:iterate - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]