19 package org.turro.contacts.zul.contact;
21 import org.turro.contacts.Contact;
22 import org.turro.contacts.db.ContactsPU;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.i18n.I_;
25 import org.zkoss.lang.Strings;
26 import org.zkoss.zk.ui.Component;
27 import org.zkoss.zk.ui.WrongValueException;
28 import org.zkoss.zk.ui.event.Event;
29 import org.zkoss.zk.ui.event.EventListener;
30 import org.zkoss.zk.ui.event.Events;
31 import org.zkoss.zul.Constraint;
32 import org.zkoss.zul.Textbox;
44 this.contact = contact;
46 Constraint ctt =
new Constraint() {
48 public void validate(Component comp, Object value)
throws WrongValueException {
49 if(!isReadonly() && !Strings.isEmpty((String) value)) {
50 if(exists((String) value)) {
58 addEventListener(Events.ON_CHANGE,
new EventListener<Event>() {
60 public void onEvent(Event event) throws Exception {
61 contact.setEmailAccount(getValue());
66 private boolean exists(String value) {
68 wc.
addClause(
"select distinct c from Contact as c");
69 wc.
addClause(
"where c.id <> :id and c.emailAccount = :email");
72 return !
new ContactsPU().getResultList(wc).isEmpty();
void addClause(String clause)
void addNamedValue(String name, Object value)
static String get(String msg)