-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I was looking for the ability (in the ZUL-File!) to disable all child components of a container-component.
But I haven't found any container-component that even supports properties like "disabled" or "readonly", just a property "visible".
Do I really have do disable ALL sub-components "manually".
I know I can iterate over all children-components via Java-Code and disable them but isn't there a better way?
I don't want to access the ZUL-Components in my code due to the MVVM principles...
Thanks for any answers,
Jörg
Hi,
if using MVVM you can bind component's "disabled" attribute that are required to be disabled to a single ViewModel's property, then you can disable them once when that property changed.
Hi,
I think zk 's container component doesn't support the feature you want. You have to disable them by your own.
hi hawk,
I am developing a ZK application following the MVVM pattern and I have a doubt. In the application there are buttons, when I click one, more than one must be disabled, while others are enabled. Following the MVC approach to the management @Wire binding is easy, but here http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/Advance/Wire%20Components this is not recommended for the MVVM pattern.
What is the right strategy to handle this situation? I deal with all the logic in zul file? how can I attach more than one button in an attribute of another button (eg snippet a zul file
... <north autoscroll="true" height="50px"> <hbox pack="start" height="100%" width="100%" align="center"> <button id="addUsr" image="/image/add_user.png" tooltiptext="Add a User" onClick="@command('preAdd', update=updUsr, delete=delUsr)" sclass="@load((mygrp.setSclass('add')), after='preAdd')" /> <button id="updUsr" image="/image/modify_user.png" disabled="@load({(delUsr.setDisabled(true)) and (addUsr.setDisabled(true))},after='pre_update')" tooltiptext="Modify a User" onClick="@command('pre_update')" sclass="@load((mygrp.setSclass('update')), after='pre_update')" /> <button id="delUsr" image="/image/delete_user.png" tooltiptext="Delete a User" onClick="@command('pre_delete')" sclass="@load((mygrp.setSclass('delete')), after='pre_delete')" /> <hbox width="20px"/> <button id="searchFilter" onClick="@command('pre_search')" tooltiptext="Search Filtered" sclass="@load((mygrp.setSclass('search')), after='pre_search')" image="/image/search.png" disabled="" /> <button id="searchAll" image="/image/filter.png" disabled="true" onClick="@command('search_all')" sclass="@load(mygrp.setSclass('selected'), after=('search_all'))" /> <hbox width="20px"/> <button id="cnfBtn" image="/image/button_ok.png" onClick="@command('confirm_operation')" disabled="true" sclass="@load(mygrp.setSclass('selected'), after=('confirm_operation'))" /> <button id="abtBtn" image="/image/button_cancel.png" onClick="@command('abort')" disabled="true" sclass="@load(mygrp.setSclass('selected'), after=('abort'))" /> </hbox> </north> ...
thank you
@pasqualeleone
Have a look on the de.forsthaus.webui.util.ButtonStatusCtrl.java controller in Zksample2 for having an idea.
best
Stephan
@ Terrytornato, thanks for the answer!
I downloaded the WAR file zkSample2 the project, but the source code is not available so I can not see the de.forsthaus.webui.util.ButtonStatusCtrl.java.
I noticed that the design features http://sourceforge.net/projects/zksample2
refers to the MVC pattern, but I follow the approach MVVM.
What I do not understand:
1) How can I handle the complex logic of user interface components. The use of @ Wire involves the loss of decoupling between View and Model, but then how do I manage complex operations on the user interface components such as buttons? for example after a onClick on a button, activates a number of methods, such as disabling a number of buttons or modification of a label, and others. Can I manage all this in zul file?
while it is easy to handle with your Java code and bind the components with @ Wire, but if I follow MVVM how I orient ?
2) the method doAfterCompose, is used to MVVM?
Help I'm confused ...
Hi,
ViewModel should contain UI's state and logic. In your case, you could bind every button's "disabled" attribute to a ViewModel's property and change those properties value according to your business logic.
<button id="add" onClick="@command('add')" disabled="@load(vm.addDisabled)"></button> <button id="update" onClick="@command('update')" disabled="@load(vm.updateDisabled)"></button> <button id="del" onClick="@command('del')" disabled="@load(vm.delDisabled)"></button>
and you change those "xDisabled" properties in each command method.
@NotifyChange({"delDisabled","updateDisabled"}) @command public add(){ this.delDisabled=true; //change flag properties upon business rule }
doAfterComposer() is one of composer's method, only those classes that inherit a composer class will contain this method. ViewModel is usually implemented with a POJO and doesn't have that method.
hawk thanks for your answer!!
I changed my code creating a pure MVVM!
I have a new question: I would like to load a Style after launching a @comman onClick of a button, and each button corresponds to a different style.
Using this syntax:
<button id="addUsr" image="@load((not umvm.addDisabledBtn) ? '/image/add_user.png' : '/image/add_user_disabled.png')" tooltiptext="Add a User" onClick="@command('preAdd')" disabled="@load(umvm.addDisabledBtn)" style="@load(hbEmail.setSclass('add'),after ='preAdd')" />
Hi,
The following code you provided seems incorrectly.
style="@load(hbEmail.setSclass('add')
You can change the css based on some condition
here is an example
http://emrpms.blogspot.in/2012/06/mvvmlist-itemhibernatemysql.html
Asked: 2012-04-26 09:09:35 +0800
Seen: 464 times
Last updated: Jul 31 '12