-
FEATURED COMPONENTS
First time here? Check out the FAQ!
When I change a field in a JPA entity (ex: name) I need to mark the entity as changed.
The changed field will be used to enable and disable the save button.
So I need something like:
Name:<textbox value="@bind(vm.entity.name) @notify(vm.entity.changed)"/>
<button disabled="@load(!vm.entity.changed)" onClick="@command('save')"/>
And I don't what to put @NotifyChange in my domain entities, since it is in other project and creates dependencies on ZK.
Since http://tracker.zkoss.org/browse/ZK-1252 is not yet implemented, is there a workaround for this?
Sorry, but the feature that you mentioned is not related to the functionality that you desired in your pseudo code.
To implement a feature that can mimic entity bean attribute change requires byte code injection.
Unfortunately, byte code injection to an entity bean(a bean that is controlled by JPA container) is definitely an error prone in the future, because we'd never know how it might happen when entity manager decide to do anything to it's controlled bean and our inject code might fucked up.
the possible way to "fire an event about data change to ask UI performing update" is:
1. You need to add additional layer between your entity and UI, DO NOT use this part of Entity directly in your UI, use a View Object, business object or something.
2. in this newly add layer, you need to implement your own event firing mechanism, which will constantly watching any changes of your entity bean(I'll do this while every request start).
3.Then you can use BindUtils to post a Global Command to notify UI do the update.
Asked: 2012-08-30 10:35:19 +0800
Seen: 153 times
Last updated: Sep 03 '12