Back Forum Reply New

RC4 nightly changes with forms

I just upgraded to RC4 nightly from RC3 and I have noticed that in all the FormAction implementations, I can no longer override methods like bind and setupForm. Is there any reason for this? What is the proposed methodology if I can no longer override those methods?

Thanks,
Grant

Grant,
Would you mind posting your RC3 code? I'd like to assess it.  I admit we are still debating the decision to mark those final--but am leaning that way. Simply put, overriding action methods is discouraged (particularly those FormAction methods, as it's been a common source of bugs here) and we'd recommend overriding an explict hook method if possible. I need to see the code to see if a suitable hook exists for what you need to do.
Keith

Keith, you might be right but changing the API between two RCs are not good. Would you mind scheduling this for the next version rather in the current release cycle?

What I've done is basically created a custom method for each of the methods that became final. So for example:Code:lt;view-state id=quot;configureProductInventoryquot; view=quot;configureProductInventoryLandingquot;gt;       lt;entry-actionsgt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;setupFormquot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;dolceSetupFormquot;/gt;       lt;/entry-actionsgt;       lt;transition on=quot;submitquot; to=quot;addItemToCartquot;gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;bindquot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;dolceBindquot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;validatequot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;processSubmitquot;/gt;       lt;/transitiongt;       lt;transition on=quot;submitAndContinueShoppingquot; to=quot;addItemToCartquot;gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;bindquot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;dolceBindquot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;validatequot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;processSubmitquot;/gt;lt;action bean=quot;configureOrderLineFormActionquot; method=quot;setFinalRedirectquot;/gt;       lt;/transitiongt;   lt;/view-stategt;
For example, I need to do some specific binding for my form before validation. One such example is:Code:
// before we bind, let's check to see if we are customizing individually so we can add the proper       // number of OrderLine objects to: formBindingIndividuallyCustomizedOrderLines       String qty = requestContext.getRequestParameters().get(quot;totalOrderLineQuantityquot;);       String isCustomizingIndividually = requestContext.getRequestParameters().get(quot;isCustomizingIndividuallyquot;);
       if ( _logger.isDebugEnabled() )       {_logger.debug(quot;#### quot; + quot;Is customizing individually: quot; + isCustomizingIndividually);       }
       if ( StringUtils.hasText(qty) amp;amp; StringUtils.hasText(isCustomizingIndividually) )       {int qtyNum = Integer.parseInt(qty);
for ( int i = 0; i lt; qtyNum; i++ ){    if ( _logger.isDebugEnabled() )    {        _logger.debug(quot;#### quot; + quot;adding order line to form binding customized order linesquot;);    }    orderLine.getFormBindingIndividuallyCustomizedOrderLines().add(new OrderLine());}
requestContext.getConversationScope().put(quot;orderLinequot;, orderLine);       }
Basically, I need to create an OrderLine object on the fly because the page uses dynamic HTML allowing customers to customize a product with qty gt; 1 individually. Each individual customized qty is represented as a unique orderline object.. Orderline is what is bound to the form as the model object which is fine when I decide not to customize individually on that particular page. In any case, I have many situations where I have some information on the form page that I need to do specific binding checks before validation. Another example is credit card numbers, I display them XXXX5409 but I still want to validate the card number is validate on submit so I have to do a check to see if the user actually changed the form by removing the XXXX and resetting the actual credit card number for validation from the form.

I've solved all the issues with the API now using final however. If you see better solutions I'm all ears  Sometime's it is hard to know the subtleties of choosing one methodology over another is in Spring Web Flow. (example: render-actions versus entry-actions) or the various scopes and how that affects visibility, hibernate lazy loading, etc.

Thanks!! and I look forward to the official RC4!

With your credit card example, one solution might be to have quot;creditCardquot; as a property on your form object of type String.  An attached FormAction.validator could then do the credit card number validation against that property on validate or bindAndValidate.  This way you customize via the strategy--the validator, instead of via subclassing.

The OrderLine example seems more complicated, but it might be worth experimenting pushing that logic into your form object as much as possble instead of the FormAction itself.  For example, you could bind your quanity and total information to it then have it create the necessary related objects perhaps.

Keith
¥
Back Forum Reply New