[
https://issues.apache.org/jira/browse/TAP5-2099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15157686#comment-15157686
]
Barry Books commented on TAP5-2099:
-----------------------------------
This is still an issue in 5.4. The question is what should happen when a
literal or a symbol is provided to a Component parameter and then something
tries to update it. Currently both literal and symbol extend AbstractBinding
which throws an exception when it's set method is called. I think both of these
bindings should override the default set method with a method that does
nothing. In the case of something like this
@Parameter(BindingConstants.SYMBOL + ":" +
ComponentParameterConstants.GRID_ROWS_PER_PAGE)
private int rowsPerPage;
There is no purpose in informing the symbol provider that something has written
the field it's value is assigned to and the property should not be read only
just because a constant has been assigned to it.
The following code overrides symbol and demonstrates this:
public static void contributeBindingSource(MappedConfiguration<String,
BindingFactory> configuration,
final SymbolSource symbolSource) {
configuration.override(BindingConstants.SYMBOL, new
BindingFactory() {
@Override
public Binding newBinding(String description,
ComponentResources container, ComponentResources component,
final String expression, final Location
location) {
return new AbstractBinding(location) {
@Override
public void set(Object value) {
}
@Override
public Object get() {
return
symbolSource.valueForSymbol(expression);
}
};
}
});
}
> Update parameters bound to literal: or symbol: from a mixin
> -----------------------------------------------------------
>
> Key: TAP5-2099
> URL: https://issues.apache.org/jira/browse/TAP5-2099
> Project: Tapestry 5
> Issue Type: Improvement
> Affects Versions: 5.3.6
> Reporter: Lance
> Labels: bulk-close-candidate
> Attachments: TAP52099-1.patch
>
>
> Currently, I cannot update a component component parameter that is
> initialized with a literal: or symbol: binding from a mixin. If I try to
> @BindParameter the param and change it's value, I get a "Binding %s is
> read-only" exception (originating from AbstractBinding).
> I propose that literal and symbol bindings are sourced from a PerThreadValue
> that can be updated by a mixin.
> My original need for this was to create a "SinglePage" mixin for the Grid
> component which would set the rowsPerPage parameter to Integer.MAX_VALUE. I
> can't currently do this because by default, the parameter is a symbol:
> binding.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)