1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.application.views.pageclicklistener;
20
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 import com.vaadin.data.fieldgroup.BeanFieldGroup;
25 import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
26 import com.vaadin.ui.Button.ClickEvent;
27 import com.vaadin.ui.Button.ClickListener;
28 import com.vaadin.ui.Notification;
29
30
31
32
33 public final class CommitFormWrapperClickListener implements ClickListener {
34
35
36 private static final String FORM_ERROR = "Form Error";
37
38
39 private static final long serialVersionUID = 1L;
40
41
42 private static final Logger LOGGER = LoggerFactory.getLogger(CommitFormWrapperClickListener.class);
43
44
45 private final BeanFieldGroup<?> fieldGroup;
46
47
48 private final ClickListener buttonListener;
49
50
51
52
53
54
55
56
57
58 public CommitFormWrapperClickListener(final BeanFieldGroup<?> fieldGroup, final ClickListener buttonListener) {
59 this.fieldGroup = fieldGroup;
60 this.buttonListener = buttonListener;
61 }
62
63 @Override
64 public void buttonClick(final ClickEvent event) {
65 try {
66 fieldGroup.commit();
67 } catch (final CommitException e) {
68 Notification.show(FORM_ERROR,
69 e.getMessage(),
70 Notification.Type.WARNING_MESSAGE);
71 LOGGER.warn(FORM_ERROR,e);
72 }
73 buttonListener.buttonClick(event);
74 }
75 }