I am developing ZK application, which contains few roles. For role "Guest" I have to to make all components in readonly mode. So how to create a container ( Window Div Layout) in readonly mode in ZK application ?
相关问题
- Zk Remove event Listener from selected tab
- Implementing static ID generator in java
- Getting an error as “Could not initialize class su
- ZK upload dialog not working
- multiple syntax highlighting in sublimetext 3 with
相关文章
- 有一个简单的方法,使与IE11的文件上传工作,而无需更新ZK(Is there an easy wa
- 房产无法读取上TreeModel中一个内部类(Property not readable on a
- 如何选择一周中ZK日历(How to selected week in calendar in zk
- 我登录/指数ZUL页面加载的两倍,其中,因为我只称这是一次(my login/index zul p
- 在ZK我们可以PostNotifyChange多个变量(In ZK Can we PostNotif
- Implementing static ID generator in java
- 放在哪里的applicationContext.xml和.hbm文件?(where to put a
- Getting an error as “Could not initialize class su
Yes you can do this in MVVM also.
So let's start with the beginning.
You need to wire some components as in the answer you reffering :
The second thing is, implementing the AfterCompose for disabling and the Init for checking the status.
In normal MVVM you almost never need to use the
@AfterCompose
but when you need to wire for solutions like this, you will need it.What you need to know is that @Init is triggered first and after that the AfterCompose is triggered.
Edit:
That's because the databinding happens after the
@AfterCompose
. You could add a getter for thedisable
and the the zul :With this, if 1 of the 2 is true, the checkbox is always disabled.
Last edit :
While going home from work, I can't let this go like this without a descend solution.
After a good night rest, I have found the solution for you.
**Explication : ** While yesterday I didn't test if the
@Wire("disable")
worked or not, I'm not getting that working in ZK Fiddle.So first of all, I wanted to get rid of the
@Wire
so we use the@SelectorParam
to do the same and like this we don't need to call theSelectors
.I had the same problem using
@Wire
or with@SelectorParam
that I never had any component in the List.So now, we just get every component in the view and check if it is an instance of the
Disable
interface, witch is actually the same, like this you could even say not for buttons.Then the second thing, is just removing the binding of the attribute
disabled
for that Component.You can do that, by asking the
Binder
from the context with the@ContextParam
annotation.At last, we remove the binding by
binder.removeBindings(Component, String);
.Watch out, not to remove the complete binding with
binder.removeBindings(Component);
because at that moment your bindings for the values are also gone.You can check it out in this fiddle (I exclude the button by checking for
Textbox
so you could still press the button)A container is not the correct place to set the enabled/disabled property. It's a "passive" element containing all sorts of other components.
To enable/disable input, you have to set the property directly at the input components like
textbox
,combobox
, ... . They usualy have adisabled
property which has to be set totrue
if the client is in read only mode.When using MVVM you can shortcut this by binding the disabled property of all components to the same view model property:
Here you can find a working example fiddle.