question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TemplateRenderer.withProperty overwrites previous property definition

See original GitHub issue

I have a grid with several columns, each column is generated by a TemplateRenderer. The grid instance itself is initialized from a polymer template.

Two of these columns are referring to properties of the same type (Person). To keep the details (like the person’s role) out of the template, the properties are both put with the name person into the template. The result of this is, that the second declaration overwrites the first one.

For me this behavior is intransparent, since I define the property at the renderer instance and not the grid and would therefore expect some local scope.

So request is, that properties defined for a TemplateRenderer should be available only in this instance and do not overwrite other renderer instances. If this is not possible due to technical reasons, then the property definition should be moved away from the TemplateRenderer to the Grid (or some other instance within the grid wide scope).

Grid column definition

@Id("grid")
private Grid<Project> projectGrid;

@PostConstrcut
private void init() {
    // ... 
    projectGrid.addColumn(TemplateRenderer.<Project>of("<div>[[item.person.name]]</div>").withProperty("person", Project::getDeliveryLead));
    projectGrid.addColumn(TemplateRenderer.<Project>of("<div>[[item.person.name]]</div>").withProperty("person", Project::getAccountManager)); // this overrides the previous set "deliveryLead" 
// ...
}

Beans

public class Project {
    private Person deliveryLead;
    private Person accountManager;
    // ...
}

public class Person {
     private String name;
     // ...
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
jcgueriaud1commented, Oct 8, 2019

Got the same problem. If you have 2 TemplateRenderer with the same property (like value), sometimes it will show the first one, sometimes the second one.

It’s pretty hard to debug it in a project. (especially in Java it fetches the correct values)

To avoid this, I used a uuid string, so my property is unique.

Should this be documented somewhere?

2reactions
heruancommented, Jul 13, 2020

@pleku I understand that “in the future the TemplateRenderer is going to be replaced” but I hope this future is very close since AFAIK TemplateRenderer is the only alternative to ComponentRenderer which does not slow down the grid (see https://vaadin.com/blog/using-the-right-r).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grid | Using Vaadin Components | Flow | Vaadin 14 Docs
By using a sort property, you can override or customise the property or multiple properties that are used for sorting the column. This...
Read more >
How to overwrite property definition properties in a class ... - IBM
Go to "Properties Definitions" tab, highlight the property definition and click ... steps below to overwrite the property definition in a document class...
Read more >
Content area - under the hood part I - Geta Digital
Everything starts with property definition on content data: ... From the technical perspective ContentArea property is still just an ...
Read more >
java - How to overwrite one property in .properties without ...
The Properties API doesn't provide any methods for adding/replacing/removing a property in the properties file. The model that the API supports is to...
Read more >
ClientSidePage.Overwrite Property (OfficeDevPnP.Core ...
In this article. Definition; Applies to. Defines whether the page can be overwritten if it exists. C# Copy. public bool Overwrite { get;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found