I think i have a fundamental problem with understanding Wire
components if some one could explain why they work with a Composer
and the doAfterCompose()
-Method and why the wiring dosen't work (Component -> NULL) in a @command
-Method (like onClick from a button).
I can't post the whole code so I'am just pasting parts of a working zul and a working Java Class
I used MVVM
to access some values from ZUL-Components
. The java class
used for this also generates some components dynamically
with data from a database (in doAfterCompose()
-Method).
Szenario: the gui shows up and via doAfterCompose()
several components are created dynamically (Row Component + Checkbox in the Row Component) with the Wire Component orgTypeRows
(Type Rows). That works fine.
But to acces the results you click on the search button which has the onClick event "startSearch"
which calls the java method startSearch()
. In this method I want to access the generated components (Type Checkbox) and verifiy which boxes have been checked but when i try to access the wire component here the Rows Component is NULL
Here is the ZUL-Code search.zul and the Java-Code search.java
Is this impossible like that? Should i just use a listener for the button in doAfterCompose()
instead of the @command
but how can I access the viewmodel in doAfterCompose()
there all values of the viewmodel are NULL?
I think you have a fundamental problem with MVC and MVVM.
Let's start with the zul you showed.
I can't find any apply
attribute in the zul so the controller or viewmodel must be applied in another zul, so I don't know what you are using, MVC or MVVM.
The loading of the properties are the MVVM way.
Let's go now to the java class.
You are mixing 2 completly different things.
First of all extending the GenericForwardComposer
is an MVC way.
It's even an old one because the SelectorComposer
is the newest MVC controller where you can annotate the wiring what must be done.
@Init
, @Command
=> MVVM
@doAfterCompose
, wiring => MVC
Now you say that the @Command
method isn't working. Do you mean not triggering?
Don't forget that the MVVM way need's a binder.
Initialisation of a viewmodel :
apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('yourPackage.YourClass')"
Initialisation of an MVC controller :
apply="yourPackage.YourClass"
See the difference?
Please, read the documentation about MVC and MVVM on zk website.
Refactor then your whole thing, and if you still have problems come back with a better question where we can help you with.