Validace Budov.
This commit is contained in:
@@ -3,6 +3,10 @@ package info.bukova.isspst.data;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
@Entity
|
||||
@Table(name="BUILDING")
|
||||
@@ -22,6 +26,9 @@ public class Building extends BaseData implements DataModel {
|
||||
/**
|
||||
* @return the code
|
||||
*/
|
||||
@NotBlank(message = "${labels.BuildingsFormCodeConstr}")
|
||||
@NotNull(message = "${labels.BuildingsFormCodeConstr}")
|
||||
@NotEmpty(message = "${labels.BuildingsFormCodeConstr}")
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package info.bukova.isspst.services;
|
||||
package info.bukova.isspst.services.buildings;
|
||||
|
||||
import info.bukova.isspst.data.Building;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
public interface BuildingService extends Service<Building> {
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package info.bukova.isspst.services;
|
||||
package info.bukova.isspst.services.buildings;
|
||||
|
||||
import info.bukova.isspst.data.Building;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
|
||||
public class BuildingServiceImpl extends AbstractService<Building> implements BuildingService{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package info.bukova.isspst.ui;
|
||||
|
||||
import info.bukova.isspst.data.Building;
|
||||
import info.bukova.isspst.services.BuildingService;
|
||||
import info.bukova.isspst.services.buildings.BuildingService;
|
||||
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
|
||||
@@ -98,9 +98,8 @@ public class ListViewModel<T extends DataModel> {
|
||||
this.editBean = edit;
|
||||
}
|
||||
|
||||
|
||||
@Command
|
||||
@NotifyChange({"filter", "dataList", "dataBean"})
|
||||
@NotifyChange({ "filter", "dataList", "dataBean" })
|
||||
public void filter() {
|
||||
filter = !filter;
|
||||
|
||||
@@ -157,22 +156,27 @@ public class ListViewModel<T extends DataModel> {
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange({"dataList", "dataBean"})
|
||||
@NotifyChange({ "dataList", "dataBean" })
|
||||
public void delete() {
|
||||
Messagebox.show("Opravdu smazat?", "Smazat záznam", Messagebox.YES|Messagebox.NO,
|
||||
Messagebox.QUESTION, new EventListener<Event>() {
|
||||
Messagebox.show("Opravdu smazat?", "Smazat záznam", Messagebox.YES
|
||||
| Messagebox.NO, Messagebox.QUESTION,
|
||||
new EventListener<Event>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event evt) throws Exception {
|
||||
if (((Integer)evt.getData()).intValue() == Messagebox.YES) {
|
||||
if (((Integer) evt.getData()).intValue() == Messagebox.YES) {
|
||||
try {
|
||||
service.delete(dataBean);
|
||||
dataList.remove(dataBean);
|
||||
dataBean = null;
|
||||
BindUtils.postNotifyChange(null, null, ListViewModel.this, "dataList");
|
||||
BindUtils.postNotifyChange(null, null, ListViewModel.this, "dataBean");
|
||||
BindUtils.postNotifyChange(null, null,
|
||||
ListViewModel.this, "dataList");
|
||||
BindUtils.postNotifyChange(null, null,
|
||||
ListViewModel.this, "dataBean");
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
Messagebox.show("Chyba při mazání záznamu", "Chyba", Messagebox.OK, Messagebox.ERROR);
|
||||
Messagebox.show("Chyba při mazání záznamu",
|
||||
"Chyba", Messagebox.OK,
|
||||
Messagebox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,23 +185,24 @@ public class ListViewModel<T extends DataModel> {
|
||||
confirmDelete = false;
|
||||
}
|
||||
|
||||
@NotifyChange({"dataList", "dataBean"})
|
||||
@NotifyChange({ "dataList", "dataBean" })
|
||||
private void onDelete() {
|
||||
try {
|
||||
service.delete(dataBean);
|
||||
dataList.remove(dataBean);
|
||||
dataBean = null;
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
Messagebox.show("Chyba při mazání záznamu", "Chyba", Messagebox.OK, Messagebox.ERROR);
|
||||
Messagebox.show("Chyba při mazání záznamu", "Chyba", Messagebox.OK,
|
||||
Messagebox.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GlobalCommand
|
||||
@NotifyChange({"dataList", "dataBean"})
|
||||
@NotifyChange({ "dataList", "dataBean" })
|
||||
public void refresh() {
|
||||
/*if (editBean != null && !editBean.isValid()) {
|
||||
if (editBean != null && !editBean.isValid()) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
if (editBean.getCreated() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -216,7 +221,7 @@ public class ListViewModel<T extends DataModel> {
|
||||
}
|
||||
|
||||
@GlobalCommand
|
||||
@NotifyChange({"dataList", "dataBean", "fullFill"})
|
||||
@NotifyChange({ "dataList", "dataBean", "fullFill" })
|
||||
public void reload() {
|
||||
dataBean = null;
|
||||
dataList.clear();
|
||||
@@ -230,12 +235,12 @@ public class ListViewModel<T extends DataModel> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selIndex > dataList.size() -1) {
|
||||
if (selIndex > dataList.size() - 1) {
|
||||
selIndex = -1;
|
||||
}
|
||||
|
||||
if (newRec) {
|
||||
selIndex = dataList.size() -1;
|
||||
selIndex = dataList.size() - 1;
|
||||
newRec = false;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +261,7 @@ public class ListViewModel<T extends DataModel> {
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange({"dataList", "fullFill"})
|
||||
@NotifyChange({ "dataList", "fullFill" })
|
||||
public void fullFill() {
|
||||
if (fullFill && dataList.isEmpty()) {
|
||||
dataList.addAll(tmpList);
|
||||
@@ -264,25 +269,25 @@ public class ListViewModel<T extends DataModel> {
|
||||
}
|
||||
}
|
||||
|
||||
// private void loadFromDb() {
|
||||
// Thread fillThread = new Thread(new Runnable() {
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
// tmpList = service.getAll();
|
||||
//
|
||||
// try {
|
||||
// Thread.sleep(200);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// fullFill = true;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// fillThread.start();
|
||||
// }
|
||||
// private void loadFromDb() {
|
||||
// Thread fillThread = new Thread(new Runnable() {
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
// tmpList = service.getAll();
|
||||
//
|
||||
// try {
|
||||
// Thread.sleep(200);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// fullFill = true;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// fillThread.start();
|
||||
// }
|
||||
|
||||
private void loadFromDbSync() {
|
||||
dataList.addAll(service.getAll());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
jdbc.driverClassName=com.mysql.jdbc.Driver
|
||||
jdbc.dialect=org.hibernate.dialect.MySQLDialect
|
||||
jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst
|
||||
jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=UTF-8
|
||||
jdbc.username=root
|
||||
jdbc.password=xsacfgd
|
||||
@@ -1,11 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:security="http://www.springframework.org/schema/security" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
@@ -17,19 +11,12 @@
|
||||
<context:annotation-config />
|
||||
<context:component-scan base-package="info.bukova.isspst,org.zkoss.spring.beans.zkcomponents"></context:component-scan>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
|
||||
id="propertyConfigurer"
|
||||
p:location="/WEB-INF/jdbc.properties"/>
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer" p:location="/WEB-INF/jdbc.properties" />
|
||||
|
||||
<!-- Database -->
|
||||
<bean id="dataSource"
|
||||
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
|
||||
p:driverClassName="${jdbc.driverClassName}"
|
||||
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
|
||||
p:password="${jdbc.password}"></bean>
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}"></bean>
|
||||
|
||||
<bean id="sessionFactory"
|
||||
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"></property>
|
||||
<property name="configLocation">
|
||||
<value>classpath:hibernate.cfg.xml</value>
|
||||
@@ -43,9 +30,8 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven transaction-manager="transactionManager"/>
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
|
||||
<tx:annotation-driven transaction-manager="transactionManager" />
|
||||
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="sessionFactory"></property>
|
||||
</bean>
|
||||
|
||||
@@ -53,77 +39,77 @@
|
||||
<security:global-method-security secured-annotations="enabled" />
|
||||
|
||||
<security:http auto-config="true">
|
||||
<security:intercept-url pattern="/app/**" access="ROLE_USER, ROLE_ADMIN"/>
|
||||
<security:intercept-url pattern="/admin/**" access="ROLE_ADMIN"/>
|
||||
<security:form-login login-page="/login.zhtml"
|
||||
authentication-failure-handler-ref="loginFail"/>
|
||||
<security:http-basic/>
|
||||
<security:logout invalidate-session="true"/>
|
||||
<security:intercept-url pattern="/app/**" access="ROLE_USER, ROLE_ADMIN" />
|
||||
<security:intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
|
||||
<security:form-login login-page="/login.zhtml" authentication-failure-handler-ref="loginFail" />
|
||||
<security:http-basic />
|
||||
<security:logout invalidate-session="true" />
|
||||
</security:http>
|
||||
|
||||
<security:authentication-manager>
|
||||
<security:authentication-provider user-service-ref="userService">
|
||||
<security:password-encoder ref="passwordEncoder">
|
||||
<security:salt-source user-property="username"/>
|
||||
<security:salt-source user-property="username" />
|
||||
</security:password-encoder>
|
||||
</security:authentication-provider>
|
||||
</security:authentication-manager>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="targetClass" value="org.springframework.security.core.context.SecurityContextHolder"/>
|
||||
<property name="targetMethod" value="setStrategyName"/>
|
||||
<property name="arguments" value="MODE_INHERITABLETHREADLOCAL"/>
|
||||
<property name="targetClass" value="org.springframework.security.core.context.SecurityContextHolder" />
|
||||
<property name="targetMethod" value="setStrategyName" />
|
||||
<property name="arguments" value="MODE_INHERITABLETHREADLOCAL" />
|
||||
</bean>
|
||||
|
||||
<bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder"/>
|
||||
<bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" />
|
||||
|
||||
<bean id="loginFail" class="info.bukova.isspst.LoginFailHandler"/>
|
||||
<bean id="loginFail" class="info.bukova.isspst.LoginFailHandler" />
|
||||
|
||||
<!-- DAO -->
|
||||
<bean id="userDao" class="info.bukova.isspst.dao.jpa.UserDaoJPA">
|
||||
<property name="sessionFactory" ref="sessionFactory"/>
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="roleDao" class="info.bukova.isspst.dao.jpa.RoleDaoJPA">
|
||||
<property name="sessionFactory" ref="sessionFactory"/>
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="buildingDao" class="info.bukova.isspst.dao.jpa.BuildingDaoJPA">
|
||||
<property name="sessionFactory" ref="sessionFactory"/>
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="addressDao" class="info.bukova.isspst.dao.jpa.AddressDaoJPA">
|
||||
<property name="sessionFactory" ref="sessionFactory"/>
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<!-- Business logic -->
|
||||
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
|
||||
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
|
||||
|
||||
<bean id="userService" class="info.bukova.isspst.services.users.UserServiceImpl">
|
||||
<property name="dao" ref="userDao"/>
|
||||
<property name="encoder" ref="passwordEncoder"/>
|
||||
<property name="dao" ref="userDao" />
|
||||
<property name="encoder" ref="passwordEncoder" />
|
||||
</bean>
|
||||
|
||||
<bean id="roleService" class="info.bukova.isspst.services.users.RoleServiceImpl">
|
||||
<property name="dao" ref="roleDao"/>
|
||||
<property name="dao" ref="roleDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="buildingService" class="info.bukova.isspst.services.BuildingServiceImpl">
|
||||
<property name="dao" ref="buildingDao"/>
|
||||
<bean id="buildingService" class="info.bukova.isspst.services.buildings.BuildingServiceImpl">
|
||||
<property name="dao" ref="buildingDao" />
|
||||
<property name="validator" ref="validator" />
|
||||
</bean>
|
||||
|
||||
<bean id="adbService" class="info.bukova.isspst.services.addressbook.AdbServiceImpl">
|
||||
<property name="dao" ref="addressDao"/>
|
||||
<property name="validator" ref="validator"/>
|
||||
<property name="dao" ref="addressDao" />
|
||||
<property name="validator" ref="validator" />
|
||||
</bean>
|
||||
|
||||
<bean id="addressFinderAres" class="info.bukova.isspst.services.addressbook.AddressFinderAres">
|
||||
<property name="aresUrl" value="http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi"/>
|
||||
<property name="unmarsheller" ref="unmarshallerAres"/>
|
||||
<property name="aresUrl" value="http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi" />
|
||||
<property name="unmarsheller" ref="unmarshallerAres" />
|
||||
</bean>
|
||||
|
||||
<bean id="addressFinderTaxID" class="info.bukova.isspst.services.addressbook.AddressFinderTaxID">
|
||||
<property name="aresDicUrl" value="http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi"/>
|
||||
<property name="aresDicUrl" value="http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi" />
|
||||
</bean>
|
||||
|
||||
<bean id="xmlCtxAres" class="org.castor.spring.xml.XMLContextFactoryBean">
|
||||
@@ -135,7 +121,7 @@
|
||||
</bean>
|
||||
|
||||
<bean id="unmarshallerAres" class="org.castor.spring.xml.CastorUnmarshallerFactoryBean">
|
||||
<property name="xmlContext" ref="xmlCtxAres"/>
|
||||
<property name="xmlContext" ref="xmlCtxAres" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<?page title="buttons" contentType="text/html;charset=UTF-8"?>
|
||||
<zk>
|
||||
<button image="/img/save.png" label="Uložit" onClick="@command('save', window=editWin) @global-command('refresh')" sclass="nicebutton" /><button image="~./zul/img/misc/drag-disallow.png" label="Zrušit" onClick="editWin.detach()" sclass="nicebutton"/>
|
||||
<vlayout>
|
||||
<div hflex="max" align="right">
|
||||
<button image="~./zul/img/misc/drag-disallow.png" label="${labels.ButtonStorno}" onClick="editWin.detach()" sclass="nicebutton" />
|
||||
<button image="/img/save.png" label="${labels.ButtonSave}" onClick="@command('save', window=editWin) @global-command('refresh')" sclass="nicebutton" />
|
||||
</div>
|
||||
</vlayout>
|
||||
</zk>
|
||||
@@ -8,12 +8,16 @@
|
||||
<columns>
|
||||
<column align="right" hflex="min" />
|
||||
<column />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<cell sclass="row-title">${labels.BuildingsFormCode} :</cell>
|
||||
<cell>
|
||||
<textbox constraint="no empty: ${labels.BuildingsFormCodeConstr}" width="200px" value="@bind(vm.dataBean.code)" />
|
||||
<textbox width="200px" value="@bind(vm.dataBean.code)" />
|
||||
</cell>
|
||||
<cell>
|
||||
<label visible="true" value="@load(vm.errMessages['code'])" style="color:red" />
|
||||
</cell>
|
||||
</row>
|
||||
<row>
|
||||
@@ -30,7 +34,7 @@
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<include src="/app/formButtons.zul"/>
|
||||
<include src="/app/formButtons.zul" />
|
||||
</vlayout>
|
||||
</window>
|
||||
</zk>
|
||||
Reference in New Issue
Block a user