ZKBind -trigger @save after initialising with @load

asked 2015-03-12 19:21:24 +0800

mminke gravatar image mminke
12 2

I have a zul page in which I use zkbind to bind values to the components. Now I encounter an issue with a separate @load and @save configuration. As seen below, the datebox is initialised with either the current date or the value of the date field. However, If I save the currentDocument using a @Command, the currentDate is not set in the document. Apparently the @save is only triggered by a change in the datebox, not because the value set in the @load.

<datebox value="@load(salesorder_vm.currentDocument.date eq null ? c:new('java.util.Date'): salesorder_vm.currentDocument.date) @save(salesorder_vm.currentDocument.date)"/>

Is there any pattern or trigger I can use to make zkbind see the @load as a change of the currentdocument?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-13 06:46:51 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9

updated 2015-03-14 07:56:33 +0800


public void initialValue(){}


<datebox value="@load(salesorder_vm.currentDocument.date eq null ? c:new('java.util.Date'): salesorder_vm.currentDocument.date) @save(salesorder_vm.currentDocument.date) @save(salesorder_vm.currentDocument.date, after='initialValue')" onCreate="@command('initialValue')"/>

If you don't want so much in the zul, you just could do (I prefer this one) :


<datebox value="@bind(salesorder_vm.currentDocument.date onCreate="@command('initialValue', currentDoc = salesorder_vm.currentDocument)"/>


public void initialValue(@BindingParam("currentDoc") Document doc){
    if (doc.getDate() == null) { 
       doc.setDate(new Date());

Greetz chill.

link publish delete flag offensive 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

1 follower



Asked: 2015-03-12 19:21:24 +0800

Seen: 18 times

Last updated: Mar 14 '15

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