0

Cannot pass a form as parameter to a macro

asked 2015-02-02 09:03:42 +0800

KlausWr gravatar image KlausWr
37 5

updated 2015-02-02 19:19:48 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

I tried to pass a form as parameter to a macro:

<?component name="mymacro" macroURI="mymacro.zul" inline="true"?>
...
<grid form="@id('fx') @load(vm) @save(vm), before='save'> 

<rows> 
  <mymacro pojo="${fx}" field="myValue"/> 
</rows>
</grid>
...
<button label="save" onClick="@command('save')" />
<button label="cancel" onClick="@command('cancel')" />

but I get "Target Unreachable, identifier 'pojo' resolved to null"

when I try to access this "passed form" in mymacro.zul:

<zk>
  <row style="border: 1px solid red;">
    <custom-attributes pojo="${arg.pojo}" field="${arg.field}"/>
    Inside macro:
    <textbox value="@bind(pojo[field])"/>
  </row>
</zk>

See also discussion in Inline Macro: pass parameter with ViewModel annotation (@load(x))

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-02-02 13:20:24 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

updated 2015-02-02 19:31:37 +0800

I did some updating of Robert's previous example.

http://zkfiddle.org/sample/6sleo1/3-macro-with-manual-reference

Like I said, not very clean code but it's possible.

I did now wire only the pojo object to the SimpleForm but you can update it so it contains every singel propertie of the Pojo object.

Edit:

Well, you could use the form binding in the macro component.
The only thing what we need to know is when te save, so I've updated cor's example again with the update of your question.
I think it's the reaction what you wanted.

http://zkfiddle.org/sample/6sleo1/4-macro-with-manual-reference

Greetz chill.

link publish delete flag offensive edit

Comments

This does not really solve my problem, as the goal is to use a form as a container of several macros (here: macros to render rows within a grid) while using MVVM-style data binding (which cannot be passed directly as macro parameter).

KlausWr ( 2015-02-02 14:26:18 +0800 )edit

The example http://zkfiddle.org/sample/6sleo1/3-macro-with-manual-reference shows how to make this data binding happen for the ViewMode (vm), but not for a "form-model" (fx) inside the zul..

KlausWr ( 2015-02-02 14:27:17 +0800 )edit

I'll try and search, but I have no good eye in it for the moment.

chillworld ( 2015-02-02 14:36:38 +0800 )edit

Klaus, can you edit your question to the final result. I espect you will also use model and template because you speak of multiple rows. Where you want to put the savebefore of the fx?

chillworld ( 2015-02-02 15:29:10 +0800 )edit

I extended the sample code in my question (did not check final syntax). No templates used.

KlausWr ( 2015-02-02 16:51:40 +0800 )edit
Your answer
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
2 followers

RSS

Stats

Asked: 2015-02-02 09:03:42 +0800

Seen: 20 times

Last updated: Feb 02 '15

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