[
https://issues.apache.org/jira/browse/TAP5-2752?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17899079#comment-17899079
]
Ben Weidig commented on TAP5-2752:
----------------------------------
Hi [~lrein], I did a small test case and see the behavior you're describing.
The condition
{code:java}
!(dataModel.getPropertyNames().contains(TapestryInternalUtils.extractIdFromPropertyExpression(paginationModel.getSortColumnId())))
{code}
is doing it the wrong way, as the property names in the {{dataModel}} still
contain the name with the dot. but {{sortColumnId}} is already without it.
However, I'd argue that there shouldn't be properties with dots in their name
to begin with, even though it was allowed/working beforehand,
as the PropertyModel sanitizes the name, which leads to the issue.
If you use the {{addExpression(String, String)}} on the
{{{}BeanModelSource{}}}, the added column is sortable.
Nevertheless, switching the {{BeanModel}} sort to work with the
{{PropertyModel#id}} instead of the property name might fix the issue and
support using property expressions without explicit property names.
[~thiagohp]: Thoughts?
> A Grid doesn't sort if sorting column cointans a dot in the PropertyModel of
> the Grid.
> ---------------------------------------------------------------------------------------
>
> Key: TAP5-2752
> URL: https://issues.apache.org/jira/browse/TAP5-2752
> Project: Tapestry 5
> Issue Type: Bug
> Components: tapestry-core
> Affects Versions: 5.8.2
> Reporter: LRein
> Assignee: Ben Weidig
> Priority: Minor
> Labels: easyfix
>
> A Grid doesn't sort if the sorting column contains a dot in the PropertyModel
> of the Grid.
> This BUG was introduced by fixing an issue TAP5-2689.
> This actual Code always returns an empty list for columns with a dot within
> the property name:
> {code:java}
> if ((paginationModel == null || paginationModel.getSortColumnId() == null)
> ||
> !(dataModel.getPropertyNames().contains(TapestryInternalUtils.extractIdFromPropertyExpression(paginationModel.getSortColumnId()))))
> {return Collections.emptyList();}
> {code}
> The correct code was something like that:
> {code:java}
> if (paginationModel == null || paginationModel.getSortColumnId() == null
> || dataModel.getPropertyNames().stream().noneMatch(x ->
> TapestryInternalUtils.extractIdFromPropertyExpression(x).equals(paginationModel.getSortColumnId())))
> {
> return Collections.emptyList();
> }
> {code}
> {code:java}
> public class A
> {
> public B b;
> }
> public class B
> {
> public name;
> }
> public class C
> {
> public BeanModel<A> getGridModel()
> {
> final BeanModel<A> model =
> beanModelSource.createDisplayModel(A.class, messages);
>
> model.include();
> model.add("b.name").sortable(true);
> return model;
> }
> }
> {code}
> Sorting on column "name" is not working because the property name includes a
> dot.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)