Monday, March 4, 2013

Zk form validation before button click.



Validation.zul

<zk xmlns:x="xhtml" xmlns:zk="zk">
      <window width="100%" height="100%"
            apply="org.zkoss.bind.BindComposer"
            viewModel="@id('vm') @init('test.test.Validation')"
            form="@id('fx') @load(vm) @save(vm,before='doSave')">


            <vlayout sclass="vertical-scroll" vflex="1">
                  <toolbar id="listToolbarProcess" sclass="vista"
                        height="20px" align="start">

                        <toolbarbutton label="Save"
                              onClick="@command('doSave')" />


                  </toolbar>

                  <intbox id="priority" maxlength="3" constraint="no empty"
                        value="@bind(fx.value)" />
                  <datebox value="@bind(fx.date)"></datebox>


            </vlayout>

      </window>


</zk>
Validation.java
package test.test;

import java.sql.Timestamp;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.zk.ui.Component;

public class Validation {

                /**
                 * @author Himanshu
                 */

                @AfterCompose
                public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
                }

                @Command
                public void doSave() {

                                System.out.println(" value =" + str);
                                System.out.println(" Date Value =" + date);
                }

                boolean check;

                public boolean isCheck() {
                                return check;
                }

                public void setCheck(boolean check) {
                                this.check = check;
                }

                Integer value;

                public Integer getValue() {
                                return value;
                }

                public void setValue(Integer value) {
                                this.value = value;
                }

                String str;

                public String getStr() {
                                return str;
                }

                public void setStr(String str) {
                                this.str = str;
                }

                Timestamp date;

                public Timestamp getDate() {
                                return date;
                }

                public void setDate(Timestamp date) {
                                this.date = date;
                }

}

How to Calculate the Future Investment Value of Investment.

Below java program for calculate future investment value. Here calculate s using the formula futureInvestmentValue =investmentAmount x (...