2
0
Fork 0

splitted the event listeners

This commit is contained in:
willem.cazander 2010-08-26 00:51:14 +02:00
parent cd2e3eaf50
commit 4f409296d0
23 changed files with 327 additions and 217 deletions

View file

@ -31,9 +31,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
/**
* Event listener annotation
*
@ -44,7 +41,5 @@ import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
@Target(ElementType.TYPE)
public @interface VascEventListener {
String[] listeners();
VascEventType[] types();
Class<?>[] listeners();
}

View file

@ -32,8 +32,9 @@ import java.util.List;
import com.idcanet.vasc.core.actions.ColumnVascAction;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryBackendEventListener;
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
/**
* The main vasc entry
@ -379,18 +380,29 @@ public interface VascEntry extends Cloneable,Serializable {
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel);
/**
* Added an VascEntryEventListener
* @param type
* @param listener
* Added an VascEntryBackendEventListener
* @param listener The class of the event listener.
*/
public void addVascEntryEventListener(VascEntryEventListener.VascEventType type,VascEntryEventListener listener);
public void addVascEntryBackendEventListener(Class<VascEntryBackendEventListener> listener);
/**
* Returns the list of VascEntryEventListener for a speciec type.
* @param type
* Returns the list of VascEntryBackendEventListener
* @return
*/
public List<VascEntryEventListener> getVascEntryEventListeners(VascEntryEventListener.VascEventType type);
public List<Class<VascEntryBackendEventListener>> getVascEntryBackendEventListeners();
/**
* Added an VascEntryFrontendEventListener
* @param listener The class of the event listener.
*/
public void addVascEntryFrontendEventListener(Class<VascEntryFrontendEventListener> listener);
/**
* Returns the list of VascEntryFrontendEventListener
* @return
*/
public List<Class<VascEntryFrontendEventListener>> getVascEntryFrontendEventListeners();
public void addListOption(VascEntryField listOption);
public List<VascEntryField> getListOptions();

View file

@ -28,8 +28,8 @@ package com.idcanet.vasc.core;
import java.util.List;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFieldValidatorService;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryResourceImageResolver;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
import com.idcanet.vasc.core.ui.VascUIComponent;
@ -86,17 +86,7 @@ public interface VascFrontendData {
public VascUIComponent getFieldVascUIComponent(VascEntryField field);
public Object getFieldRealRenderer(VascEntryField field);
public void clearFieldRenderObjects();
/**
* @return the exceptionListener
*/
public VascEntryEventListener getExceptionListener();
/**
* @param exceptionListener the exceptionListener to set
*/
public void setExceptionListener(VascEntryEventListener exceptionListener);
/**
* @return the vascEntryResourceImageResolver
*/
@ -112,4 +102,8 @@ public interface VascFrontendData {
public VascEntryState getVascEntryState();
public void setVascEntryState(VascEntryState state);
public void initFrontendListeners(VascEntry entry) throws InstantiationException, IllegalAccessException;
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener);
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type);
}

View file

@ -30,7 +30,7 @@ import java.util.List;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
/**
@ -76,7 +76,7 @@ public interface VascFrontendHelper {
public void handleException(VascEntry entry,Exception exception);
public void fireVascEvent(VascEntry entry,VascEventType type,Object data);
public void fireVascEvent(VascEntry entry,VascFrontendEventType type,Object data);
public void sortAction(VascEntry entry,VascEntryField field);

View file

@ -36,9 +36,9 @@ import com.idcanet.vasc.core.VascEntry;
* @author Willem Cazander
* @version 1.0 Aug 02, 2007
*/
public interface VascEntryEventListener extends Cloneable,Serializable {
public interface VascEntryFrontendEventListener extends Serializable {
public enum VascEventType {
public enum VascFrontendEventType {
EXCEPTION,
DATA_CREATE,
@ -56,18 +56,13 @@ public interface VascEntryEventListener extends Cloneable,Serializable {
OPTION_UPDATE,
}
public VascFrontendEventType[] getEventTypes();
/**
* Is executed when the type of event is fired.
* @param entry
* @param type
* @param data
*/
public void vascEvent(VascEntry entry,VascEventType type,Object data);
/**
* Force impl to have public clone methode
* @return
* @throws CloneNotSupportedException
*/
public VascEntryEventListener clone() throws CloneNotSupportedException;
public void vascEvent(VascEntry entry,Object data);
}

View file

@ -64,14 +64,13 @@ import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import com.idcanet.fff.SwingImageHelper;
import com.idcanet.vasc.core.AbstractVascFrontend;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryExporter;
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
import com.idcanet.vasc.core.ui.VascUIComponent;
@ -128,7 +127,8 @@ public class SwingVascFrontend extends AbstractVascFrontend {
}
if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) {
return SwingImageHelper.getImageIcon(key);
return null;
//return SwingImageHelper.getImageIcon(key);
} else {
return null;
}
@ -592,16 +592,12 @@ public class SwingVascFrontend extends AbstractVascFrontend {
}
}
class VascColumnModel extends AbstractTableModel implements VascEntryEventListener {
class VascColumnModel extends AbstractTableModel implements VascEntryFrontendEventListener {
private static final long serialVersionUID = 10L;
public void vascEvent(VascEntry entry,VascEventType e,Object o) {
public void vascEvent(VascEntry entry,Object o) {
fireTableDataChanged();
}
public VascEntryEventListener clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
/**
* @see javax.swing.entry.entryModel#getColumnCount()
@ -655,6 +651,11 @@ public class SwingVascFrontend extends AbstractVascFrontend {
return "Error";
}
}
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascFrontendEventType.DATA_LIST_UPDATE};
return result;
}
}
}

View file

@ -74,9 +74,9 @@ import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryExporter;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import com.idcanet.vasc.core.ui.VascOptionValueModelListener;
import com.idcanet.vasc.core.ui.VascUIComponent;
import com.idcanet.vasc.core.ui.VascValueModel;
@ -440,14 +440,15 @@ public class SwtVascFrontend extends AbstractVascFrontend {
}
};
entry.addVascEntryEventListener(VascEventType.DATA_LIST_UPDATE, new VascEntryEventListener() {
public void vascEvent(VascEntry entry,VascEventType type,Object data) {
entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE};
return result;
}
public void vascEvent(VascEntry entry,Object data) {
tableViewer.refresh();
table2.deselectAll();
}
public VascEntryEventListener clone() throws CloneNotSupportedException {
return this;
}
});

View file

@ -11,14 +11,14 @@ import javax.faces.context.FacesContext;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
/**
* @author willemc
*
*/
public class JSFVascEntryEventListener implements VascEntryEventListener {
public class JSFVascEntryEventListener implements VascEntryFrontendEventListener {
private static final long serialVersionUID = 1765054259934158076L;
private String entrySupportVar = null;
@ -26,8 +26,18 @@ public class JSFVascEntryEventListener implements VascEntryEventListener {
public JSFVascEntryEventListener(String entrySupportVar) {
this.entrySupportVar=entrySupportVar;
}
public void vascEvent(VascEntry entry, VascEventType type,Object dataNotUsed) {
/**
* @see com.idcanet.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
*/
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE};
return result;
}
public void vascEvent(VascEntry entry,Object dataNotUsed) {
try {
for (VascEntryField field:entry.getVascEntryFields()) {
if (field.getVascEntryFieldValue()==null) {
@ -56,9 +66,4 @@ public class JSFVascEntryEventListener implements VascEntryEventListener {
ValueExpression ve3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tablePagesDataModel.wrappedData}", Object.class);
ve3.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendData().getVascFrontendHelper().getVascBackendPageNumbers(entry));
}
@Override
public VascEntryEventListener clone() throws CloneNotSupportedException {
return this;
}
}

View file

@ -295,6 +295,14 @@ public class JSFVascEntrySupportBean implements Serializable {
return result;
}
public boolean getHasOnlySinglePage() {
int pages = getTablePagesDataModel().getRowCount();
if (pages==1) {
return true;
}
return false;
}
public boolean getHasExtendedPageMode() {
int pages = getTablePagesDataModel().getRowCount();
if (pages>13) {
@ -851,16 +859,17 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
VascEntryState state = entry.getVascFrontendData().getVascEntryState();
if (state.getMultiActionSelection().isEmpty()==false) {
List<Object> sels = new ArrayList<Object>(5);
for (Integer rowId:state.getMultiActionSelection().keySet()) {
Boolean value = state.getMultiActionSelection().get(rowId);
logger.fine("multiRow delete: "+rowId+" value: "+value);
if (value!=null && value==true) {
Object row = state.getEntryDataList().get(rowId);
sels.add(row);
}
List<Object> sels = new ArrayList<Object>(5);
for (Integer rowId:state.getMultiActionSelection().keySet()) {
Boolean value = state.getMultiActionSelection().get(rowId);
logger.fine("multiRow delete: "+rowId+" value: "+value);
if (value!=null && value==true) {
Object row = state.getEntryDataList().get(rowId);
sels.add(row);
}
}
if (sels.isEmpty()==false) {
for (Object row:sels) {
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(row);
entry.getVascFrontendData().getVascFrontendHelper().deleteObject(entry);

View file

@ -45,8 +45,8 @@ import com.idcanet.vasc.core.VascEntryState;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFListModel;
import com.idcanet.vasc.impl.DefaultVascFactory;
@ -239,7 +239,7 @@ public class JSFVascUIComponent extends UIComponentBase {
try {
VascEntry entry = supportBean.getVascEntry();
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascEventType.DATA_SELECT, rowObject);
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.DATA_SELECT, rowObject);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendData().getVascFrontend().renderEdit();
} catch (Exception e) {
@ -326,6 +326,15 @@ public class JSFVascUIComponent extends UIComponentBase {
frontendData.setVascController(vascController);
entry.setVascFrontendData(frontendData);
try {
frontendData.initFrontendListeners(entry);
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
frontendData.getVascEntryState().setVascBackend(backend);
frontendData.getVascEntryState().setVascEntry(entry);
@ -373,7 +382,7 @@ public class JSFVascUIComponent extends UIComponentBase {
}
// create listener for new objects
entry.addVascEntryEventListener(VascEventType.DATA_CREATE, new CreateEntryFieldValuesListener2(fieldId,selectedValue));
entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
}
} catch (Exception e) {
e.printStackTrace();
@ -382,12 +391,12 @@ public class JSFVascUIComponent extends UIComponentBase {
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
entry.addVascEntryEventListener(VascEntryEventListener.VascEventType.DATA_LIST_UPDATE, new JSFVascEntryEventListener(entrySupportVar));
entry.getVascFrontendData().addVascEntryFrontendEventListener(new JSFVascEntryEventListener(entrySupportVar));
return entry;
}
class CreateEntryFieldValuesListener2 implements VascEntryEventListener {
class CreateEntryFieldValuesListener2 implements VascEntryFrontendEventListener {
private static final long serialVersionUID = 1L;
private String fieldId = null;
private Object value = null;
@ -398,7 +407,11 @@ public class JSFVascUIComponent extends UIComponentBase {
this.fieldId=fieldId;
this.value=value;
}
public void vascEvent(VascEntry entry,VascEventType type, Object data) {
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_CREATE};
return result;
}
public void vascEvent(VascEntry entry,Object data) {
VascEntryField field = entry.getVascEntryFieldById(fieldId);
try {
field.getVascEntryFieldValue().setValue(field, data, value);
@ -406,9 +419,5 @@ public class JSFVascUIComponent extends UIComponentBase {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
@Override
public VascEntryEventListener clone() throws CloneNotSupportedException {
return this;
}
}
}

View file

@ -4,6 +4,7 @@
package com.idcanet.vasc.frontends.web.jsf;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
@ -35,9 +36,20 @@ public class JSFVascValidatePhaseListener implements PhaseListener {
logger = Logger.getLogger(JSFVascValidatePhaseListener.class.getName());
}
private static final String SAVE_ACTION_ID_HACK = "VASC_SAVE";
public void afterPhase(PhaseEvent event) {
FacesContext context = event.getFacesContext();
validateUIInput(context.getViewRoot(),context);
// we really only want validation this early when saveing.
// this is currently a bit hacky impl;
Map<String,String> requestMap = context.getExternalContext().getRequestParameterMap();
for (String key:requestMap.keySet()) {
if (key.contains(SAVE_ACTION_ID_HACK)) {
validateUIInput(context.getViewRoot(),context);
return;
}
}
}
public void beforePhase(PhaseEvent event) {
}

View file

@ -76,10 +76,10 @@ import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryExporter;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import com.idcanet.vasc.core.ui.VascOptionValueModelListener;
import com.idcanet.vasc.core.ui.VascValueModel;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFBoolean;
@ -208,6 +208,15 @@ public class OldVascUIComponent extends UIComponentBase {
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), vascFrontendData.getExpressionString(), VascFrontendData.class);
VascFrontendData frontendData = (VascFrontendData)ve2.getValue(FacesContext.getCurrentInstance().getELContext());
try {
frontendData.initFrontendListeners(entry);
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
frontendData.setVascController(vascControllerObj);
entry.setVascFrontendData(frontendData);
@ -229,9 +238,13 @@ public class OldVascUIComponent extends UIComponentBase {
}
frontendData.getVascEntryState().setVascBackend(backend);
entry.addVascEntryEventListener(VascEntryEventListener.VascEventType.DATA_LIST_UPDATE, new VascEntryEventListener() {
entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
private static final long serialVersionUID = 1L;
public void vascEvent(VascEntry entry, VascEventType type,Object dataNotUsed) {
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE};
return result;
}
public void vascEvent(VascEntry entry, Object dataNotUsed) {
List<Object> data = entry.getVascFrontendData().getVascEntryState().getEntryDataList();
for (VascEntryField field:entry.getVascEntryFields()) {
if (field.getVascEntryFieldValue()==null) {
@ -255,10 +268,6 @@ public class OldVascUIComponent extends UIComponentBase {
ValueExpression ren4 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['totalResults']}", Integer.class);
ren4.setValue(FacesContext.getCurrentInstance().getELContext(), getVascEntry().getVascFrontendData().getVascEntryState().getTotalBackendRecords());
}
@Override
public VascEntryEventListener clone() throws CloneNotSupportedException {
return this;
}
});
return entry;
@ -451,7 +460,7 @@ public class OldVascUIComponent extends UIComponentBase {
}
// create listener for new objects
entry.addVascEntryEventListener(VascEventType.DATA_CREATE, new CreateEntryFieldValuesListener(fieldId,selectedValue));
entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener(fieldId,selectedValue));
}
}
@ -477,7 +486,7 @@ public class OldVascUIComponent extends UIComponentBase {
}
}
class CreateEntryFieldValuesListener implements VascEntryEventListener {
class CreateEntryFieldValuesListener implements VascEntryFrontendEventListener {
private static final long serialVersionUID = 1L;
private String fieldId = null;
private Object value = null;
@ -488,7 +497,11 @@ public class OldVascUIComponent extends UIComponentBase {
this.fieldId=fieldId;
this.value=value;
}
public void vascEvent(VascEntry entry,VascEventType type, Object data) {
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_CREATE};
return result;
}
public void vascEvent(VascEntry entry,Object data) {
VascEntryField field = entry.getVascEntryFieldById(fieldId);
try {
field.getVascEntryFieldValue().setValue(field, data, value);
@ -496,10 +509,6 @@ public class OldVascUIComponent extends UIComponentBase {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
@Override
public VascEntryEventListener clone() throws CloneNotSupportedException {
return this;
}
}
public Object getSelectedTableObject() {

View file

@ -41,8 +41,9 @@ import com.idcanet.vasc.core.actions.ColumnVascAction;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.actions.VascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryBackendEventListener;
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
/**
* VascEntry
@ -86,7 +87,8 @@ public class DefaultVascEntry implements VascEntry {
private List<VascLinkEntry> vascLinkEntries = null;
private Map<String,Object> entryParameters = null;
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
private Map<VascEntryEventListener.VascEventType,List<VascEntryEventListener>> eventListeners = null;
private List<Class<VascEntryFrontendEventListener>> eventEntryFrontendEventListeners = null;
private List<Class<VascEntryBackendEventListener>> eventEntryBackendEventListeners = null;
private List<VascEntryField> listOptions = null;
private List<VascBackendFilter> backendFilters = null;
@ -107,7 +109,8 @@ public class DefaultVascEntry implements VascEntry {
vascLinkEntries = new ArrayList<VascLinkEntry>(10);
entryParameters = new HashMap<String,Object>(10);
eventListeners = new HashMap<VascEntryEventListener.VascEventType,List<VascEntryEventListener>>(3);
eventEntryFrontendEventListeners = new ArrayList<Class<VascEntryFrontendEventListener>>(10);
eventEntryBackendEventListeners = new ArrayList<Class<VascEntryBackendEventListener>>(10);
listOptions = new ArrayList<VascEntryField>(5);
backendFilters = new ArrayList<VascBackendFilter>(3);
}
@ -140,6 +143,8 @@ public class DefaultVascEntry implements VascEntry {
result.vascAdminDelete=vascAdminDelete;
result.backendId=backendId;
result.vascEntryFieldEventChannel=vascEntryFieldEventChannel;
result.eventEntryFrontendEventListeners.addAll(eventEntryFrontendEventListeners);
result.eventEntryBackendEventListeners.addAll(eventEntryBackendEventListeners);
// skipping 'vascFrontendData' because it should always be null when cloning happens.
for (VascEntryField f:vascFields) {
@ -162,13 +167,6 @@ public class DefaultVascEntry implements VascEntry {
for (VascLinkEntry l:vascLinkEntries) {
result.vascLinkEntries.add(l.clone());
}
for (VascEntryEventListener.VascEventType type:eventListeners.keySet()) {
List<VascEntryEventListener> lists = eventListeners.get(type);
for (VascEntryEventListener e:lists) {
VascEntryEventListener listener = e.clone();
result.addVascEntryEventListener(type, listener);
}
}
for (VascEntryField listOption:listOptions) {
VascEntryField ff = listOption.clone();
ff.setVascEntry(result);
@ -717,32 +715,37 @@ public class DefaultVascEntry implements VascEntry {
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) {
this.vascEntryFieldEventChannel = vascEntryFieldEventChannel;
}
/**
* Added an VascEntryEventListener
* @param type
* @param listener
* Added an VascEntryBackendEventListener
* @param listener The class of the event listener.
*/
public void addVascEntryEventListener(VascEntryEventListener.VascEventType type,VascEntryEventListener listener) {
List<VascEntryEventListener> result = eventListeners.get(type);
if (result==null) {
result = new ArrayList<VascEntryEventListener>(3);
eventListeners.put(type,result);
}
result.add(listener);
public void addVascEntryBackendEventListener(Class<VascEntryBackendEventListener> listener) {
eventEntryBackendEventListeners.add(listener);
}
/**
* Returns the list of VascEntryEventListener for a speciec type.
* @param type
* Returns the list of VascEntryBackendEventListener
* @return
*/
public List<VascEntryEventListener> getVascEntryEventListeners(VascEntryEventListener.VascEventType type) {
List<VascEntryEventListener> result = eventListeners.get(type);
if (result!=null) {
return result;
}
return new ArrayList<VascEntryEventListener>(0);
public List<Class<VascEntryBackendEventListener>> getVascEntryBackendEventListeners() {
return eventEntryBackendEventListeners;
}
/**
* Added an VascEntryFrontendEventListener
* @param listener The class of the event listener.
*/
public void addVascEntryFrontendEventListener(Class<VascEntryFrontendEventListener> listener) {
eventEntryFrontendEventListeners.add(listener);
}
/**
* Returns the list of VascEntryFrontendEventListener
* @return
*/
public List<Class<VascEntryFrontendEventListener>> getVascEntryFrontendEventListeners() {
return eventEntryFrontendEventListeners;
}
public void addListOption(VascEntryField listOption) {

View file

@ -35,7 +35,6 @@ import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver;
import com.idcanet.vasc.impl.entry.VascValidatorsValidatorService;
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeController;
@ -83,15 +82,6 @@ public class DefaultVascFactory {
vascFrontendData.getVascEntryState().setVascBackendState(new DefaultVascBackendState());
vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100); // default page size is zero aka disabled
vascFrontendData.getVascEntryState().getVascBackendState().setPageSizeMax(1000); // max 1k records on screen.
vascFrontendData.setExceptionListener(new VascEntryEventListener() {
private static final long serialVersionUID = 1L;
public void vascEvent(VascEntry entry, VascEventType type,Object data) {
throw new RuntimeException(((Exception)data)); // throw to top.
}
public VascEntryEventListener clone() throws CloneNotSupportedException {
return this;
}
});
vascFrontendData.addVascValidatorService(new VascValidatorsValidatorService()); // normal vasc validators
return vascFrontendData;
}

View file

@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFinalizer;
import com.idcanet.vasc.core.VascEntryState;
@ -39,8 +40,8 @@ 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.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFieldValidatorService;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryResourceImageResolver;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
import com.idcanet.vasc.core.ui.VascUIComponent;
@ -59,7 +60,7 @@ public class DefaultVascFrontendData implements VascFrontendData {
private VascEntryResourceImageResolver vascEntryResourceImageResolver = null;
private Map<String,String> uiComponents = null;
private VascController vascController = null;
private VascEntryEventListener exceptionListener = null;
private Map<VascEntryFrontendEventListener.VascFrontendEventType,List<VascEntryFrontendEventListener>> vascEntryFrontendEventListeners = null;
private VascEntryState state = null;
@ -72,6 +73,7 @@ public class DefaultVascFrontendData implements VascFrontendData {
fieldComps = new HashMap<VascEntryField,VascUIComponent>(8);
fieldEditors = new HashMap<VascEntryField,Object>(8);
validatorServices = new ArrayList<VascEntryFieldValidatorService>(4);
vascEntryFrontendEventListeners = new HashMap<VascEntryFrontendEventListener.VascFrontendEventType,List<VascEntryFrontendEventListener>>(10);
}
/**
@ -208,20 +210,6 @@ public class DefaultVascFrontendData implements VascFrontendData {
return fieldComps.get(field);
}
/**
* @return the exceptionListener
*/
public VascEntryEventListener getExceptionListener() {
return exceptionListener;
}
/**
* @param exceptionListener the exceptionListener to set
*/
public void setExceptionListener(VascEntryEventListener exceptionListener) {
this.exceptionListener = exceptionListener;
}
/**
* @return the vascEntryResourceImageResolver
*/
@ -257,4 +245,31 @@ public class DefaultVascFrontendData implements VascFrontendData {
public void setVascEntryState(VascEntryState state) {
this.state=state;
}
public void initFrontendListeners(VascEntry entry) throws InstantiationException, IllegalAccessException {
for (Class<VascEntryFrontendEventListener> clazz:entry.getVascEntryFrontendEventListeners()) {
VascEntryFrontendEventListener listener = clazz.newInstance();
addVascEntryFrontendEventListener(listener);
}
}
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener) {
for (VascEntryFrontendEventListener.VascFrontendEventType type:listener.getEventTypes()) {
List<VascEntryFrontendEventListener> list = vascEntryFrontendEventListeners.get(type);
if (list==null) {
list = new ArrayList<VascEntryFrontendEventListener>(10);
vascEntryFrontendEventListeners.put(type, list);
}
list.add(listener);
}
}
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type) {
List<VascEntryFrontendEventListener> list = vascEntryFrontendEventListeners.get(type);
if (list==null) {
return new ArrayList<VascEntryFrontendEventListener>(0);
}
return list;
}
}

View file

@ -29,7 +29,6 @@ package com.idcanet.vasc.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idcanet.vasc.core.VascBackendFilter;
@ -44,9 +43,9 @@ import com.idcanet.vasc.core.VascLinkEntryType;
import com.idcanet.vasc.core.VascUserRoleController;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryFieldValidatorService;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import com.idcanet.vasc.core.ui.VascUIComponent;
/**
@ -158,10 +157,10 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#fireVascEvent(com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType, java.lang.Object)
*/
public void fireVascEvent(VascEntry entry,VascEventType type, Object data) {
List<VascEntryEventListener> list = entry.getVascEntryEventListeners(type);
for (VascEntryEventListener l:list) {
l.vascEvent(entry, type, data);
public void fireVascEvent(VascEntry entry,VascFrontendEventType type, Object data) {
List<VascEntryFrontendEventListener> list = entry.getVascFrontendData().getVascEntryFrontendEventListener(type);
for (VascEntryFrontendEventListener l:list) {
l.vascEvent(entry, data);
}
}
@ -223,12 +222,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
* @see com.idcanet.vasc.core.VascFrontendHelper#handleException(com.idcanet.vasc.core.VascEntry,java.lang.Exception)
*/
public void handleException(VascEntry entry,Exception exception) {
VascEntryEventListener listener = entry.getVascFrontendData().getExceptionListener();
if (listener==null) {
logger.log(Level.WARNING,exception.getMessage(),exception);
throw new RuntimeException("Exception happend: "+exception.getMessage(),exception);
}
listener.vascEvent(entry,VascEventType.EXCEPTION , exception);
fireVascEvent(entry,VascFrontendEventType.EXCEPTION , exception);
}
/**
@ -258,7 +252,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue);
field.getVascEntryFieldValue().setValue(field, object, defaultValue);
}
fireVascEvent(entry,VascEventType.DATA_CREATE, object);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_CREATE, object);
return object;
} catch (Exception e) {
handleException(entry,e);
@ -307,7 +301,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
Object result = null;
try {
fireVascEvent(entry,VascEventType.DATA_PRE_UPDATE,object);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_PRE_UPDATE,object);
int index = removeObjectFromDataList(entry,object);
// merge object on backend
@ -321,8 +315,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
// put object back in list
entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
fireVascEvent(entry,VascEventType.DATA_POST_UPDATE,result);
fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE,result);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_POST_UPDATE,result);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE,result);
} catch (Exception e) {
handleException(entry,e);
}
@ -343,8 +337,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
}
removeObjectFromDataList(entry,object);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
fireVascEvent(entry,VascEventType.DATA_DELETE, object);
fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE, object);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_DELETE, object);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE, object);
}
/**
@ -370,8 +364,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
} catch (Exception e) {
handleException(entry, e);
}
fireVascEvent(entry,VascEventType.DATA_READ, null);
fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE, null);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_READ, null);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE, null);
}
public void headerOptionsCreatedFillData(VascEntry entry) {
@ -480,7 +474,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
String sortID = field.getBackendName();
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(sortID);
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_SORT, field);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_SORT, field);
refreshData(entry);
}
@ -489,7 +483,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSearchString(searchString);
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(null);
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_SEARCH, searchString);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_SEARCH, searchString);
refreshData(entry);
}
@ -504,7 +498,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
}
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(pageIndex);
fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_PAGE, pageIndex);
fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_PAGE, pageIndex);
// lets load data;
refreshData(entry);

View file

@ -62,49 +62,49 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
/**
* @see com.idcanet.vasc.core.ui.VascSelectItemModel#getVascSelectItems(com.idcanet.vasc.core.VascEntry)
*/
public List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException {
public List<VascSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException {
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(entryId);
VascEntry entry = currentEntry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(entryId);
if (keyFieldId==null) {
keyFieldId = ve.getPrimaryKeyFieldId();
keyFieldId = entry.getPrimaryKeyFieldId();
}
VascEntryField key = ve.getVascEntryFieldById(keyFieldId);
VascEntryField key = entry.getVascEntryFieldById(keyFieldId);
if (displayFieldId==null) {
displayFieldId = ve.getDisplayNameFieldId();
displayFieldId = entry.getDisplayNameFieldId();
}
VascEntryField dis = ve.getVascEntryFieldById(displayFieldId);
VascEntryField dis = entry.getVascEntryFieldById(displayFieldId);
if (key==null) {
throw new VascException("Could not find: "+keyFieldId+" from: "+ve.getId());
throw new VascException("Could not find: "+keyFieldId+" from: "+entry.getId());
}
if (dis==null) {
throw new VascException("Could not find: "+displayFieldId+" from: "+ve.getId());
throw new VascException("Could not find: "+displayFieldId+" from: "+entry.getId());
}
// set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc
ve.setVascFrontendData(entry.getVascFrontendData());
VascBackend back = DefaultVascFactory.getProxyVascBackend(ve);
entry.setVascFrontendData(currentEntry.getVascFrontendData());
VascBackend back = DefaultVascFactory.getProxyVascBackend(entry);
try {
if (nullLabel!=null) {
if (nullKeyValue==null) {
nullKeyValue = "null";
}
nullLabel = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(nullLabel);
nullLabel = currentEntry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(nullLabel);
VascSelectItem item = new VascSelectItem(nullLabel,null,nullKeyValue);
result.add(item);
}
// set def para
VascBackendState state = new DefaultVascBackendState();
for (String key2:ve.getEntryParameterKeys()) {
Object value = ve.getEntryParameter(key2);
for (String key2:entry.getEntryParameterKeys()) {
Object value = entry.getEntryParameter(key2);
//System.out.println("Copy paras name: "+key2+" value: "+value+" class: "+value.getClass().getName());
state.setDataParameter(key2, value);
}
// set list para
for (VascEntryField vef:ve.getListOptions()) {
for (VascEntryField vef:entry.getListOptions()) {
Object def = vef.getDefaultValue();
if (def==null) {
continue;
@ -116,12 +116,12 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
// set para from parent state entry
for (String paraName:entryParameterFieldIds.keySet()) {
VascEntry fieldEntry = entry;
VascEntry fieldEntry = currentEntry;
if (useParentFields!=null && useParentFields==true) {
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
if (currentEntry.getVascFrontendData().getVascEntryState().getParent()==null) {
throw new IllegalStateException("Requested to use parent state field values but no parent state found.");
}
fieldEntry = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
fieldEntry = currentEntry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
}
String paraValueId = entryParameterFieldIds.get(paraName);
@ -152,7 +152,7 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
VascEntryField fieldClone = key.clone();
fieldClone.getVascValidators().clear();
VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
VascEntryFieldValue v = currentEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
key.setVascEntryFieldValue(v);
}
if (dis.getVascEntryFieldValue()==null) {
@ -160,7 +160,7 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
VascEntryField fieldClone = dis.clone();
fieldClone.getVascValidators().clear();
VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
VascEntryFieldValue v = currentEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
dis.setVascEntryFieldValue(v);
}

View file

@ -29,7 +29,7 @@ package com.idcanet.vasc.impl.actions;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.actions.AbstractVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
/**
*
@ -51,7 +51,7 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
return; // nothing selected
}
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascEventType.DATA_SELECT, rowObject);
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.DATA_SELECT, rowObject);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendData().getVascFrontend().renderEdit();
}

View file

@ -43,6 +43,7 @@ import com.idcanet.vasc.core.ui.VascValueModel;
public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
private static final long serialVersionUID = 1L;
@Override
public VascEntryFieldType clone() throws CloneNotSupportedException {
MultiTextVascEntryFieldType clone = new MultiTextVascEntryFieldType();
@ -57,6 +58,8 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
clone.vascValidators.addAll(vascValidators);
return clone;
}
/*
private Object getIndexValue(VascEntryField entryField,int index) throws VascException {
Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
@ -103,13 +106,15 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
}
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 {
return 1;
/*
Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
@ -123,6 +128,7 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
return 1+1;
}
throw new VascException("Unknown object type: "+value);
*/
}
/**
@ -130,6 +136,10 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
*/
@Override
public VascValueModel provideEditorVascValueModel(final int index,final VascEntryField entryField) {
MultiVascValueModel model = new MultiVascValueModel();
return model;
/* note: not allowed to use inner classes in backend , that breaks remoting !!
VascValueModel model = new VascValueModel() {
public Object getValue() throws VascException {
Object value = getIndexValue(entryField,index);
@ -143,5 +153,63 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
};
return model;
*/
}
}
class MultiVascValueModel extends VascValueModel {
public Object getValue() throws VascException {
Object value = super.getValue();
//System.out.println("value: "+value+" type: "+value.getClass());
StringBuffer buf = new StringBuffer(100);
if (value instanceof List<?>) {
for (Object o:((List<?>)value)) {
buf.append(o);
buf.append("\n");
}
return buf.toString();
}
if (value instanceof String[]) {
for (Object o:((String[])value)) {
buf.append(o);
buf.append("\n");
}
return buf.toString();
}
if (value instanceof String) {
return (String)value;
}
return value;
}
@SuppressWarnings("unchecked")
public void setValue(Object editValueObj) throws VascException {
if (super.getValue()==null) {
super.setValue(editValueObj);
return;
}
if ((editValueObj instanceof String)==false) {
throw new VascException("Can only handle string stuff.");
}
String editValue = (String)editValueObj;
String[] editList = editValue.split(",|\t|\n");
Object value = super.getValue();
if (value instanceof List<?>) {
((List<?>)value).clear();
for (String o:editList) {
((List<String>)value).add(o);
}
super.setValue(value);
return;
}
if (value instanceof String[]) {
super.setValue(value);
return;
}
// solo String type
super.setValue(value);
}
}

View file

@ -45,8 +45,8 @@ import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryBackendEventListener;
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
import com.idcanet.vasc.impl.DefaultVascEntryField;
import com.idcanet.vasc.validators.VascValidator;
import com.idcanet.vasc.validators.VascValidatorClassParser;
@ -104,6 +104,7 @@ public class AnnotationParserElement extends AbstractElement {
}
}
@SuppressWarnings("unchecked")
private void fillEntry(VascEntry entry,Class<?> modelClass,VascAnnotationParser parser) throws ElementException {
@ -111,21 +112,15 @@ public class AnnotationParserElement extends AbstractElement {
}
VascEventListener vc = parser.getVascEventListener (modelClass);
VascEventListener vc = parser.getVascEventListener(modelClass);
if (vc!=null) {
if (vc.listeners().length!=vc.types().length) {
throw new IllegalArgumentException("Total listeners and types are not equals on: "+modelClass);
}
int i = 0;
for (VascEventType type:vc.types()) {
String listenerClass = vc.listeners()[i];
VascEntryEventListener listener;
try {
listener = (VascEntryEventListener)X4OParser.loadClass(listenerClass).newInstance();
entry.addVascEntryEventListener(type, listener);
} catch (Exception e) {
throw new ElementException("Could not create listener: "+listenerClass+" for entryId: "+entry.getId(),e);
for (Class<?> listener:vc.listeners()) {
if (listener.isAssignableFrom(VascEntryFrontendEventListener.class)) {
entry.addVascEntryFrontendEventListener((Class<VascEntryFrontendEventListener>)listener);
}
if (listener.isAssignableFrom(VascEntryBackendEventListener.class)) {
entry.addVascEntryBackendEventListener((Class<VascEntryBackendEventListener>)listener);
}
i++;
}

View file

@ -85,7 +85,7 @@
<x4o:property key="max_items" value="15"/>
</vf:fieldType>
<vf:multiTextFieldType id="MultiTextField" uiComponentId="VascText">
<vf:multiTextFieldType id="MultiTextField" uiComponentId="VascTextArea">
<x4o:property key="min_items" value="0"/>
<x4o:property key="max_items" value="15"/>
</vf:multiTextFieldType>

View file

@ -115,6 +115,9 @@ public class SwingTest extends TestCase {
// render
render.initEntry(entry);
render.renderView();
// get data
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
// view
frame.pack();

View file

@ -6,7 +6,7 @@
<v:simpleJdbcConnectionProvider
el.id="dbDatafeeds"
driverClassName="org.postgresql.Driver"
dbUrl="jdbc:postgresql://db0.dev.lan.mbuyu.nl/datafeeds_dev"
dbUrl="jdbc:postgresql://db0.dev.mbuyu.nl/datafeeds_dev"
dbUser="mbuyu"
dbPassword="eephoh2O"
/>