Hi,

Thanks for your reply!

Currently I did implement it in the second way you explained, but I wasn't too happy with it...

I like your other suggestion, that way I can move the code cleanly to a reusable utility class and my Page class won't have any clutter nor will it have to change when Tapestry itself get this kind of feature (or at worst the format of the annotation will have to change).

Finally, I know that Tapestry can parse arrays though (it does so with the parameters of the DirectLink class), so I'd rather not duplicate this code myself (new bugs, etc.), and use that... I was wondering if it is possible to use that without having to write a wrapper class (just using XML)...

Greetings,
Sebastiaan

Kent Tong wrote:
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to