I wrote a component which inherited Image component to generate a random
number, and I want the number generated set to a outgoing parameter (named
value), the source code like this:
public abstract class MagicCodeImage extends Image {
@InjectObject("service:tapestry.asset.AssetSource")
public abstract AssetSource getAssetSource();
private Random random = new Random();
private DecimalFormat formatter = new DecimalFormat("0000");
public abstract void setValue(String value);
private String magic;
public IAsset getImage() {
magic = getRandomNumber();
setValue(magic);
String path = "magic:" + magic;
return getAssetSource().findAsset(getLocation().getResource(), path,
Locale.getDefault(), getLocation());
}
private String getRandomNumber() {
int number = random.nextInt(10000);
return formatter.format(number);
}
}
This worked fine with T4-beta3, but after I upgrade it to beta10, the value
parameter is always null. Why?
BTW: In beta10, IComponent.getProperty(String) deprecated, comment say we
should use PropertyUtils.read instead, but the old behavior of getProperty
is to read a property named after jwc file. For example, if I have a
parameter defined as following:
<parameter name="value" property="magicCode">
<description>
The generated magic code.
</description>
</parameter>
then getProperty("value") will return getMagicCode() result. But in the new
way, I can't do this, I must read(component, "magicCode") instead. It seems
no way to get the old behavior back.