Index: JDynFormFieldDynObjectList.java
===================================================================
--- JDynFormFieldDynObjectList.java	(revision 1404)
+++ JDynFormFieldDynObjectList.java	(revision 1405)
@@ -3,23 +3,22 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.tools.dynform.services.dynformfield.DynObjectList;
 
@@ -38,8 +37,10 @@
 import org.gvsig.tools.dynform.JDynFormField;
 import org.gvsig.tools.dynform.JDynFormSet;
 import org.gvsig.tools.dynform.JDynFormSet.JDynFormSetListener;
+import org.gvsig.tools.dynform.spi.AbstractJDynForm;
+import org.gvsig.tools.dynform.spi.AbstractJDynFormSet;
+import org.gvsig.tools.dynform.spi.DynFormSPIManager;
 import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField;
-import org.gvsig.tools.dynobject.DynClass;
 import org.gvsig.tools.dynobject.DynField;
 import org.gvsig.tools.dynobject.DynField_v2;
 import org.gvsig.tools.dynobject.DynObject;
@@ -48,185 +49,183 @@
 import org.gvsig.tools.service.spi.ServiceManager;
 
 public class JDynFormFieldDynObjectList extends AbstractJDynFormField implements JDynFormField, JDynFormListener, JDynFormSetListener, FocusListener {
-	
-	protected List assignedValue  = null;
-	protected List currentValue = null;
-	protected JDynFormSet jdynFormSet = null;
-	protected boolean readonly = false;
 
-	public JDynFormFieldDynObjectList(DynObject parameters,
-			ServiceManager serviceManager) {
-		super(parameters, serviceManager);
-		this.assignedValue = (List) this.getParameterValue();
-	}
+    protected List assignedValue = null;
+    protected List currentValue = null;
+    protected AbstractJDynFormSet jdynFormSet = null;
+    protected boolean readonly = false;
 
-	public void setReadOnly(boolean readonly) {
-		super.setReadOnly(readonly);
-		if( this.contents != null ) {
-			this.jdynFormSet.setReadOnly(readonly);
-		}
-	}
-	
-	public Object getAssignedValue() {
-		return this.assignedValue;
-	}
-	
-	public void initComponent() {
-		this.contents = new JPanel();
-		this.contents.setLayout(new BorderLayout());
-		try {
-			DynFormFieldDefinition def = this.getDefinition();
-			DynField_v2 fielddef = (DynField_v2)def;
-			DynStruct struct = fielddef.getDynClassOfItems();
-                        String viewMode = getTagValueAsString("ViewMode", "dynform.viewmode", "Subform");
-                        try{
-                                this.jdynFormSet = DynFormLocator.getDynFormManager().createJDynFormSet(viewMode,struct);
-                        } catch(Exception e){
-                                logger.warn("Error en la creación del DynFormSet '"+ viewMode +"'" , e);
-                                this.jdynFormSet = DynFormLocator.getDynFormManager().createJDynFormSet(struct);
-                        }
+    public JDynFormFieldDynObjectList(DynObject parameters,
+            ServiceManager serviceManager) {
+        super(parameters, serviceManager);
+        this.assignedValue = (List) this.getParameterValue();
+    }
 
-                        int height = getTagValueAsInt("dynform.height", -1);
-                        if( height>0 ) {
-                            this.jdynFormSet.setFormSize(50,height); 
-                        }
+    public void setReadOnly(boolean readonly) {
+        super.setReadOnly(readonly);
+        if (this.contents != null) {
+            this.jdynFormSet.setReadOnly(readonly);
+        }
+    }
 
-                        this.jdynFormSet.addListener(this);
-                        this.jdynFormSet.setLayoutMode(getTagValueAsInt("layoutMode", "dynform.layoutmode",JDynFormSet.USE_PLAIN));
-                        this.jdynFormSet.setAllowNew(getTagValueAsBoolean("allowNew", "dynform.action.new", false));
-                        this.jdynFormSet.setAllowUpdate(getTagValueAsBoolean("allowUpdate", "dynform.action.update", false));
-                        this.jdynFormSet.setAllowDelete(getTagValueAsBoolean("allowDelete", "dynform.action.delete", false));
-                        this.jdynFormSet.setAllowSearch(getTagValueAsBoolean("allowSearch", "dynform.action.search", false));
-			this.jdynFormSet.setAllowClose(false);
-			this.jdynFormSet.setUseScrollBars(false);
-//			this.jdynFormSet.setShowMessageStatus(false);
-//			this.jdynFormSet.addListener(this);
-			this.contents.add(jdynFormSet.asJComponent(),BorderLayout.CENTER);
-			this.contents.setVisible(true);
-			this.jdynFormSet.setReadOnly(readonly);
-			this.setValue(this.assignedValue);
-		} catch (Exception e) {
-			logger.warn("",e);
-		}
+    public Object getAssignedValue() {
+        return this.assignedValue;
+    }
+
+    public void initComponent() {
+        this.contents = new JPanel();
+        this.contents.setLayout(new BorderLayout());
+        try {
+            DynFormFieldDefinition def = this.getDefinition();
+            DynField_v2 fielddef = (DynField_v2) def;
+            DynStruct struct = fielddef.getDynClassOfItems();
+            String viewMode = getTagValueAsString("ViewMode", DynFormSPIManager.TAG_DYNFORM_VIEWMODE, "Subform");
+            try {
+                this.jdynFormSet = (AbstractJDynFormSet) DynFormLocator.getDynFormManager().createJDynFormSet(viewMode, struct);
+            } catch (Exception e) {
+                logger.warn("Error en la creación del DynFormSet '" + viewMode + "'", e);
+                this.jdynFormSet = (AbstractJDynFormSet) DynFormLocator.getDynFormManager().createJDynFormSet(struct);
+            }
+            this.jdynFormSet.loadDefaultValueFromTags(this.getDefinition().getTags());
+
+//            int height = getTagValueAsInt(DynFormSPIManager.TAG_DYNFORM_HEIGHT, -1);
+//            if (height > 0) {
+//                this.jdynFormSet.setFormSize(50, height);
+//            }
+
+            this.jdynFormSet.addListener(this);
+            this.contents.add(jdynFormSet.asJComponent(), BorderLayout.CENTER);
+            this.contents.setVisible(true);
+            this.setValue(this.assignedValue);
+        } catch (Exception e) {
+            logger.warn("", e);
+        }
 //		this.jdynForm.addFocusListener(this);
 
-	}
-	
-	
-	public void setValue(Object value) {
-		if( value == null ) {
+    }
+
+    public void setValue(Object value) {
+        if (value == null) {
 			// TODO
-			// this.jdynForm.clear();
-		} else {
-			if( !(value instanceof List) ) {
-				logger.info("setValue invoked with non List value ("+value.toString()+").");
-				return;
-			}
-			try {
-				this.jdynFormSet.setValues((List)value);
-			} catch (ServiceException e) {
-				logger.warn("Error settings values to DynformSet",e);
-			}
-		}
-		this.assignedValue = (List) value;
-		this.currentValue = this.assignedValue;
-	}
-	
-	public Object getValue() {
-		return this.jdynFormSet.getValues();
-	}
-	
-	public boolean hasValidValue() {
-		return this.jdynFormSet.hasValidValues();
-	}
+            // this.jdynForm.clear();
+        } else {
+            if (!(value instanceof List)) {
+                logger.info("setValue invoked with non List value (" + value.toString() + ").");
+                return;
+            }
+            try {
+                this.jdynFormSet.setValues((List) value);
+            } catch (ServiceException e) {
+                logger.warn("Error settings values to DynformSet", e);
+            }
+        }
+        this.assignedValue = (List) value;
+        this.currentValue = this.assignedValue;
+    }
 
-	public void focusGained(FocusEvent arg0) {
-		fireFieldEnterEvent();
-		this.problemIndicator().restore();
-	}
+    public Object getValue() {
+        return this.jdynFormSet.getValues();
+    }
 
-	public void focusLost(FocusEvent arg0) {
-		fireFieldExitEvent();
-	}
+    public boolean hasValidValue() {
+        return this.jdynFormSet.hasValidValues();
+    }
 
-	public void message(String message) {
-		fireMessageEvent(message);
-	}
+    public void focusGained(FocusEvent arg0) {
+        fireFieldEnterEvent();
+        this.problemIndicator().restore();
+    }
 
-	public void fieldChanged(JDynFormField field) {
+    public void focusLost(FocusEvent arg0) {
+        fireFieldExitEvent();
+    }
+
+    public void message(String message) {
+        fireMessageEvent(message);
+    }
+
+    public void fieldChanged(JDynFormField field) {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formMessage(String message) {
+    }
+
+    public void formMessage(String message) {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formClose() {
+    }
+
+    public void formClose() {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formMovedTo(int currentPosition) {
+    }
+
+    public void formMovedTo(int currentPosition) {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formBeforeSave(JDynFormSet dynformSet) throws AbortActionException {
+    }
+
+    public void formBeforeSave(JDynFormSet dynformSet) throws AbortActionException {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formBeforeNew(JDynFormSet dynformSet) throws AbortActionException {
-		DynFormFieldDefinition def = this.getDefinition();
-		DynField_v2 fielddef = (DynField_v2)def;
-		DynStruct struct = fielddef.getDynClassOfItems();
-		DynObject value = createDynObject(struct);
-		this.currentValue.add(value);
+    }
 
-		
-	}
-	
-	private DynObject createDynObject(DynStruct dynStruct){
-		DynObject value = ToolsLocator.getDynObjectManager().createDynObject(dynStruct);
-		DynField[] fields = dynStruct.getDynFields();
-		for(int i=0;i<fields.length; i++){
-			DynField_v2 field = (DynField_v2) fields[i];
-			if(field.getDataType().isDynObject()){
-				value.setDynValue(field.getName(), createDynObject(field.getDynClassOfValue()));
-			}
-		}
-		return value;
-	}
+    public void formBeforeNew(JDynFormSet dynformSet) throws AbortActionException {
+        DynFormFieldDefinition def = this.getDefinition();
+        DynField_v2 fielddef = (DynField_v2) def;
+        DynStruct struct = fielddef.getDynClassOfItems();
+        DynObject value = createDynObject(struct);
+        this.currentValue.add(value);
+    }
 
-	public void formBeforeDelete(JDynFormSet dynformSet) throws AbortActionException {
-		this.currentValue.remove(dynformSet.getCurrentIndex());
-	}
+    public void formBeforeCancelNew(JDynFormSet dynformSet) throws AbortActionException {
+		// TODO Auto-generated method stub
 
-	public void formBeforeSearch(JDynFormSet dynformSet) throws AbortActionException {
+    }
+
+    private DynObject createDynObject(DynStruct dynStruct) {
+        DynObject value = ToolsLocator.getDynObjectManager().createDynObject(dynStruct);
+        DynField[] fields = dynStruct.getDynFields();
+        for (int i = 0; i < fields.length; i++) {
+            DynField_v2 field = (DynField_v2) fields[i];
+            if (field.getDataType().isDynObject()) {
+                value.setDynValue(field.getName(), createDynObject(field.getDynClassOfValue()));
+            }
+        }
+        return value;
+    }
+
+    public void formBeforeDelete(JDynFormSet dynformSet) throws AbortActionException {
+        this.currentValue.remove(dynformSet.getCurrentIndex());
+    }
+
+    public void formBeforeSearch(JDynFormSet dynformSet) throws AbortActionException {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formAfterSave(JDynFormSet dynformSet) {
+    }
+
+    public void formAfterSave(JDynFormSet dynformSet) {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formAfterNew(JDynFormSet dynformSet) {
+    }
+
+    public void formAfterNew(JDynFormSet dynformSet) {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formAfterDelete(JDynFormSet dynformSet) {
+    }
+
+    public void formAfterCancelNew(JDynFormSet dynformSet) {
 		// TODO Auto-generated method stub
-		
-	}
 
-	public void formAfterSearch(JDynFormSet dynformSet) {
+    }
+
+    public void formAfterDelete(JDynFormSet dynformSet) {
 		// TODO Auto-generated method stub
-		
-	}
-	
+
+    }
+
+    public void formAfterSearch(JDynFormSet dynformSet) {
+		// TODO Auto-generated method stub
+
+    }
+
 }
