Get actual entity inside click listener callback.
See original GitHub issueHi. Spent a lot of time to find a way to get clicked entity inside clickListener callback. Have the following code
@Override
protected void buildModels(final List<Item> items) {
for (Item item : items) {
new ListItemViewModel()
.id(item.getId())
.name(item.getName())
.clickListener()
.addTo(this);
}
}
public interface OnItemClickListener {
void onItemClick(Item clickedItem);
}
I’ve tried to use just item from cycle, but as I noticed this entity cached somewhere and if it changes it’s state I still receive “old” entity with not actual fields. Is there any way to receive clicked item? Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Chapter 6. Entity listeners and Callback methods
A callback method is a no-arg method with no return type and any arbitrary name. An entity listener has the signature void <METHOD>(Object)...
Read more >Access current user in entity lifecycle callback - Stack Overflow
the good way to do this is to use the doctrine event listener: file service.yml services: my_report_listener : class ...
Read more >Chapter 5. Entity listeners and Callback methods
A callback method is a no-arg method with no return type and any arbitrary name. An entity listener has the signature void <METHOD>(Object)...
Read more >Entity listeners and callback methods - IBM
Two callback mechanisms exist for state change events: lifecycle callback methods that are defined on an entity class and are invoked whenever ...
Read more >JPA event-driven development with entity listeners
To show explained concepts in the code, let's write some test cases. But before, we need to define listeners and callback methods inside...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, I’ve also tried this approach. It works, but seems a little bit strange to pass
Reminder
and then all it’s properties separately. Anyway thanks for your response.I would change your
ReminderListItemView
to include this linethen set it on the model
Then in the click listener you can easily get it
that way you don’t have to deal with item lookup. Also, the way you are currently looking up data has potential race conditions.