Project

General

Profile

Revision 1952d4c7

ID1952d4c7a2112004dce88808bf8ac46b4c821e52
Parent 532beab7
Child d7e9db79

Added by Andreas Kohlbecker over 2 years ago

ref #6169 documenting bean nesting in ToManyRelatedEntitiesListSelect

View differences:

src/main/java/eu/etaxonomy/vaadin/component/ToManyRelatedEntitiesListSelect.java
10 10

  
11 11
import java.util.List;
12 12

  
13
import org.apache.log4j.Logger;
14

  
13 15
import com.vaadin.data.fieldgroup.FieldGroup;
14 16
import com.vaadin.data.util.BeanItemContainer;
15 17
import com.vaadin.server.FontAwesome;
......
30 32

  
31 33
    private static final long serialVersionUID = 4670707714503199599L;
32 34

  
35
    private static final Logger logger = Logger.getLogger(ToManyRelatedEntitiesListSelect.class);
36

  
33 37
    protected Class<F> fieldType;
34 38

  
35 39
    protected Class<V> itemType;
......
43 47
    //NOTE: Managing the item
44 48
    //      IDs makes BeanContainer more complex to use, but it is necessary in some cases where the
45 49
    //      equals() or hashCode() methods have been reimplemented in the bean.
46
    //      TODO CdmBase an a reimplemented equals method, do we need to use the BeanContainer instead?
50
    //      TODO CdmBase has a reimplemented equals method, do we need to use the BeanContainer instead?
47 51
    private BeanItemContainer<V> beans;
48 52

  
49 53
   //private LinkedList<V> itemList = new LinkedList<>();
......
144 148
    protected void setInternalValue(List<V> newValue) {
145 149
        super.setInternalValue(newValue);
146 150

  
147
        // newValue is already converted, need to use the original value from the dataasource
151
        // newValue is already converted, need to use the original value from the data source
148 152
        isOrderedCollection = List.class.isAssignableFrom(getPropertyDataSource().getValue().getClass());
149 153

  
150 154
        beans.addAll(newValue);
......
180 184
    }
181 185

  
182 186
    /**
187
     *
183 188
     * @param val
184 189
     * @return
185 190
     * @throws InstantiationException
......
193 198
    }
194 199

  
195 200
    /**
201
     * Handle the data binding of the sub fields. Sub-fields can either be composite editor fields
202
     * or 'simple' fields, usually select fields.
203
     * <p>
204
     * Composite editor fields allow editing the nested bean Items and must implement the
205
     * {@link NestedFieldGroup} interface. Simple fields are only instantiated in
206
     * {@link #newFieldInstance(Object)} where the value of the field is set. No further binding is needed
207
     * for these 'simple' fields.
208
     *
196 209
     * @param field
197 210
     */
198 211
    protected void nestFieldGroup(F field) {
......
203 216

  
204 217
    /**
205 218
     * {@inheritDoc}
219
     * <p>
220
     * However, this class has no local fieldGroup but must delegate to the nested NestedFieldGroup
221
     * if there are any. This happens in {@link #nestFieldGroup(AbstractField)}.
222
     * <p>
223
     */
224
    @Override
225
    public FieldGroup getFieldGroup() {
226
        return null;
227
    }
228

  
229
    /**
230
     * This ToMany-CompositeCustomField has no own fields and this no local fieldGroup (see {@link #getFieldGroup()})
231
     * which allow changing data. Editing of the list items is delegated to
232
     * a list of sub-fields which are responsible for editing and committing the changes.
233
     * Therefore the <code>parentFieldGroup</code> is only stored in a local field so that it can
234
     * be passed to per item fields in {@link #nestFieldGroup}
235
     *
236
     * {@inheritDoc}
237
     */
238
    @Override
239
    public void registerParentFieldGroup(FieldGroup parent) {
240
        parentFieldGroup = parent;
241
    }
242

  
243
    /**
244
     * {@inheritDoc}
206 245
     */
207 246
    @Override
208 247
    public void setWidth(String width) {
......
226 265
        // no default styles
227 266
    }
228 267

  
229
    /**
230
     * {@inheritDoc}
231
     * <p>
232
     * However, this class has no local fieldGroup but must delegate to the nested NestedFieldGroup
233
     * if there are any. This happens in {@link #nestFieldGroup(AbstractField)}.
234
     * <p>
235
     */
236
    @Override
237
    public FieldGroup getFieldGroup() {
238
        return null;
239
    }
240

  
241
    @Override
242
    public void registerParentFieldGroup(FieldGroup parent) {
243
        parentFieldGroup = parent;
244
    }
245

  
246 268
    public void withEditButton(boolean withEditButton){
247 269
        this.withEditButton = withEditButton;
248 270
    }
249 271

  
250

  
251

  
252

  
253

  
254

  
255

  
256

  
257 272
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)