Sebastiaan van Erk <sebster <at> sebster.com> writes:
>
> Hi,
>
> Just wondering if it was possible to accomplish this somehow:
>
> <at> Meta("my-array={ string1, string2 }")
> public abstract class TestPage extends BasePage {
>
> <at> InjectMeta("my-array")
> public abstract String[] getMyArray();
>
> ...
> }
>
> At the moment it complains that it cannot coerce to a String[] because
> it does not have an appropriate ValueConverter. Since the logic for
> parsing arrays from strings like that is surely lying around somewhere,
> shouldn't this be relatively simple to add?
You can add a contribution like:
<contribution configuration-id="ListConverters">
<converter
class="java.lang.String"
object="instance:StringToListConverter" />
</contribution>
Then define a class StringToListConverter implementing TypeConverter to
convert a comman separated string into a List. Of course, you should
expect a List instead of an array:
public abstract class TestPage extends BasePage {
@InjectMeta("my-list")
public abstract List getMyList();
}
Do you consider this simple? If not, you may just do it like this:
public abstract class TestPage extends BasePage {
@InjectMeta("my-array")
public abstract String getMyArrayAsString();
public List getMyArray() {
//call getMyArrayAsString() and convert it to a list.
}
}
--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]