Hi,
I am trying to upgrade from Tapestry 5.3 to 5.4 and I encountered a problem
with built-in mixin Autocomplete.
It is quite useful if the mixin takes effect just if some condition is met. So
I have implemented a custom mixin by subclassing the built-in one.
Here is the important snippet of code:
public class ConditionalAutocomplete extends Autocomplete
{
@Parameter(name = "test", required = true, allowNull = false, defaultPrefix
= BindingConstants.PROP)
private boolean enabled;
...
@Override
protected void configure(final JSONObject config)
{
super.configure(config);
if (!enabled)
{
config.put("frequency", 365 * 24 * 60 * 60); // fire an Ajax
request after the "ethernity" elapses
config.put("minChars", 1000000000); // at least "infinity"
characters must be entered to fire an Ajax request
}
}
...
}
I admit that disabling the feature by setting frequency and minChars to
ethernity and infinity is somewhat tricky and can be considered as dirty. On
the other hand, I have achived the required feature by reusing the existing
built-in mixin with all its features.
The mixing can be used in a template file like this:
<t:textfield value="userEmail" t:mixins="conditionalAutocomplete"
test="userAutocompleteSupported"/>
The built-in mixin Autocomplete seems to be rewritten in Tapestry 5.4 and there
is no method configure anymore.
Is there any chance to implement the ConditionalAutocomplete with Tapestry 5.4?
I can copy the code of Autocomplete.java and make some changes in it instead of
subclassing. However, I am trying to find some better solution as such copying
can cause troubles in next Tapestry upgrade.
Thanks for help.
Jarda
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]