以下のサンプルでは、ボタンコンポーネントの onClick イベントがスプリングセキュリティでセキュアにされている為、 account の balance を変更しようとすると、ZK はログインを要求します。
<?variable-resolver class="org.zkoss.spring.DelegatingVariableResolver"?>
<zk> <window title="Accouts" border="normal" width="500px"> <zscript><![CDATA[ void adjBalance(Button btn) { double bal = new Double((String)btn.getAttribute("bal")).doubleValue(); //get the account object bigbank.Account a = bankService.readAccount(btn.getAttribute("aid")); //change the account balance bankService.post(a, bal); //update the account balance on the browser btn.getFellow("bal_"+a.getId()).setValue(""+a.getBalance()); } ]]> </zscript> <grid> <rows> <row forEach="${accounts}"> <label value="${each.id}"/> <label value="${each.holder}"/> <label id="bal_${each.id}" value="${each.balance}"/> <button id="btn_m20_${each.id}" label="-$20" onClick="adjBalance(self)"> <custom-attributes aid="${each.id}" bal="-20"/> </button> <button id="btn_m5_${each.id}" label="-$5" onClick="adjBalance(self)"> <custom-attributes aid="${each.id}" bal="-5"/> </button> ................... </row> </rows> </grid> </window> <button label="Home" href="/index.zul"/> <button label="Logout" href="/j_spring_security_logout"/> </zk>