Validace Budov.

multitenant
František Přibyl 11 years ago
parent 3718e4c088
commit f93021485e

@ -3,6 +3,10 @@ package info.bukova.isspst.data;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
@Entity @Entity
@Table(name="BUILDING") @Table(name="BUILDING")
@ -22,6 +26,9 @@ public class Building extends BaseData implements DataModel {
/** /**
* @return the code * @return the code
*/ */
@NotBlank(message = "${labels.BuildingsFormCodeConstr}")
@NotNull(message = "${labels.BuildingsFormCodeConstr}")
@NotEmpty(message = "${labels.BuildingsFormCodeConstr}")
public String getCode() { public String getCode() {
return code; return code;
} }

@ -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.data.Building;
import info.bukova.isspst.services.Service;
public interface BuildingService extends Service<Building> { public interface BuildingService extends Service<Building> {

@ -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.data.Building;
import info.bukova.isspst.services.AbstractService;
public class BuildingServiceImpl extends AbstractService<Building> implements BuildingService{ public class BuildingServiceImpl extends AbstractService<Building> implements BuildingService{

@ -1,7 +1,7 @@
package info.bukova.isspst.ui; package info.bukova.isspst.ui;
import info.bukova.isspst.data.Building; 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.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;

@ -98,7 +98,6 @@ public class ListViewModel<T extends DataModel> {
this.editBean = edit; this.editBean = edit;
} }
@Command @Command
@NotifyChange({ "filter", "dataList", "dataBean" }) @NotifyChange({ "filter", "dataList", "dataBean" })
public void filter() { public void filter() {
@ -159,8 +158,9 @@ public class ListViewModel<T extends DataModel> {
@Command @Command
@NotifyChange({ "dataList", "dataBean" }) @NotifyChange({ "dataList", "dataBean" })
public void delete() { public void delete() {
Messagebox.show("Opravdu smazat?", "Smazat záznam", Messagebox.YES|Messagebox.NO, Messagebox.show("Opravdu smazat?", "Smazat záznam", Messagebox.YES
Messagebox.QUESTION, new EventListener<Event>() { | Messagebox.NO, Messagebox.QUESTION,
new EventListener<Event>() {
@Override @Override
public void onEvent(Event evt) throws Exception { public void onEvent(Event evt) throws Exception {
@ -169,10 +169,14 @@ public class ListViewModel<T extends DataModel> {
service.delete(dataBean); service.delete(dataBean);
dataList.remove(dataBean); dataList.remove(dataBean);
dataBean = null; dataBean = null;
BindUtils.postNotifyChange(null, null, ListViewModel.this, "dataList"); BindUtils.postNotifyChange(null, null,
BindUtils.postNotifyChange(null, null, ListViewModel.this, "dataBean"); ListViewModel.this, "dataList");
BindUtils.postNotifyChange(null, null,
ListViewModel.this, "dataBean");
} catch (DataIntegrityViolationException e) { } 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);
} }
} }
} }
@ -188,16 +192,17 @@ public class ListViewModel<T extends DataModel> {
dataList.remove(dataBean); dataList.remove(dataBean);
dataBean = null; dataBean = null;
} catch (DataIntegrityViolationException e) { } 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 @GlobalCommand
@NotifyChange({ "dataList", "dataBean" }) @NotifyChange({ "dataList", "dataBean" })
public void refresh() { public void refresh() {
/*if (editBean != null && !editBean.isValid()) { if (editBean != null && !editBean.isValid()) {
return; return;
}*/ }
if (editBean.getCreated() == null) { if (editBean.getCreated() == null) {
return; return;
} }

@ -1,5 +1,5 @@
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.dialect=org.hibernate.dialect.MySQLDialect 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.username=root
jdbc.password=xsacfgd jdbc.password=xsacfgd

@ -1,11 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <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"
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 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/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 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
@ -17,19 +11,12 @@
<context:annotation-config /> <context:annotation-config />
<context:component-scan base-package="info.bukova.isspst,org.zkoss.spring.beans.zkcomponents"></context:component-scan> <context:component-scan base-package="info.bukova.isspst,org.zkoss.spring.beans.zkcomponents"></context:component-scan>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer" p:location="/WEB-INF/jdbc.properties" />
id="propertyConfigurer"
p:location="/WEB-INF/jdbc.properties"/>
<!-- Database --> <!-- Database -->
<bean id="dataSource" <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>
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${jdbc.driverClassName}" <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
p:password="${jdbc.password}"></bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property> <property name="dataSource" ref="dataSource"></property>
<property name="configLocation"> <property name="configLocation">
<value>classpath:hibernate.cfg.xml</value> <value>classpath:hibernate.cfg.xml</value>
@ -44,8 +31,7 @@
</bean> </bean>
<tx:annotation-driven transaction-manager="transactionManager" /> <tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager" <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property> <property name="sessionFactory" ref="sessionFactory"></property>
</bean> </bean>
@ -55,8 +41,7 @@
<security:http auto-config="true"> <security:http auto-config="true">
<security:intercept-url pattern="/app/**" access="ROLE_USER, ROLE_ADMIN" /> <security:intercept-url pattern="/app/**" access="ROLE_USER, ROLE_ADMIN" />
<security:intercept-url pattern="/admin/**" access="ROLE_ADMIN" /> <security:intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
<security:form-login login-page="/login.zhtml" <security:form-login login-page="/login.zhtml" authentication-failure-handler-ref="loginFail" />
authentication-failure-handler-ref="loginFail"/>
<security:http-basic /> <security:http-basic />
<security:logout invalidate-session="true" /> <security:logout invalidate-session="true" />
</security:http> </security:http>
@ -108,8 +93,9 @@
<property name="dao" ref="roleDao" /> <property name="dao" ref="roleDao" />
</bean> </bean>
<bean id="buildingService" class="info.bukova.isspst.services.BuildingServiceImpl"> <bean id="buildingService" class="info.bukova.isspst.services.buildings.BuildingServiceImpl">
<property name="dao" ref="buildingDao" /> <property name="dao" ref="buildingDao" />
<property name="validator" ref="validator" />
</bean> </bean>
<bean id="adbService" class="info.bukova.isspst.services.addressbook.AdbServiceImpl"> <bean id="adbService" class="info.bukova.isspst.services.addressbook.AdbServiceImpl">

@ -1,4 +1,9 @@
<?page title="buttons" contentType="text/html;charset=UTF-8"?> <?page title="buttons" contentType="text/html;charset=UTF-8"?>
<zk> <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> </zk>

@ -8,12 +8,16 @@
<columns> <columns>
<column align="right" hflex="min" /> <column align="right" hflex="min" />
<column /> <column />
<column />
</columns> </columns>
<rows> <rows>
<row> <row>
<cell sclass="row-title">${labels.BuildingsFormCode} :</cell> <cell sclass="row-title">${labels.BuildingsFormCode} :</cell>
<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> </cell>
</row> </row>
<row> <row>

Loading…
Cancel
Save