Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In short, instead of specifying the types found in collections and maps as documented in Type Conversion, the collection's generic type is used. This means you most likely don't need any ClassName-conversion.properties files.

*NOTE:
This is a work in progress and not yet finished! More compex examples will follow. For now, have a look at the unit tests with the xwork-tiger project path.*

Type Conversion Annotations


Anchor
TypeConversion
TypeConversion

TypeConversion

Parameter

Required

Default

Notes

property

no

 

The optional property name used within TYPE or PACKAGE level annotations.

type

no

ConversionType.CLASS

Enum value of ConversionType. Determines whether the conversion should be applied at application or class level.

converter

yes

 

The class of the TypeConverter to be used as converter.

rule

no

ConversionRule.PROPERTY

Enum value of ConversionRule. The ConversionRule can be a property, a Collection or a Map.

Example:

Code Block
java
java

@Conversion()
public class ConversionAction implements Action {

    private String convertInt;

    private String convertDouble;

    private List users = null;

    private HashMap keyValues = null;

    @TypeConversion(type = ConversionType.APPLICATION, converter = XWorkBasicConverter.class)
    public void setConvertInt( String convertInt ) {
        this.convertInt = convertInt;
    }

    @TypeConversion(converter = XWorkBasicConverter.class)
    public void setConvertDouble( String convertDouble ) {
        this.convertDouble = convertDouble;
    }

    @TypeConversion(rule = ConversionRule.COLLECTION, converter = String.class)
    public void setUsers( List users ) {
        this.users = users;
    }

    @TypeConversion(rule = ConversionRule.MAP, converter = BigInteger.class)
    public void setKeyValues( HashMap keyValues ) {
        this.keyValues = keyValues;
    }

    @TypeConversion(type = ConversionType.APPLICATION, property = "java.util.Date", converter = XWorkBasicConverter.class)
    public String execute() throws Exception {
        return SUCCESS;
    }
}

Validation Annotations

If you want to use annotatin based validation, you have to annotate the class or interface with Validation Annotation.

...

...


Anchor
RequiredFieldValidator
RequiredFieldValidator

...