");
+
+
+ HtmlInputText inputText = new HtmlInputText();
+ inputText.setParent(this);
+ // inputText.setId(this.getId() + ":_text1");
+ inputText.encodeBegin(context);
+ inputText.encodeEnd(context);
+
+ if (inputText.getRendersChildren()) {
+ for (UIComponent child:inputText.getChildren()) {
+ child.encodeBegin(context);
+ child.encodeEnd(context);
+ }
+ }
+
+ }
+
+
+ public void restoreState(FacesContext context, Object state) {
+ this.state = (Object[]) state;
+ super.restoreState(context, this.state[0]);
+ bar = (String) this.state[1];
+ }
+
+ public Object saveState(FacesContext context) {
+ if (state == null) {
+ state = new Object[2];
+ }
+ state[0] = super.saveState(context);
+ state[1] = bar;
+ return state;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/frontends/web/jsf/VascUIComponentTag.java b/src/com/idcanet/vasc/frontends/web/jsf/VascUIComponentTag.java
new file mode 100644
index 0000000..4383c47
--- /dev/null
+++ b/src/com/idcanet/vasc/frontends/web/jsf/VascUIComponentTag.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004-2007 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.frontends.web.jsf;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+import javax.faces.webapp.UIComponentTag;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 16, 2008
+ */
+public class VascUIComponentTag extends UIComponentTag {
+
+ protected ValueExpression bar;
+
+ public String getComponentType() {
+ return VascUIComponent.COMPONENT_TYPE;
+ }
+
+ public String getRendererType() {
+ return VascUIComponent.COMPONENT_TYPE;
+ }
+
+ public ValueExpression getBar() {
+ return bar;
+ }
+
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ VascUIComponent download = null;
+ try {
+ //foo = (VascUIComponent) component;
+ } catch (ClassCastException cce) {
+ throw new IllegalStateException("Component " + component.toString() +
+ " not expected type. Expected: com.foo.Foo. Perhaps you're missing a tag?");
+ }
+
+ if (bar != null) {
+ //foo.setValueExpression("bar", bar);
+ }
+ }
+
+ public void release() {
+ super.release();
+ bar = null;
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/DefaultVascBackedEntryFinalizer.java b/src/com/idcanet/vasc/impl/DefaultVascBackedEntryFinalizer.java
index 7553483..eb8576c 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascBackedEntryFinalizer.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascBackedEntryFinalizer.java
@@ -26,12 +26,12 @@
package com.idcanet.vasc.impl;
-import java.util.Date;
-
+import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldSet;
+import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.VascEntryFinalizer;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascLinkEntry;
@@ -67,6 +67,13 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
}
}
+ // Check if backendId is valid
+ VascBackend back = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() );
+ if (back==null) {
+ throw new IllegalArgumentException("The VascEntry backendId is not found in backends: '"+entry.getBackendId()+"'");
+ }
+
+
// Fill up all not field i18n keys
String id = entry.getId();
@@ -183,18 +190,26 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
}
if (vef.getVascEntryFieldValue()==null) {
- vef.setVascEntryFieldValue( vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() ).provideVascEntryFieldValue(vef) );
+ VascBackend back2 = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() );
+ vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef));
}
- if (vef.getVascEntryFieldType()==null) {
-
-
- vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField"));
-
- if (vef.getDefaultValue() instanceof Boolean) {
- ///vef.setVascEntryFieldType(vascEntryFieldType);
- } else if (vef.getDefaultValue() instanceof Date) {
- } else {
+ if (vef.getVascEntryFieldType()==null) {
+ Object defValue = vef.getDefaultValue();
+ if (defValue != null) {
+ for (String typeId: vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
+ VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
+
+ if (type.getAutoDetectClass()!=null) {
+ if (type.getAutoDetectClass().isAssignableFrom(defValue.getClass())) {
+ vef.setVascEntryFieldType(type);
+ break;
+ }
+ }
+ }
+ }
+ if (vef.getVascEntryFieldType()==null) {
+ vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField"));
}
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
}
diff --git a/src/com/idcanet/vasc/impl/DefaultVascBackendController.java b/src/com/idcanet/vasc/impl/DefaultVascBackendController.java
index c52c9ce..451a031 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascBackendController.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascBackendController.java
@@ -30,7 +30,7 @@ import java.util.HashMap;
import java.util.Map;
import com.idcanet.vasc.core.VascBackend;
-import com.idcanet.vasc.core.VascBackendController;
+import com.idcanet.vasc.core.VascBackendControllerLocal;
/**
*
@@ -38,7 +38,7 @@ import com.idcanet.vasc.core.VascBackendController;
* @author Willem Cazander
* @version 1.0 Sep 18, 2008
*/
-public class DefaultVascBackendController implements VascBackendController {
+public class DefaultVascBackendController implements VascBackendControllerLocal {
private Map backends = null;
@@ -53,6 +53,9 @@ public class DefaultVascBackendController implements VascBackendController {
return backends.get(id);
}
+ /**
+ * Local
+ */
public void addVascBackend(VascBackend backend) {
if (backend==null) {
throw new NullPointerException("backend must not be null.");
diff --git a/src/com/idcanet/vasc/impl/DefaultVascController.java b/src/com/idcanet/vasc/impl/DefaultVascController.java
index 92f5508..aa370b3 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascController.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascController.java
@@ -30,6 +30,7 @@ import com.idcanet.vasc.core.VascBackendControllerResolver;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntryControllerResolver;
import com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver;
+import com.idcanet.vasc.core.VascEventChannelControllerResolver;
/**
*
@@ -42,7 +43,23 @@ public class DefaultVascController implements VascController {
private VascBackendControllerResolver vascBackendControllerResolver = null;
private VascEntryControllerResolver vascEntryControllerResolver = null;
private VascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = null;
+ private VascEventChannelControllerResolver vascEventChannelControllerResolver = null;
+ /**
+ * @return the vascEventChannelControllerResolver
+ */
+ public VascEventChannelControllerResolver getVascEventChannelControllerResolver() {
+ return vascEventChannelControllerResolver;
+ }
+
+ /**
+ * @param vascEventChannelControllerResolver the vascEventChannelControllerResolver to set
+ */
+ public void setVascEventChannelControllerResolver(
+ VascEventChannelControllerResolver vascEventChannelControllerResolver) {
+ this.vascEventChannelControllerResolver = vascEventChannelControllerResolver;
+ }
+
/**
* @return the vascBackendControllerResolver
*/
diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryController.java b/src/com/idcanet/vasc/impl/DefaultVascEntryController.java
index 59b2372..39367fe 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascEntryController.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascEntryController.java
@@ -33,7 +33,7 @@ import java.util.Map;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
-import com.idcanet.vasc.core.VascEntryController;
+import com.idcanet.vasc.core.VascEntryControllerLocal;
import com.idcanet.vasc.core.VascException;
/**
@@ -42,7 +42,7 @@ import com.idcanet.vasc.core.VascException;
* @author Willem Cazander
* @version 1.0 Sep 18, 2008
*/
-public class DefaultVascEntryController implements VascEntryController {
+public class DefaultVascEntryController implements VascEntryControllerLocal {
private Map entries = null;
diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryField.java b/src/com/idcanet/vasc/impl/DefaultVascEntryField.java
index 86d3b61..108d830 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascEntryField.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascEntryField.java
@@ -95,7 +95,7 @@ public class DefaultVascEntryField implements VascEntryField {
}
public DefaultVascEntryField(String id) {
- super();
+ this();
setId(id);
}
diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java b/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java
index 1a9b6af..918bf1a 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascEntryFieldSet.java
@@ -26,6 +26,7 @@
package com.idcanet.vasc.impl;
+import java.util.ArrayList;
import java.util.List;
import com.idcanet.vasc.core.VascEntryFieldSet;
@@ -52,6 +53,10 @@ public class DefaultVascEntryFieldSet implements VascEntryFieldSet {
private List vascEntryFieldIds = null;
+ public DefaultVascEntryFieldSet() {
+ vascEntryFieldIds = new ArrayList(10);
+ }
+
/**
* @return the id
*/
diff --git a/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java b/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java
index 2c745fc..26c9fa1 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java
@@ -31,12 +31,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.idcanet.vasc.core.VascBackend;
+import com.idcanet.vasc.core.VascController;
+import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFinalizer;
+import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontend;
import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.VascFrontendHelper;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
+import com.idcanet.vasc.core.ui.VascUIComponent;
/**
@@ -46,7 +49,6 @@ import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
*/
public class DefaultVascFrontendData implements VascFrontendData {
- private VascBackend vascBackend = null;
private List entryDataList = null;
private Object entryDataObject = null;
private VascFrontend vascFrontend = null;
@@ -54,26 +56,19 @@ public class DefaultVascFrontendData implements VascFrontendData {
private VascFrontendHelper vascFrontendHelper = null;
private VascEntryResourceResolver vascEntryResourceResolver = null;
private Map uiComponents = null;
+ private VascController vascController = null;
+
+ private Map fieldComps = null;
+ private Map fieldEditors = null;
public DefaultVascFrontendData() {
entryDataList = new ArrayList(0);
uiComponents = new HashMap(8);
+
+ fieldComps = new HashMap(8);
+ fieldEditors = new HashMap(8);
}
-
- /**
- * @return the vascBackend
- */
- public VascBackend getVascBackend() {
- return vascBackend;
- }
-
- /**
- * @param vascBackend the vascBackend to set
- */
- public void setVascBackend(VascBackend vascBackend) {
- this.vascBackend = vascBackend;
- }
-
+
/**
* @return the entryDataList
*/
@@ -158,10 +153,27 @@ public class DefaultVascFrontendData implements VascFrontendData {
this.vascEntryResourceResolver = vascEntryResourceResolver;
}
+
+ public VascUIComponent getVascUIComponent(String rendererId) throws VascException {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) {
+ cl = rendererId.getClass().getClassLoader(); // fallback
+ }
+ String componentClass = getVascUIComponentClass(rendererId);
+ if (componentClass==null) {
+ throw new VascException("No component Class found for frontend UIComponent: "+rendererId);
+ }
+ try {
+ return (VascUIComponent)cl.loadClass(componentClass).newInstance();
+ } catch (Exception e) {
+ throw new VascException(e);
+ }
+ }
+
/**
* @see com.idcanet.vasc.core.VascFrontendData#getVascUIComponent(java.lang.String)
*/
- public String getVascUIComponent(String rendererId) {
+ public String getVascUIComponentClass(String rendererId) {
return uiComponents.get(rendererId);
}
@@ -171,4 +183,40 @@ public class DefaultVascFrontendData implements VascFrontendData {
public void putVascUIComponent(String rendererId, String uiComponentClass) {
uiComponents.put(rendererId, uiComponentClass);
}
+
+ /**
+ * @return the vascController
+ */
+ public VascController getVascController() {
+ return vascController;
+ }
+
+ /**
+ * @param vascController the vascController to set
+ */
+ public void setVascController(VascController vascController) {
+ this.vascController = vascController;
+ }
+
+ /**
+ * @see com.idcanet.vasc.core.VascFrontendData#addFieldVascUIComponents(com.idcanet.vasc.core.VascEntryField, com.idcanet.vasc.core.ui.VascUIComponent, java.lang.Object)
+ */
+ public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent, Object editor) {
+ fieldComps.put(field, uiComponent);
+ fieldEditors.put(field, editor);
+ }
+
+ /**
+ * @see com.idcanet.vasc.core.VascFrontendData#getFieldRealRenderer(com.idcanet.vasc.core.VascEntryField)
+ */
+ public Object getFieldRealRenderer(VascEntryField field) {
+ return fieldEditors.get(field);
+ }
+
+ /**
+ * @see com.idcanet.vasc.core.VascFrontendData#getFieldVascUIComponent(com.idcanet.vasc.core.VascEntryField)
+ */
+ public VascUIComponent getFieldVascUIComponent(VascEntryField field) {
+ return fieldComps.get(field);
+ }
}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java b/src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java
index f431651..099742f 100644
--- a/src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java
+++ b/src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java
@@ -34,6 +34,8 @@ import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascFrontendHelper;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
+import com.idcanet.vasc.core.ui.VascUIComponent;
+import com.idcanet.vasc.validators.VascValidator;
/**
@@ -117,7 +119,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (object!=null) {
return object;
}
- object = entry.getVascFrontendData().getVascBackend().provideVascEntryRecordCreator(entry).newRecord(entry);
+ object = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).provideVascEntryRecordCreator(entry).newRecord(entry);
//fireVascEvent(VascEventListener.VascEventType.BEAN_INIT, object);
return object;
}
@@ -143,7 +145,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
public Object mergeObject(VascEntry entry, Object object) {
Object result = null;
try {
- object = entry.getVascFrontendData().getVascBackend().merge(object);
+ object = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).merge(object);
//fireVascEvent(VascEventListener.VascEventType.BEAN_MERGE,object);
// todo: make faster
// add to table at position old old object
@@ -162,7 +164,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
*/
public void refreshData(VascEntry entry) throws Exception {
entry.getVascFrontendData().setEntryDataObject(null);
- entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascBackend().execute());
+ entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).execute());
//fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, null);
}
@@ -197,6 +199,32 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
//logger.fine("Got invaliled value: "+ival.length);
for(VascEntryField col:entry.getVascEntryFields()) {
+
+ try {
+ Object object = col.getVascEntryFieldValue().getValue(col, bean);
+ VascUIComponent comp = entry.getVascFrontendData().getFieldVascUIComponent(col);
+
+ for (VascValidator val:col.getVascEntryFieldType().getVascValidators()) {
+ if (val.isObjectValid(object)==false) {
+ comp.setErrorText("error");
+ error = true;
+ } else {
+ comp.setErrorText(null);
+ }
+ }
+
+ for (VascValidator val:col.getVascValidators()) {
+ if (val.isObjectValid(object)==false) {
+ comp.setErrorText("error");
+ error = true;
+ } else {
+ comp.setErrorText(null);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
/*
if(col.getVascUIComponent()==null) {
continue; // we only DISPLAY user input errors !!
diff --git a/src/com/idcanet/vasc/impl/DefaultVascLinkEntry.java b/src/com/idcanet/vasc/impl/DefaultVascLinkEntry.java
new file mode 100644
index 0000000..607b829
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/DefaultVascLinkEntry.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004-2008 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl;
+
+import com.idcanet.vasc.core.VascLinkEntry;
+
+
+/**
+ * The DefaultVascLinkEntry
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 27, 2007
+ */
+public class DefaultVascLinkEntry implements VascLinkEntry {
+
+ private String vascEntryName = null;
+
+ /**
+ * @return the vascEntryName
+ */
+ public String getVascEntryName() {
+ return vascEntryName;
+ }
+
+ /**
+ * @param vascEntryName the vascEntryName to set
+ */
+ public void setVascEntryName(String vascEntryName) {
+ this.vascEntryName = vascEntryName;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/type/MultiTextVascEntryFieldType.java b/src/com/idcanet/vasc/impl/type/MultiTextVascEntryFieldType.java
new file mode 100644
index 0000000..87c9c52
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/type/MultiTextVascEntryFieldType.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2004-2007 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl.type;
+
+import java.util.List;
+
+import com.idcanet.vasc.core.VascEntryField;
+import com.idcanet.vasc.core.VascException;
+import com.idcanet.vasc.core.ui.VascValueModel;
+
+
+/**
+ * Custem FieldType for multi text values.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 17, 2008
+ */
+public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
+
+ private Object getIndexValue(VascEntryField entryField,int index) throws VascException {
+ Object record = entryField.getVascEntry().getVascFrontendData().getEntryDataObject();
+ Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
+
+ if (value instanceof List) {
+ return ((List)value).get(index);
+ }
+ if (value instanceof String[]) {
+ if (index >= ((String[])value).length ) {
+ return "";
+ }
+ return ((String[])value)[index];
+ }
+ if (value instanceof String) {
+ return ((String)value);
+ }
+ throw new VascException("Unknown object type");
+ }
+
+ private void setIndexValue(VascEntryField entryField,int index,Object newValue) throws VascException {
+ Object record = entryField.getVascEntry().getVascFrontendData().getEntryDataObject();
+ Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
+
+ if (value instanceof List) {
+ ((List)value).set(index, newValue);
+ return;
+ }
+ if (value instanceof String[]) {
+
+ if (index+1 > ((String[])value).length ) {
+ String[] n = new String[index+1];
+ for (int i=0;i<((String[])value).length;i++) {
+ n[i]= ((String[])value)[i];
+ }
+ value = n;
+ }
+ ((String[])value)[index] = newValue.toString();
+ return;
+ }
+ if (value instanceof String) {
+ value = new String[] { (String)value };
+ return;
+ }
+ throw new VascException("Unknown object type: "+value);
+ }
+
+ /**
+ * @see com.idcanet.vasc.core.AbstractVascEntryFieldType#getUIComponentCount(com.idcanet.vasc.core.VascEntryField)
+ */
+ @Override
+ public int getUIComponentCount(VascEntryField entryField) throws VascException {
+
+
+ Object record = entryField.getVascEntry().getVascFrontendData().getEntryDataObject();
+ Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
+
+ if (value instanceof List) {
+ return ((List)value).size()+1;
+ }
+ if (value instanceof String[]) {
+ return ((String[])value).length+1;
+ }
+ if (value instanceof String) {
+ return 1+1;
+ }
+ throw new VascException("Unknown object type: "+value);
+ }
+
+ /**
+ * @see com.idcanet.vasc.core.AbstractVascEntryFieldType#provideEditorVascValueModel(int, com.idcanet.vasc.core.VascEntryField)
+ */
+ @Override
+ public VascValueModel provideEditorVascValueModel(final int index,final VascEntryField entryField) {
+ VascValueModel model = new VascValueModel() {
+ public Object getValue() throws VascException {
+ Object value = getIndexValue(entryField,index);
+ return value;
+ }
+
+ public void setValue(Object value) throws VascException {
+ setIndexValue(entryField,index,value);
+ super.setValue(value);
+ }
+ };
+
+ return model;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/x4o/VascBackendElementConfigurator.java b/src/com/idcanet/vasc/impl/x4o/VascBackendElementConfigurator.java
new file mode 100644
index 0000000..6fa28a7
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/x4o/VascBackendElementConfigurator.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004-2008 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl.x4o;
+
+import com.idcanet.vasc.core.VascBackend;
+import com.idcanet.vasc.core.VascBackendController;
+import com.idcanet.vasc.core.VascBackendControllerLocal;
+import com.idcanet.vasc.core.VascController;
+
+import com.idcanet.x4o.element.AbstractElementConfigurator;
+import com.idcanet.x4o.element.Element;
+import com.idcanet.x4o.element.ElementConfiguratorException;
+
+
+/**
+ * Adds the backend to the local controller
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 16, 2008
+ */
+public class VascBackendElementConfigurator extends AbstractElementConfigurator {
+
+ /**
+ * @see com.idcanet.x4o.element.AbstractElementConfigurator#doConfigEndTag(com.idcanet.x4o.element.Element)
+ */
+ @Override
+ public void doConfigEndTag(Element element) throws ElementConfiguratorException {
+
+ VascBackend backend = (VascBackend)element.getElementObject();
+
+ VascController vascController = VascParser.getVascController(element.getElementContext());
+ VascBackendController backendController = vascController.getVascBackendControllerResolver().getVascBackendController();
+
+ if (backendController instanceof VascBackendControllerLocal) {
+ try {
+ ((VascBackendControllerLocal)backendController).addVascBackend(backend);
+ } catch (Exception e) {
+ throw new ElementConfiguratorException(this,"Couln't add backend: "+e.getMessage(),e);
+ }
+ } else {
+ throw new ElementConfiguratorException(this,"Can not add backend '"+backend.getId()+"' to VascBackendController because we have no access to VascBackendControllerLocal interface.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/x4o/VascEntryElementConfigurator.java b/src/com/idcanet/vasc/impl/x4o/VascEntryElementConfigurator.java
new file mode 100644
index 0000000..93fde9c
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/x4o/VascEntryElementConfigurator.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004-2008 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl.x4o;
+
+import com.idcanet.vasc.core.VascController;
+import com.idcanet.vasc.core.VascEntry;
+import com.idcanet.vasc.core.VascEntryController;
+import com.idcanet.vasc.core.VascEntryControllerLocal;
+import com.idcanet.vasc.core.VascException;
+import com.idcanet.x4o.element.AbstractElementConfigurator;
+import com.idcanet.x4o.element.Element;
+import com.idcanet.x4o.element.ElementConfiguratorException;
+
+
+/**
+ * Converts the type to the type object
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 16, 2008
+ */
+public class VascEntryElementConfigurator extends AbstractElementConfigurator {
+
+ /**
+ * @see com.idcanet.x4o.element.AbstractElementConfigurator#doConfigEndTag(com.idcanet.x4o.element.Element)
+ */
+ @Override
+ public void doConfigEndTag(Element element) throws ElementConfiguratorException {
+
+ VascEntry entry = (VascEntry)element.getElementObject();
+
+ VascController vascController = VascParser.getVascController(element.getElementContext());
+ VascEntryController entryController = vascController.getVascEntryControllerResolver().getVascEntryController();
+
+ if (entryController instanceof VascEntryControllerLocal) {
+ try {
+ ((VascEntryControllerLocal)entryController).addVascEntry(entry, vascController);
+ } catch (VascException e) {
+ throw new ElementConfiguratorException(this,"Couln't add entry: "+e.getMessage(),e);
+ }
+ } else {
+ throw new ElementConfiguratorException(this,"Can not add entry '"+entry.getId()+"' to VascEntryController because we have no access to VascEntryControllerLocal interface.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/x4o/VascEntryFieldSetParameterConverter.java b/src/com/idcanet/vasc/impl/x4o/VascEntryFieldSetParameterConverter.java
new file mode 100644
index 0000000..60655b6
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/x4o/VascEntryFieldSetParameterConverter.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004-2008 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl.x4o;
+
+import com.idcanet.vasc.core.VascEntryFieldSet;
+import com.idcanet.x4o.element.AbstractElementParameterConverter;
+import com.idcanet.x4o.element.Element;
+import com.idcanet.x4o.element.ElementParameterConverterException;
+
+
+/**
+ * Converts the VascEntryFieldSet parameter
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 17, 2008
+ */
+public class VascEntryFieldSetParameterConverter extends AbstractElementParameterConverter {
+
+ /**
+ * @see com.idcanet.x4o.element.AbstractElementParameterConverter#doConvertParameter(com.idcanet.x4o.element.Element, java.lang.Object)
+ */
+ @Override
+ public Object doConvertParameter(Element element, Object parameterValue) throws ElementParameterConverterException {
+
+ if (parameterValue==null) {
+ throw new NullPointerException("can't convert null parameter");
+ }
+ if ("".equals(parameterValue)) {
+ return null;
+ }
+ String[] ids = parameterValue.toString().split(",");
+
+ VascEntryFieldSet set = (VascEntryFieldSet)element.getElementObject();
+ for (String id:ids) {
+ set.addVascEntryFieldId(id);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/x4o/VascEntryFieldTypeParameterConverter.java b/src/com/idcanet/vasc/impl/x4o/VascEntryFieldTypeParameterConverter.java
new file mode 100644
index 0000000..1e60f03
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/x4o/VascEntryFieldTypeParameterConverter.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004-2008 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl.x4o;
+
+import com.idcanet.vasc.core.VascController;
+import com.idcanet.x4o.element.AbstractElementParameterConverter;
+import com.idcanet.x4o.element.Element;
+import com.idcanet.x4o.element.ElementParameterConverterException;
+
+
+/**
+ * Converts the type to the type object
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 16, 2008
+ */
+public class VascEntryFieldTypeParameterConverter extends AbstractElementParameterConverter {
+
+ /**
+ * @see com.idcanet.x4o.element.AbstractElementParameterConverter#doConvertParameter(com.idcanet.x4o.element.Element, java.lang.Object)
+ */
+ @Override
+ public Object doConvertParameter(Element element, Object parameterValue) throws ElementParameterConverterException {
+
+ if (parameterValue==null) {
+ throw new NullPointerException("can't convert null parameter");
+ }
+ if ("".equals(parameterValue)) {
+ parameterValue = "TextField"; // ??
+ }
+ String fieldID = parameterValue.toString();
+
+ VascController controller = VascParser.getVascController(element.getElementContext());
+ Object result = controller.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID);
+
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/vasc/impl/x4o/VascParser.java b/src/com/idcanet/vasc/impl/x4o/VascParser.java
new file mode 100644
index 0000000..b796ea9
--- /dev/null
+++ b/src/com/idcanet/vasc/impl/x4o/VascParser.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004-2008 IDCA. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
+ * the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the authors and
+ * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
+ */
+
+package com.idcanet.vasc.impl.x4o;
+
+import java.io.IOException;
+import javax.el.ValueExpression;
+import javax.xml.parsers.ParserConfigurationException;
+import org.xml.sax.SAXException;
+
+import com.idcanet.vasc.core.VascController;
+import com.idcanet.x4o.core.X4OParser;
+import com.idcanet.x4o.element.ElementContext;
+
+/**
+ * Parses the vasc xml streams
+ *
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Oct 27, 2008
+ */
+public class VascParser extends X4OParser {
+
+ static public String VASC_LANGUAGE = "vasc";
+ private VascController vascController = null;
+
+ /**
+ * @see X4OParser#X4OParser(String)
+ */
+ public VascParser(VascController vascController) throws Exception {
+ super(VASC_LANGUAGE);
+ if (vascController==null) {
+ throw new NullPointerException("vascController may not be null");
+ }
+ this.vascController=vascController;
+ }
+
+ public VascController getVascController() {
+ return vascController;
+ }
+
+ static public VascController getVascController(ElementContext context) {
+ ValueExpression ee = context.getExpressionFactory().createValueExpression(context.getELContext(),"${vascController}", VascController.class);
+ VascController con = (VascController)ee.getValue(context.getELContext());
+ return con;
+ }
+
+ protected void preStartParsing() throws ParserConfigurationException,SAXException,IOException {
+ super.preStartParsing();
+
+ // Add the controller to EL
+ ValueExpression ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${vascController}", VascController.class);
+ ee.setValue(getElementContext().getELContext(), vascController);
+ }
+}
\ No newline at end of file
diff --git a/tests/META-INF/vasc-lang.eld b/tests/META-INF/vasc-lang.eld
deleted file mode 100644
index c19c954..0000000
--- a/tests/META-INF/vasc-lang.eld
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/META-INF/vasc-namespaces.xml b/tests/META-INF/vasc-namespaces.xml
deleted file mode 100644
index 01ac3aa..0000000
--- a/tests/META-INF/vasc-namespaces.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
- Vasc namespace for x4o vasc state/table/column language
-
- META-INF/vasc-lang.eld
-
\ No newline at end of file
diff --git a/tests/com/idcanet/vasc/SwingTest.java b/tests/com/idcanet/vasc/SwingTest.java
index 5df6d2e..657a27f 100644
--- a/tests/com/idcanet/vasc/SwingTest.java
+++ b/tests/com/idcanet/vasc/SwingTest.java
@@ -26,10 +26,15 @@
package com.idcanet.vasc;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.InputStream;
import java.util.logging.LogManager;
import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
import javax.swing.JPanel;
import com.idcanet.vasc.core.VascEntry;
@@ -57,16 +62,43 @@ public class SwingTest extends TestCase {
public void testAll() throws Exception {
JFrame.setDefaultLookAndFeelDecorated(false);
+ VascEntry entry = TestTable.getVascTable();
+ JFrame frame = viewEntry(entry);
+ while (frame.isVisible()) {
+ Thread.sleep(1000);
+ }
+ }
+
+ public JFrame viewEntry(final VascEntry entry) throws Exception {
// get GUI
JFrame frame = new JFrame();
- frame.setTitle("Vasc Test - Swing");
+ frame.setTitle("Vasc Test - Swing - "+entry.getName());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(null);
-
- // get table
- VascEntry entry = TestTable.getVascTable();
-
+
+ JMenuBar menubar = new JMenuBar();
+ JMenu vascMenu = new JMenu("Vasc Entries");
+
+ for (final String id:entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryIds()) {
+ JMenuItem item = new JMenuItem(id);
+ item.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(id);
+ TestTable.fill(ee,entry.getVascFrontendData().getVascController());
+ viewEntry(ee);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ });
+ vascMenu.add(item);
+ }
+ menubar.add(vascMenu);
+ frame.setJMenuBar(menubar);
+
// define redering
JPanel panel = new JPanel();
SwingVascFrontend render = new SwingVascFrontend(panel);
@@ -74,18 +106,12 @@ public class SwingTest extends TestCase {
// render
render.initEntry(entry);
-
- //table.getTableColumns().get(0).set
-
- //render.renderEdit(table.getTableData().get(0));
render.renderView();
// view
frame.pack();
frame.setVisible(true);
- while (frame.isVisible()) {
- Thread.sleep(1000);
- }
+ return frame;
}
}
\ No newline at end of file
diff --git a/tests/com/idcanet/vasc/TestTable.java b/tests/com/idcanet/vasc/TestTable.java
index bf79968..dc50243 100644
--- a/tests/com/idcanet/vasc/TestTable.java
+++ b/tests/com/idcanet/vasc/TestTable.java
@@ -32,7 +32,6 @@ import java.util.Date;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
-import com.idcanet.vasc.core.ui.VascList;
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
import com.idcanet.vasc.impl.DefaultVascBackendController;
import com.idcanet.vasc.impl.DefaultVascBackendControllerResolver;
@@ -50,12 +49,9 @@ import com.idcanet.vasc.impl.actions.DeleteRowAction;
import com.idcanet.vasc.impl.actions.EditRowAction;
import com.idcanet.vasc.impl.actions.RefreshDataGlobalAction;
import com.idcanet.vasc.impl.actions.XMLExportGlobalAction;
-import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
-import com.idcanet.vasc.impl.entry.BeanPropertyVascEntryFieldValue;
-import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver;
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeController;
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeControllerResolver;
-import com.idcanet.vasc.models.TestModel;
+import com.idcanet.vasc.impl.x4o.VascParser;
/**
@@ -69,7 +65,7 @@ public class TestTable {
// for test
TestModelVascDataSource backend = new TestModelVascDataSource();
- backend.setId("testBackend");
+ backend.setId("testBackend1");
// config full controller for local jvm use
DefaultVascController c = new DefaultVascController();
@@ -87,6 +83,7 @@ public class TestTable {
DefaultVascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = new DefaultVascEntryFieldTypeControllerResolver();
DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController();
+ //vascEntryFieldTypeController.
vascEntryFieldTypeControllerResolver.setVascEntryFieldTypeController(vascEntryFieldTypeController);
c.setVascEntryFieldTypeControllerResolver(vascEntryFieldTypeControllerResolver);
@@ -94,19 +91,10 @@ public class TestTable {
}
-
- static public VascEntry getVascTable() throws Exception {
-
- VascController c = getDefaultVascController();
-
- // config table
- VascEntry entry = new DefaultVascEntry();
- entry.setId("test1");
- entry.setBackendId("testBackend");
-
+ static public void fill(VascEntry entry,VascController c) {
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData();
- vascFrontendData.setVascBackend(c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend"));
-
+ vascFrontendData.setVascController(c);
+
VascI18nTextValue vascEntryResourceResolver = new VascI18nTextValue();// new DefaultVascEntryResourceResolver();
vascFrontendData.setVascEntryResourceResolver(vascEntryResourceResolver);
@@ -114,7 +102,7 @@ public class TestTable {
vascFrontendData.setVascFrontendHelper(vascFrontendHelper);
entry.setVascFrontendData(vascFrontendData);
-
+
entry.addRowAction(new AddRowAction());
entry.addRowAction(new EditRowAction());
entry.addRowAction(new DeleteRowAction());
@@ -122,7 +110,28 @@ public class TestTable {
entry.addGlobalAction(new XMLExportGlobalAction());
entry.addGlobalAction(new CSVExportGlobalAction());
entry.addGlobalAction(new RefreshDataGlobalAction());
+ }
+
+ static public VascEntry getVascTable() throws Exception {
+ VascController c = getDefaultVascController();
+
+ VascParser parser = new VascParser(c);
+ parser.parseResource("resources/vasc/tables.xml");
+
+ VascEntry entry = parser.getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById("test1");
+ fill(entry,c);
+
+
+ // config table
+
+ //VascEntry entry = new DefaultVascEntry();
+ //entry.setId("test1");
+ //entry.setBackendId("testBackend");
+
+
+
+ /*
//table.addUserOptions(userOption);
//table.addColumnActions(new GraphColumnAction());
@@ -131,6 +140,7 @@ public class TestTable {
entry.addVascEntryField(field);
field = new DefaultVascEntryField("description");
+ field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("EmailField"));
entry.addVascEntryField(field);
field = new DefaultVascEntryField("active");
@@ -142,19 +152,14 @@ public class TestTable {
entry.addVascEntryField(field);
field = new DefaultVascEntryField("testModel");
- //field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField"));
- //field.getVascEntryFieldType()
- VascList list = new VascList();
- list.setVascSelectItemModel((TestModelVascDataSource)c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend"));
- //field.setVascUIComponent(list);
+ field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"));
+ field.getVascEntryFieldType().setDataObject(c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend"));
entry.addVascEntryField(field);
field = new DefaultVascEntryField("hexColor");
+ field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ColorField"));
field.setDefaultValue("#FF3355");
- //VascColorChooser ui = new VascColorChooser();
- //ui.setHexSwingEncoding(true);
- //field.setVascUIComponent(ui);
entry.addVascEntryField(field);
printEntry(entry);
@@ -165,6 +170,7 @@ public class TestTable {
DefaultVascFrontendEntryFinalizer f2 = new DefaultVascFrontendEntryFinalizer();
entry = f2.finalizeVascEntry(entry,c);
//printEntry(entry);
+ */
return entry;
}
diff --git a/tests/resources/vasc/tables.xml b/tests/resources/vasc/tables.xml
index 488cf20..f56a572 100644
--- a/tests/resources/vasc/tables.xml
+++ b/tests/resources/vasc/tables.xml
@@ -2,6 +2,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (&(objectClass=sudoRole))
- ${baseDn},cn=%s
- sudoRole,top
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/www/META-INF/MANIFEST.MF b/www/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5e94951
--- /dev/null
+++ b/www/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/www/META-INF/vasc-jsf.taglib.xml b/www/META-INF/vasc-jsf.taglib.xml
new file mode 100644
index 0000000..fa8b340
--- /dev/null
+++ b/www/META-INF/vasc-jsf.taglib.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ http://foo.com/foo
+
+ foo
+
+ com.foo.Foo
+ com.foo.component.Foo
+
+
+
\ No newline at end of file
diff --git a/www/WEB-INF/faces-config.xml b/www/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..cfd6c98
--- /dev/null
+++ b/www/WEB-INF/faces-config.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+ Vasc
+ vasc-jsf
+ com.idcanet.vasc.frontends.web.jsf.VascUIComponent
+
+
+
+
+
+
\ No newline at end of file
diff --git a/www/WEB-INF/vasc-jsf.tld b/www/WEB-INF/vasc-jsf.tld
new file mode 100644
index 0000000..2421927
--- /dev/null
+++ b/www/WEB-INF/vasc-jsf.tld
@@ -0,0 +1,27 @@
+
+
+
+ 1.0
+ vasc
+ http://vasc.idcanet.com/jsf
+
+
+ vasc
+ com.idcanet.vasc.frontends.web.jsf.VascUIComponentTag
+ JSP
+
+
+ id
+ false
+ true
+
+
+
+ bar
+ false
+ java.lang.Object
+
+
+
\ No newline at end of file
diff --git a/www/WEB-INF/web.xml b/www/WEB-INF/web.xml
new file mode 100644
index 0000000..5715804
--- /dev/null
+++ b/www/WEB-INF/web.xml
@@ -0,0 +1,81 @@
+
+
+
+ index.jsp
+
+
+
+ facelets.SKIP_COMMENTS
+ true
+
+
+
+ javax.faces.STATE_SAVING_METHOD
+ server
+
+
+ com.sun.faces.validateXml
+ true
+
+
+ com.sun.faces.verifyObjects
+ true
+
+
+ javax.faces.DEFAULT_SUFFIX
+ .jsp
+
+
+
+
+ facelets.VIEW_MAPPINGS
+ *.xhtml
+
+
+
+
+ Faces Servlet
+ javax.faces.webapp.FacesServlet
+ 1
+
+
+
+
+ Faces Servlet
+ /faces/*
+
+
+ Faces Servlet
+ *.jsf
+
+
+
+
+
+
diff --git a/www/index.jsp b/www/index.jsp
new file mode 100644
index 0000000..db9befe
--- /dev/null
+++ b/www/index.jsp
@@ -0,0 +1,12 @@
+
+
+ TEST INDEX.JSP
+
\ No newline at end of file
diff --git a/www/vasc_test1.jsp b/www/vasc_test1.jsp
new file mode 100644
index 0000000..cb446ca
--- /dev/null
+++ b/www/vasc_test1.jsp
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+