Revision be4a9789
Added by Andreas Kohlbecker about 6 years ago
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import org.apache.log4j.Logger; |
16 | 16 |
import org.hibernate.HibernateException; |
17 |
import org.springframework.context.event.EventListener;
|
|
17 |
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.api.service.IService; |
20 | 20 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher; |
... | ... | |
120 | 120 |
* @return |
121 | 121 |
*/ |
122 | 122 |
protected abstract IService<DTO> getService(); |
123 |
|
|
123 |
|
|
124 | 124 |
@SuppressWarnings("unchecked") |
125 | 125 |
@Override |
126 |
@EventListener // the generic type parameter <DTO> must not be used here otherwise events will not be received
|
|
126 |
@EventBusListenerMethod
|
|
127 | 127 |
public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){ |
128 | 128 |
|
129 | 129 |
if(!isFromOwnView(preSaveEvent)){ |
... | ... | |
134 | 134 |
|
135 | 135 |
@SuppressWarnings("unchecked") |
136 | 136 |
@Override |
137 |
@EventListener // the generic type parameter <DTO> must not be used here otherwise events will not be received
|
|
138 |
public void onEditorSaveEvent(EditorSaveEvent saveEvent){ |
|
137 |
@EventBusListenerMethod
|
|
138 |
public void onEditorSaveEvent(EditorSaveEvent<DTO> saveEvent){
|
|
139 | 139 |
|
140 | 140 |
if(!isFromOwnView(saveEvent)){ |
141 | 141 |
return; |
142 | 142 |
} |
143 |
|
|
144 |
|
|
143 |
|
|
145 | 144 |
// the bean is now updated with the changes made by the user |
146 |
DTO bean = (DTO) saveEvent.getBean();
|
|
145 |
DTO bean = saveEvent.getBean(); |
|
147 | 146 |
|
148 | 147 |
if(logger.isTraceEnabled()){ |
149 | 148 |
PersistentContextAnalyzer pca = new PersistentContextAnalyzer(bean); |
... | ... | |
161 | 160 |
EntityChangeEvent changeEvent = getStore().saveBean(bean); |
162 | 161 |
|
163 | 162 |
if(changeEvent != null){ |
164 |
eventBus.publishEvent(changeEvent);
|
|
163 |
viewEventBus.publish(this, changeEvent);
|
|
165 | 164 |
} |
166 | 165 |
} catch (HibernateException e){ |
167 | 166 |
if(newAuthorityCreated != null){ |
... | ... | |
172 | 171 |
} |
173 | 172 |
|
174 | 173 |
/** |
175 |
* EditorPresneters for beans with transient properties should overwrite this method to
|
|
174 |
* EditorPresenters for beans with transient properties should overwrite this method to
|
|
176 | 175 |
* update the beanItem with the changes made to the transient properties. |
177 | 176 |
* <p> |
178 | 177 |
* This is necessary because Vaadin MethodProperties are readonly when no setter is |
... | ... | |
220 | 219 |
protected final void deleteBean(DTO bean){ |
221 | 220 |
EntityChangeEvent changeEvent = getStore().deleteBean(bean); |
222 | 221 |
if(changeEvent != null){ |
223 |
eventBus.publishEvent(changeEvent);
|
|
222 |
viewEventBus.publish(this, changeEvent);
|
|
224 | 223 |
} |
225 | 224 |
|
226 | 225 |
} |
Also available in: Unified diff
fix #7231 replacing SpringApplicationEventBus by scoped Vaadin4Spring Event Bus