Re: Prepopulating forms & validation
Apologies Erik, its not in this version...maybe the next one. Niall - Original Message - From: "Erik Weber" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, July 12, 2004 10:44 PM Subject: Re: Prepopulating forms & validation > Awesome! Inheritance in, or parameterizing of, the Validator plugin, > will be the last step in getting a CRU (no D) use case finished the > *right* way (hopefully). This is with declarative validation, > declarative exception handling, an action layer, a business layer and a > data access layer (architect demanded these layers), as well as full use > of Struts HTML tags for all forms, and some use of bean and logic tags, > plus I wrote a PlugIn for combo box value arrays and a pluggable > validator extension to do some "twofields" matching, and finally learned > how to do conditional validation with requiredif. Oh, and of course the > "static" content is all pulled from i18n-able properties files. Total > time to learn Struts from scratch, set up JBoss, MySQL, CVS and get this > use case working: Three weeks. > > Not too shabby eh? I'm sold on Struts, but the docs need to be revised, > revised and revised some more! Maybe someday I'll have time to contribute. > > The only thing I have done redundantly is check for "loggedin-ness", but > I will soon refactor that with a Servlet filter methinks. > > Thanks to all on this list who have helped! Can't wait till the clients > ask for the site in Spanish! > > Erik > > - > 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: Prepopulating forms & validation
Sorry, you're right its not in this version - I've been living under that misconception for weeks now. Niall - Original Message - From: "Hubert Rabago" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, July 12, 2004 10:33 PM Subject: Re: Prepopulating forms & validation > I wanted to ask about this. The javadoc of Validator's Form.inherit field ( > http://jakarta.apache.org/commons/validator/apidocs/org/apache/commons/validator/Form.html#inherit > ) has it marked as "Since Validator 1.2.0", so I was thinking the inheritance > feature wasn't included yet. Do you know if this is the case? > > Hubert > > --- Niall Pemberton <[EMAIL PROTECTED]> wrote: > > The version of commons validator (1.1.3 I think) that comes with the > > recently released Sruts 1.2.1 beta allows you to inherit from another form > > definition using the extends attribute > > > > Niall > > > > - Original Message - > > From: "Erik Weber" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Monday, July 12, 2004 10:09 PM > > Subject: Re: Prepopulating forms & validation > > > > > > > Thanks a lot! I no doubt will find that very useful. > > > > > > I have another question for the group at large: > > > > > > I am now using the same form successfully for adds and updates. I am > > > using the Validator plugin for validation, which I find to be pretty > > > awesome. The problem I face though is, the fields I need to validate are > > > slightly different between add and update conditions. > > > > > > For example, when I add, there is a "disclaimer" checkbox that *must* be > > > checked. When I update, there is no longer any checkbox. I am trying to > > > share the element in validation.xml, obviously, because the form > > > itself is (almost) the same. So the problem is that sometimes I need > > > "required", and sometimes not, for this checkbox field. > > > > > > Because of one or two fields being different between add and update > > > forms, I fear I'll have to do a nearly-redundant (and very long) > > > element for my update condition in validation.xml. Does anyone have a > > > better solution? > > > > > > Thanks, > > > Erik > > > > > > > > > > > > Rick Reumann wrote: > > > > > > > On Mon, 12 Jul 2004 12:22:11 -0400, Erik Weber > > > > <[EMAIL PROTECTED]> wrote: > > > > > > > >> Using BeanUtils.copyProperties(), it's a piece of cake to update > > > >> your Form bean from the ValueObject properties. > > > >> > > > >> Do you have an example of this, or is there one on your site? I > > > >> indeed have some properties that are the same between form bean and > > > >> VO, but some are not (for example my form beans use only Strings, > > > >> but my VOs use some booleans, ints, etc.) > > > > > > > > > > > > Sorry was busy so unable to keep up with this thread. > > > > > > > > No, the types can all be different. BeanUtils will convert them for > > > > you, so your formBean can have all Strings (some would argue it > > > > should only be all Strings anyway) and your VO obviously will have > > > > different types. To copy the properties from your VO to your form > > > > bean it's as simple as: > > > > > > > > import org.apache.commons.beanutils.BeanUtils; > > > > > > > > BeanUtils.copyProperties(youFormBean, yourVO); > > > > > > > > If you are dealing with java.util.Dates you'll have one other thing to > > > > do (register a converter for your app) but I can explain that more if > > > > you need to go that route. > > > > > > > > > > - > > > 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!? > Yahoo! Mail is new and improved - Check it out! > http://promotions.yahoo.com/new_mail > > - > 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: Prepopulating forms & validation
Awesome! Inheritance in, or parameterizing of, the Validator plugin, will be the last step in getting a CRU (no D) use case finished the *right* way (hopefully). This is with declarative validation, declarative exception handling, an action layer, a business layer and a data access layer (architect demanded these layers), as well as full use of Struts HTML tags for all forms, and some use of bean and logic tags, plus I wrote a PlugIn for combo box value arrays and a pluggable validator extension to do some "twofields" matching, and finally learned how to do conditional validation with requiredif. Oh, and of course the "static" content is all pulled from i18n-able properties files. Total time to learn Struts from scratch, set up JBoss, MySQL, CVS and get this use case working: Three weeks. Not too shabby eh? I'm sold on Struts, but the docs need to be revised, revised and revised some more! Maybe someday I'll have time to contribute. The only thing I have done redundantly is check for "loggedin-ness", but I will soon refactor that with a Servlet filter methinks. Thanks to all on this list who have helped! Can't wait till the clients ask for the site in Spanish! Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Prepopulating forms & validation
I wanted to ask about this. The javadoc of Validator's Form.inherit field ( http://jakarta.apache.org/commons/validator/apidocs/org/apache/commons/validator/Form.html#inherit ) has it marked as "Since Validator 1.2.0", so I was thinking the inheritance feature wasn't included yet. Do you know if this is the case? Hubert --- Niall Pemberton <[EMAIL PROTECTED]> wrote: > The version of commons validator (1.1.3 I think) that comes with the > recently released Sruts 1.2.1 beta allows you to inherit from another form > definition using the extends attribute > > Niall > > - Original Message - > From: "Erik Weber" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > Sent: Monday, July 12, 2004 10:09 PM > Subject: Re: Prepopulating forms & validation > > > > Thanks a lot! I no doubt will find that very useful. > > > > I have another question for the group at large: > > > > I am now using the same form successfully for adds and updates. I am > > using the Validator plugin for validation, which I find to be pretty > > awesome. The problem I face though is, the fields I need to validate are > > slightly different between add and update conditions. > > > > For example, when I add, there is a "disclaimer" checkbox that *must* be > > checked. When I update, there is no longer any checkbox. I am trying to > > share the element in validation.xml, obviously, because the form > > itself is (almost) the same. So the problem is that sometimes I need > > "required", and sometimes not, for this checkbox field. > > > > Because of one or two fields being different between add and update > > forms, I fear I'll have to do a nearly-redundant (and very long) > > element for my update condition in validation.xml. Does anyone have a > > better solution? > > > > Thanks, > > Erik > > > > > > > > Rick Reumann wrote: > > > > > On Mon, 12 Jul 2004 12:22:11 -0400, Erik Weber > > > <[EMAIL PROTECTED]> wrote: > > > > > >> Using BeanUtils.copyProperties(), it's a piece of cake to update > > >> your Form bean from the ValueObject properties. > > >> > > >> Do you have an example of this, or is there one on your site? I > > >> indeed have some properties that are the same between form bean and > > >> VO, but some are not (for example my form beans use only Strings, > > >> but my VOs use some booleans, ints, etc.) > > > > > > > > > Sorry was busy so unable to keep up with this thread. > > > > > > No, the types can all be different. BeanUtils will convert them for > > > you, so your formBean can have all Strings (some would argue it > > > should only be all Strings anyway) and your VO obviously will have > > > different types. To copy the properties from your VO to your form > > > bean it's as simple as: > > > > > > import org.apache.commons.beanutils.BeanUtils; > > > > > > BeanUtils.copyProperties(youFormBean, yourVO); > > > > > > If you are dealing with java.util.Dates you'll have one other thing to > > > do (register a converter for your app) but I can explain that more if > > > you need to go that route. > > > > > > > - > > 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!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Prepopulating forms & validation
On Mon, 12 Jul 2004 17:09:41 -0400, Erik Weber <[EMAIL PROTECTED]> wrote: Because of one or two fields being different between add and update forms, I fear I'll have to do a nearly-redundant (and very long) element for my update condition in validation.xml. Does anyone have a better solution? Oh sorry I replied to soon. Yea this is a problem. I suggested a long time ago that you should be able to 'extend' other validation xml definitions. Not sure if that was ever worked on by anyone or not, but that would be nice. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Prepopulating forms & validation
The version of commons validator (1.1.3 I think) that comes with the recently released Sruts 1.2.1 beta allows you to inherit from another form definition using the extends attribute Niall - Original Message - From: "Erik Weber" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, July 12, 2004 10:09 PM Subject: Re: Prepopulating forms & validation > Thanks a lot! I no doubt will find that very useful. > > I have another question for the group at large: > > I am now using the same form successfully for adds and updates. I am > using the Validator plugin for validation, which I find to be pretty > awesome. The problem I face though is, the fields I need to validate are > slightly different between add and update conditions. > > For example, when I add, there is a "disclaimer" checkbox that *must* be > checked. When I update, there is no longer any checkbox. I am trying to > share the element in validation.xml, obviously, because the form > itself is (almost) the same. So the problem is that sometimes I need > "required", and sometimes not, for this checkbox field. > > Because of one or two fields being different between add and update > forms, I fear I'll have to do a nearly-redundant (and very long) > element for my update condition in validation.xml. Does anyone have a > better solution? > > Thanks, > Erik > > > > Rick Reumann wrote: > > > On Mon, 12 Jul 2004 12:22:11 -0400, Erik Weber > > <[EMAIL PROTECTED]> wrote: > > > >> Using BeanUtils.copyProperties(), it's a piece of cake to update > >> your Form bean from the ValueObject properties. > >> > >> Do you have an example of this, or is there one on your site? I > >> indeed have some properties that are the same between form bean and > >> VO, but some are not (for example my form beans use only Strings, > >> but my VOs use some booleans, ints, etc.) > > > > > > Sorry was busy so unable to keep up with this thread. > > > > No, the types can all be different. BeanUtils will convert them for > > you, so your formBean can have all Strings (some would argue it > > should only be all Strings anyway) and your VO obviously will have > > different types. To copy the properties from your VO to your form > > bean it's as simple as: > > > > import org.apache.commons.beanutils.BeanUtils; > > > > BeanUtils.copyProperties(youFormBean, yourVO); > > > > If you are dealing with java.util.Dates you'll have one other thing to > > do (register a converter for your app) but I can explain that more if > > you need to go that route. > > > > - > 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: Prepopulating forms & validation
On Mon, 12 Jul 2004 17:09:41 -0400, Erik Weber <[EMAIL PROTECTED]> wrote: I am now using the same form successfully for adds and updates. I am using the Validator plugin for validation, which I find to be pretty awesome. The problem I face though is, the fields I need to validate are slightly different between add and update conditions. Use the ValidatorActionForm and validate on the Action name, not the form name. Useful for just that reasons you've desscribed. You can have different validation set up for the updateAction vs the insertAction. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Prepopulating forms & validation
Thanks a lot! I no doubt will find that very useful. I have another question for the group at large: I am now using the same form successfully for adds and updates. I am using the Validator plugin for validation, which I find to be pretty awesome. The problem I face though is, the fields I need to validate are slightly different between add and update conditions. For example, when I add, there is a "disclaimer" checkbox that *must* be checked. When I update, there is no longer any checkbox. I am trying to share the element in validation.xml, obviously, because the form itself is (almost) the same. So the problem is that sometimes I need "required", and sometimes not, for this checkbox field. Because of one or two fields being different between add and update forms, I fear I'll have to do a nearly-redundant (and very long) element for my update condition in validation.xml. Does anyone have a better solution? Thanks, Erik Rick Reumann wrote: On Mon, 12 Jul 2004 12:22:11 -0400, Erik Weber <[EMAIL PROTECTED]> wrote: Using BeanUtils.copyProperties(), it's a piece of cake to update your Form bean from the ValueObject properties. Do you have an example of this, or is there one on your site? I indeed have some properties that are the same between form bean and VO, but some are not (for example my form beans use only Strings, but my VOs use some booleans, ints, etc.) Sorry was busy so unable to keep up with this thread. No, the types can all be different. BeanUtils will convert them for you, so your formBean can have all Strings (some would argue it should only be all Strings anyway) and your VO obviously will have different types. To copy the properties from your VO to your form bean it's as simple as: import org.apache.commons.beanutils.BeanUtils; BeanUtils.copyProperties(youFormBean, yourVO); If you are dealing with java.util.Dates you'll have one other thing to do (register a converter for your app) but I can explain that more if you need to go that route. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]