-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
I tested this out and it works:
ZUL
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="new page title" border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('TestViewModel')">
<datebox id="myDate" constraint="@bind(vm.myDateConstraint)"
value="@bind(vm.myDate)" />
</window>
</zk>
TestViewModel
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import org.zkoss.zul.SimpleDateConstraint;
public class TestViewModel
{
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd-MM-yyyy");
private SimpleDateConstraint sdc;
private Date constraintDate;
private Date myDate;
public Date getMyDate()
{
if (myDate == null)
{
myDate = new GregorianCalendar().getTime();
}
return myDate;
}
public void setMyDate(Date myDate)
{
this.myDate = myDate;
}
public SimpleDateConstraint getMyDateConstraint()
{
constraintDate = new GregorianCalendar(2012, 10, 30).getTime();
sdc = new SimpleDateConstraint("before 20121130: " +
"Error! Date " + SDF.format(getMyDate()) +
" is before " + SDF.format(constraintDate));
return sdc;
}
public void setMyDateConstraint(SimpleDateConstraint sdc)
{
this.sdc = sdc;
}
}