Struts "Legacy" Forms
Though Calyxo Action Forms are easier to use, there may be reasons to keep using the Struts HTML tags and form beans.
This might be the case if you're migrating from the Struts Validator to Calyxo Forms. It would be an extra effort to migrate your JSP pages to use Calyxo Forms' form/input tags. Or, you may depend on a special feature offered by some Struts tag, or...
Thus, we provide "legacy" action forms to be used with the Struts tag library, located in package de.odysseus.calyxo.struts.forms.legacy. There are two flavours of action form base classes:
- Simple forms – the classes SimpleActionForm and SimpleDynaActionForm are drop-in replacements for action form classes in existing applications.
- Flushable forms – the classes FlushableActionForm and FlushableDynaActionForm are intended for use in new projects, that want to stay with the Struts form/input tag library.
Simple Action Forms
Let's continue with the migration scenario. Consider you have an application which validates inputs by hand or uses the Struts Validator. Now, you would like to use Calyxo Forms to validate your forms. The migration path is short and simple 1-2-3 procedure:
- Create your forms configuration file(s). Please, read the Calyxo Forms documentation to learn about that. The form names in the forms configuration correspond to form names in your Struts configuration.
- Make your form beans subclasses of SimpleActionForm. Or, if you're using DynaForms, derive from SimpleDynaActionForm. You may also want to remove hand-coded validation code, that will now be covered by validation rules.
- Load the Calyxo Forms for Struts Plugin as described in the configuration section.
You're done. Note, that you don't have to touch any action classes and JSP files!
The simple action forms have been designed for the "Enhance an existing application with minimal change effort" scenario. Thus, they do not need to offer things, that aren't available when using plain action forms or the Struts validator. In particular, committing form properties in a simple action form has no effect.
The major drawback of Struts action forms in general is, that they don't maintain a valid state. Thus, after an action form has once been populated with invalid data, this data will be shown again if the user navigates back to a page containing the form. Ugly!
Flushable Action Forms
The flushable action forms fix this. They are to be used with the Struts tags and keep validated form inputs for you.
Why are flushable forms called flushable? Flushable forms store committed form properties in a map. The Calyxo Forms component is able to format these values back into strings, that are to be displayed in the HTML form elements. However, the Struts tags pull their values out of the form bean properties, which still contain the unformatted input strings. So, when we flush our form, we format back our form data and re-populate the form bean properties. That way, we synchronize our view with the valid values. When redisplaying the form, these values will appear in a standard, localized format.
Flushing a form is triggered by the <flush> tag, provided by the Calyxo Struts component. The tag has to be placed inside a Struts form tag, before any input elements:
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns:calyxo="http://calyxo.odysseus.de/jsp/struts"
xmlns:html="http://struts.apache.org/tags-html">
<html:form method="POST" action="/foo">
<calyxo:flush/>
Enter a number
<html:text property="number"/>
<html:submit/>
</html:form>
</jsp:root>


