0

notifyChange in zul

asked 2012-08-30 10:35:19 +0800

shumy gravatar image shumy
244 1

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?

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-09-03 03:48:04 +0800

iantsai gravatar image iantsai
2755 1

updated 2012-09-03 03:49:23 +0800

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.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-08-30 10:35:19 +0800

Seen: 153 times

Last updated: Sep 03 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More