2
0
Fork 0

[svn r390] jsf and state updates

This commit is contained in:
willemc 2009-12-31 13:51:53 +01:00
parent c1a8402ae8
commit 7ee4809086
64 changed files with 1475 additions and 1086 deletions

View file

@ -83,6 +83,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
// Copy parameters // Copy parameters
for (String key:state.getDataParameterKeys()) { for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key); Object value = state.getDataParameter(key);
//System.out.println("Set para pame: "+key+" value: "+value);
query.setQueryParameter(key, value); query.setQueryParameter(key, value);
if (queryTotal!=null) { if (queryTotal!=null) {
queryTotal.setQueryParameter(key, value); queryTotal.setQueryParameter(key, value);
@ -97,6 +98,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
for (QueryParameterValue value:values) { for (QueryParameterValue value:values) {
Object valueObject = value.getValue(); Object valueObject = value.getValue();
q.setParameter(i,valueObject); q.setParameter(i,valueObject);
//System.out.println("Set para index: "+i+" value: "+valueObject+" valueClass: "+valueObject.getClass()+" valueType: "+value.getValueType());
i++; i++;
} }
if (isPageable() & state.getPageSize()>0) { if (isPageable() & state.getPageSize()>0) {

View file

@ -42,6 +42,7 @@ import com.idcanet.vasc.validators.VascValidator;
*/ */
abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { abstract public class AbstractVascEntryFieldType implements VascEntryFieldType {
private static final long serialVersionUID = 1L;
protected String id = null; protected String id = null;
protected Class<?> autoDetectClass = null; protected Class<?> autoDetectClass = null;
protected List<VascValidator> vascValidators = null; protected List<VascValidator> vascValidators = null;

View file

@ -0,0 +1,142 @@
/**
*
*/
package com.idcanet.vasc.core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Holds all default state values
*
* @author Willem Cazander
* @version 1.0 Dec 15, 2009
*/
abstract public class AbstractVascEntryState implements VascEntryState {
private static final long serialVersionUID = 1L;
private List<Object> entryDataList = null;
private Object entryDataObject = null;
private Long totalBackendRecords = null;
private VascBackendState vascBackendState = null;
private VascEntryState state = null;
private Map<Integer,Boolean> multiActionSelection = null;
private boolean isEditCreate = false;
private VascBackend vascBackend = null;
private VascEntry vascEntry = null;
public AbstractVascEntryState() {
entryDataList = new ArrayList<Object>(0);
multiActionSelection = new HashMap<Integer,Boolean>(200);
}
/**
* @return the entryDataList
*/
public List<Object> getEntryDataList() {
return entryDataList;
}
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> entryDataList) {
this.entryDataList = entryDataList;
}
/**
* @return the entryDataObject
*/
public Object getEntryDataObject() {
return entryDataObject;
}
/**
* @param entryDataObject the entryDataObject to set
*/
public void setEntryDataObject(Object entryDataObject) {
this.entryDataObject = entryDataObject;
}
/**
* @return the vascBackendState
*/
public VascBackendState getVascBackendState() {
return vascBackendState;
}
/**
* @param vascBackendState the vascBackendState to set
*/
public void setVascBackendState(VascBackendState vascBackendState) {
this.vascBackendState = vascBackendState;
}
/**
* @return the totalBackendRecords
*/
public Long getTotalBackendRecords() {
return totalBackendRecords;
}
/**
* @param totalBackendRecords the totalBackendRecords to set
*/
public void setTotalBackendRecords(Long totalBackendRecords) {
this.totalBackendRecords = totalBackendRecords;
}
public void setParent(VascEntryState state) {
this.state=state;
}
public VascEntryState getParent() {
return state;
}
public void setMultiActionSelection(Map<Integer,Boolean> multiActionSelection) {
this.multiActionSelection=multiActionSelection;
}
public Map<Integer,Boolean> getMultiActionSelection() {
return multiActionSelection;
}
/**
* @return the vascBackend
*/
public VascBackend getVascBackend() {
return vascBackend;
}
/**
* @param vascBackend the vascBackend to set
*/
public void setVascBackend(VascBackend vascBackend) {
this.vascBackend = vascBackend;
}
/**
* @return the isEditCreate
*/
public boolean isEditCreate() {
return isEditCreate;
}
/**
* @param isEditCreate the isEditCreate to set
*/
public void setEditCreate(boolean isEditCreate) {
this.isEditCreate = isEditCreate;
}
public void setVascEntry(VascEntry vascEntry) {
this.vascEntry=vascEntry;
}
public VascEntry getVascEntry() {
return vascEntry;
}
}

View file

@ -37,31 +37,31 @@ package com.idcanet.vasc.core;
public interface VascController { public interface VascController {
/** /**
* @return Returns the VascBackendControllerResolver * @return Returns the VascBackendController
*/ */
public VascBackendControllerResolver getVascBackendControllerResolver(); public VascBackendController getVascBackendController();
/** /**
* *
* @return Returns the VascEntryControllerResolver * @return Returns the VascEntryController
*/ */
public VascEntryControllerResolver getVascEntryControllerResolver(); public VascEntryController getVascEntryController();
/** /**
* *
* @return Returns the VascEntryFieldControllerResolver * @return Returns the VascEntryFieldController
*/ */
public VascEntryFieldTypeControllerResolver getVascEntryFieldTypeControllerResolver(); public VascEntryFieldTypeController getVascEntryFieldTypeController();
/** /**
* *
* @return Returns the VascEventChannelControllerResolver * @return Returns the VascEventChannelController
*/ */
public VascEventChannelControllerResolver getVascEventChannelControllerResolver(); public VascEventChannelController getVascEventChannelController();
/** /**
* *
* @return Returns the VascUserRoleControllerResolver * @return Returns the VascUserRoleController
*/ */
public VascUserRoleControllerResolver getVascUserRoleControllerResolver(); public VascUserRoleController getVascUserRoleController();
} }

View file

@ -1,38 +0,0 @@
/*
* 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.core;
/**
*
* @author Willem Cazander
* @version 1.0 Sep 4, 2008
*/
public interface VascEntryControllerResolver {
public VascEntryController getVascEntryController();
}

View file

@ -1,38 +0,0 @@
/*
* 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.core;
/**
*
* @author Willem Cazander
* @version 1.0 Sep 4, 2008
*/
public interface VascEntryFieldTypeControllerResolver {
public VascEntryFieldTypeController getVascEntryFieldTypeController();
}

View file

@ -0,0 +1,117 @@
/*
* 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.core;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* Holds all the data for state.
* So we can jump forward or back to a state.
*
* @author Willem Cazander
* @version 1.0 Dec 15, 2009
*/
public interface VascEntryState extends Serializable {
/**
* @return the entryDataList
*/
public List<Object> getEntryDataList();
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> entryDataList);
/**
* @return the entryDataObject
*/
public Object getEntryDataObject();
/**
* @param entryDataObject the entryDataObject to set
*/
public void setEntryDataObject(Object entryDataObject);
/**
* @return the vascBackendState
*/
public VascBackendState getVascBackendState();
/**
* @param vascBackendState the vascBackendState to set
*/
public void setVascBackendState(VascBackendState vascBackendState);
/**
* @return the totalBackendRecords
*/
public Long getTotalBackendRecords();
/**
* @param totalBackendRecords the totalBackendRecords to set
*/
public void setTotalBackendRecords(Long totalBackendRecords);
/**
* @param state The previous state we come from.
*/
public void setParent(VascEntryState state);
/**
* @return The previous state we come from.
*/
public VascEntryState getParent();
public void setMultiActionSelection(Map<Integer,Boolean> multiActionSelection);
public Map<Integer,Boolean> getMultiActionSelection();
public void setVascEntry(VascEntry vascEntry);
public VascEntry getVascEntry();
/**
* @return the vascBackend
*/
public VascBackend getVascBackend();
/**
* @param vascBackend the vascBackend to set
*/
public void setVascBackend(VascBackend vascBackend);
/**
* @return the isEditCreate
*/
public boolean isEditCreate();
/**
* @param isEditCreate the isEditCreate to set
*/
public void setEditCreate(boolean isEditCreate);
}

View file

@ -1,38 +0,0 @@
/*
* 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.core;
/**
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2008
*/
public interface VascEventChannelControllerResolver {
public VascEventChannelController getVascEventChannelController();
}

View file

@ -42,26 +42,6 @@ import com.idcanet.vasc.core.ui.VascUIComponent;
*/ */
public interface VascFrontendData { public interface VascFrontendData {
/**
* @return the entryDataList
*/
public List<Object> getEntryDataList();
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> entryDataList);
/**
* @return the entryDataObject
*/
public Object getEntryDataObject();
/**
* @param entryDataObject the entryDataObject to set
*/
public void setEntryDataObject(Object entryDataObject);
/** /**
* @return the vascFrontend * @return the vascFrontend
*/ */
@ -107,16 +87,6 @@ public interface VascFrontendData {
public Object getFieldRealRenderer(VascEntryField field); public Object getFieldRealRenderer(VascEntryField field);
public void clearFieldRenderObjects(); public void clearFieldRenderObjects();
/**
* @return the vascBackend
*/
public VascBackend getVascBackend();
/**
* @param vascBackend the vascBackend to set
*/
public void setVascBackend(VascBackend vascBackend);
/** /**
* @return the exceptionListener * @return the exceptionListener
*/ */
@ -140,33 +110,6 @@ public interface VascFrontendData {
public void addVascValidatorService(VascEntryFieldValidatorService validatorService); public void addVascValidatorService(VascEntryFieldValidatorService validatorService);
public List<VascEntryFieldValidatorService> getVascValidatorServices(); public List<VascEntryFieldValidatorService> getVascValidatorServices();
/** public VascEntryState getVascEntryState();
* @return the isEditCreate public void setVascEntryState(VascEntryState state);
*/
public boolean isEditCreate();
/**
* @param isEditCreate the isEditCreate to set
*/
public void setEditCreate(boolean isEditCreate);
/**
* @return the vascBackendState
*/
public VascBackendState getVascBackendState();
/**
* @param vascBackendState the vascBackendState to set
*/
public void setVascBackendState(VascBackendState vascBackendState);
/**
* @return the totalBackendRecords
*/
public Long getTotalBackendRecords();
/**
* @param totalBackendRecords the totalBackendRecords to set
*/
public void setTotalBackendRecords(Long totalBackendRecords);
} }

View file

@ -83,4 +83,6 @@ public interface VascFrontendHelper {
public void pageAction(VascEntry entry,Integer page); public void pageAction(VascEntry entry,Integer page);
public void moveAction(VascEntry entry,Object object,boolean moveUp); public void moveAction(VascEntry entry,Object object,boolean moveUp);
public List<RowVascAction> getMultiRowActions(VascEntry entry);
} }

View file

@ -1,38 +0,0 @@
/*
* 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.core;
/**
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2008
*/
public interface VascUserRoleControllerResolver {
public VascUserRoleController getVascUserRoleController();
}

View file

@ -35,6 +35,7 @@ package com.idcanet.vasc.core.actions;
*/ */
abstract public class AbstractVascAction implements VascAction { abstract public class AbstractVascAction implements VascAction {
private static final long serialVersionUID = 1L;
private String id = null; private String id = null;
private String name = null; private String name = null;
private String description = null; private String description = null;

View file

@ -142,7 +142,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
public void renderEdit() throws Exception { public void renderEdit() throws Exception {
logger.fine("Rending Edit View"); logger.fine("Rending Edit View");
Object rowBean = entry.getVascFrontendData().getEntryDataObject(); Object rowBean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
String beanValue = rowBean.toString(); String beanValue = rowBean.toString();
if (entry.getDisplayNameFieldId()!=null) { if (entry.getDisplayNameFieldId()!=null) {
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
@ -163,12 +163,12 @@ public class SwingVascFrontend extends AbstractVascFrontend {
if(result==null) { if(result==null) {
return; return;
} }
entry.getVascFrontendData().setEntryDataObject(result); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry); entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry);
} }
public void renderDelete() throws Exception { public void renderDelete() throws Exception {
Object rowBean = entry.getVascFrontendData().getEntryDataObject(); Object rowBean = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
String beanValue = rowBean.toString(); String beanValue = rowBean.toString();
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
@ -476,7 +476,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
table.addMouseListener(new MouseAdapter() { table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) { if (e.getClickCount() == 2) {
Object o = entry.getVascFrontendData().getEntryDataObject(); Object o = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
if (o==null) { if (o==null) {
return; return;
} }
@ -505,10 +505,10 @@ public class SwingVascFrontend extends AbstractVascFrontend {
if (rowIndex!=-1) { if (rowIndex!=-1) {
// temp; gets index by sorter // temp; gets index by sorter
//rowIndex = tableSorter.modelIndex(rowIndex); //rowIndex = tableSorter.modelIndex(rowIndex);
Object data = entry.getVascFrontendData().getEntryDataList().get(rowIndex); Object data = entry.getVascFrontendData().getVascEntryState().getEntryDataList().get(rowIndex);
entry.getVascFrontendData().setEntryDataObject(data); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(data);
} else { } else {
entry.getVascFrontendData().setEntryDataObject(null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
} }
} }
} }
@ -567,7 +567,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
logger.fine("Row Action"); logger.fine("Row Action");
try { try {
action.doRowAction(entry, entry.getVascFrontendData().getEntryDataObject()); action.doRowAction(entry, entry.getVascFrontendData().getVascEntryState().getEntryDataObject());
} catch (Exception e) { } catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e); entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
} }
@ -621,17 +621,17 @@ public class SwingVascFrontend extends AbstractVascFrontend {
* @see javax.swing.entry.entryModel#getRowCount() * @see javax.swing.entry.entryModel#getRowCount()
*/ */
public int getRowCount() { public int getRowCount() {
if (entry.getVascFrontendData().getEntryDataList()==null) { if (entry.getVascFrontendData().getVascEntryState().getEntryDataList()==null) {
return 0; return 0;
} }
return entry.getVascFrontendData().getEntryDataList().size(); return entry.getVascFrontendData().getVascEntryState().getEntryDataList().size();
} }
/** /**
* @see javax.swing.entry.entryModel#getValueAt(int, int) * @see javax.swing.entry.entryModel#getValueAt(int, int)
*/ */
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
Object bean = entry.getVascFrontendData().getEntryDataList().get(rowIndex); Object bean = entry.getVascFrontendData().getVascEntryState().getEntryDataList().get(rowIndex);
logger.finer("Rending column; "+columnIndex+" bean: "+bean); logger.finer("Rending column; "+columnIndex+" bean: "+bean);
// TODO: this is slowing.... // TODO: this is slowing....

View file

@ -35,18 +35,20 @@ public class JSFVascEntryEventListener implements VascEntryEventListener {
VascEntryField fieldClone = field.clone(); VascEntryField fieldClone = field.clone();
fieldClone.getVascValidators().clear(); fieldClone.getVascValidators().clear();
VascEntryFieldValue v = entry.getVascFrontendData().getVascBackend().provideVascEntryFieldValue(fieldClone); VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
field.setVascEntryFieldValue(v); field.setVascEntryFieldValue(v);
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
List<Object> data = entry.getVascFrontendData().getEntryDataList(); List<Object> data = entry.getVascFrontendData().getVascEntryState().getEntryDataList();
List<Object> result = new ArrayList<Object>(data.size()); List<Object> result = new ArrayList<Object>(data.size());
int index = 0;
for (Object o:data) { for (Object o:data) {
VascDataBackendBean b = new VascDataBackendBean(entry,o); VascDataBackendBean b = new VascDataBackendBean(entry,o,index);
result.add(b); result.add(b);
index++;
} }
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tableDataModel.wrappedData}", Object.class); ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tableDataModel.wrappedData}", Object.class);

View file

@ -41,6 +41,9 @@ import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlCommandLink;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.faces.event.ValueChangeEvent; import javax.faces.event.ValueChangeEvent;
import javax.faces.model.DataModel; import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
@ -48,13 +51,16 @@ import javax.faces.model.SelectItem;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendPageNumber; import com.idcanet.vasc.core.VascBackendPageNumber;
import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryState;
import com.idcanet.vasc.core.VascLinkEntry; import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction; import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryExporter; import com.idcanet.vasc.core.entry.VascEntryExporter;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
/** /**
* *
@ -81,6 +87,7 @@ public class JSFVascEntrySupportBean implements Serializable {
private VascEntryExporter selectedExporter = null; private VascEntryExporter selectedExporter = null;
private String selectedExporterAction = "null"; private String selectedExporterAction = "null";
private String selectedDirectPage = "null"; private String selectedDirectPage = "null";
private String selectedMultiRowAction = "null";
private Map<String,Object> editSelectItemModels = null; private Map<String,Object> editSelectItemModels = null;
public JSFVascEntrySupportBean(VascEntry entry) { public JSFVascEntrySupportBean(VascEntry entry) {
@ -96,10 +103,11 @@ public class JSFVascEntrySupportBean implements Serializable {
editSelectItemModels = new HashMap<String,Object>(6); editSelectItemModels = new HashMap<String,Object>(6);
// cache some values // cache some values
backendPageable = entry.getVascFrontendData().getVascBackend().isPageable(); VascBackend backend = entry.getVascFrontendData().getVascEntryState().getVascBackend();;
backendMoveable = entry.getVascFrontendData().getVascBackend().isRecordMoveable(); backendPageable = backend.isPageable();
backendSearchable = entry.getVascFrontendData().getVascBackend().isSearchable(); backendMoveable = backend.isRecordMoveable();
backendSortable = entry.getVascFrontendData().getVascBackend().isSortable(); backendSearchable = backend.isSearchable();
backendSortable = backend.isSortable();
i18nMap = new JSFVascSupportI18nMapController(entry); i18nMap = new JSFVascSupportI18nMapController(entry);
@ -134,6 +142,9 @@ public class JSFVascEntrySupportBean implements Serializable {
public int getTotalFieldColumnCount() { public int getTotalFieldColumnCount() {
int t = 0; int t = 0;
if (getHasMultiRowActions()) {
t++; // auto add of select boxes
}
for (VascEntryField c:entry.getVascEntryFields()) { for (VascEntryField c:entry.getVascEntryFields()) {
if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) { if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) {
continue; continue;
@ -145,43 +156,42 @@ public class JSFVascEntrySupportBean implements Serializable {
public int getTotalActionColumnCount() { public int getTotalActionColumnCount() {
int t = 0; int t = 0;
if (entry.getVascFrontendData().getVascBackend().isRecordMoveable()) { if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
t++; t++;
t++; t++;
} }
for (RowVascAction action:entry.getRowActions()) { t+=entry.getRowActions().size();
t++;
}
return t; return t;
} }
public int getTotalLinkColumnCount() { public int getTotalLinkColumnCount() {
int t = 0; JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(FacesContext.getCurrentInstance().getViewRoot(),entry.getId());
for (VascLinkEntry vascLink:entry.getVascLinkEntries()) { String disableLinkColumns = (String)comp.getAttributes().get(JSFVascUIComponent.DISABLE_LINK_COLUMNS);
t++; if (disableLinkColumns!=null && disableLinkColumns.equals("true")) {
return 0; // not added too table.
} }
return t; return entry.getVascLinkEntries().size();
} }
public long getPageTotalRecordCount() { public long getPageTotalRecordCount() {
long result = entry.getVascFrontendData().getTotalBackendRecords(); long result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
return result; return result;
} }
public long getPageStartCount() { public long getPageStartCount() {
int index = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int index = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int pageSize = entry.getVascFrontendData().getVascBackendState().getPageSize(); int pageSize = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
long result = index*pageSize; long result = index*pageSize;
return result; return result;
} }
public long getPageStopCount() { public long getPageStopCount() {
int index = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int index = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int pageSize = entry.getVascFrontendData().getVascBackendState().getPageSize(); int pageSize = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
long result = (index*pageSize)+pageSize; long result = (index*pageSize)+pageSize;
// limit for small result sets. // limit for small result sets.
if (result>entry.getVascFrontendData().getTotalBackendRecords()) { if (result>entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords()) {
result = entry.getVascFrontendData().getTotalBackendRecords(); result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
} }
return result; return result;
} }
@ -189,8 +199,8 @@ public class JSFVascEntrySupportBean implements Serializable {
public List<SelectItem> getGlobalExportItems() { public List<SelectItem> getGlobalExportItems() {
List<SelectItem> result = new ArrayList<SelectItem>(5); List<SelectItem> result = new ArrayList<SelectItem>(5);
SelectItem s = new SelectItem(); SelectItem s = new SelectItem();
s.setLabel("..."); s.setLabel(i18nMap.get("generic.vasc.jsf.table.export.select"));
s.setDescription("Selecteer Export"); s.setDescription(i18nMap.get("generic.vasc.jsf.table.export.select.alt"));
s.setValue("null"); s.setValue("null");
result.add(s); result.add(s);
@ -203,25 +213,26 @@ public class JSFVascEntrySupportBean implements Serializable {
result.add(s); result.add(s);
} }
} }
return result; return result;
} }
public List<SelectItem> getDirectPageItems() { public List<SelectItem> getDirectPageItems() {
List<SelectItem> result = new ArrayList<SelectItem>(5); List<SelectItem> result = new ArrayList<SelectItem>(5);
SelectItem s = new SelectItem(); SelectItem s = new SelectItem();
s.setLabel("..."); s.setLabel(i18nMap.get("generic.vasc.jsf.table.page.select"));
s.setDescription("Selecteer Page"); s.setDescription(i18nMap.get("generic.vasc.jsf.table.page.select.alt"));
s.setValue("null"); s.setValue("null");
result.add(s); result.add(s);
int pageSize = getVascEntry().getVascFrontendData().getVascBackendState().getPageSize(); int pageSize = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
for (int i=0;i<getTablePagesDataModel().getRowCount();i++) { for (int i=0;i<getTablePagesDataModel().getRowCount();i++) {
getTablePagesDataModel().setRowIndex(i); getTablePagesDataModel().setRowIndex(i);
VascBackendPageNumber page = (VascBackendPageNumber)getTablePagesDataModel().getRowData(); VascBackendPageNumber page = (VascBackendPageNumber)getTablePagesDataModel().getRowData();
s = new SelectItem(); s = new SelectItem();
s.setLabel("Page: "+page.getPageNumber()+" "+(i*pageSize)+"-"+((i*pageSize)+pageSize)); String name = i18nMap.get("generic.vasc.jsf.table.page.name");
s.setDescription("Ga naar pagina: "+page.getPageNumber()); String description = i18nMap.get("generic.vasc.jsf.table.page.description");
s.setLabel(name+page.getPageNumber()+" "+(i*pageSize)+"-"+((i*pageSize)+pageSize));
s.setDescription(description+page.getPageNumber());
s.setValue(page.getPageNumber()); s.setValue(page.getPageNumber());
result.add(s); result.add(s);
} }
@ -241,12 +252,12 @@ public class JSFVascEntrySupportBean implements Serializable {
if (getHasExtendedPageMode()==false) { if (getHasExtendedPageMode()==false) {
return false; return false;
} }
int page = getVascEntry().getVascFrontendData().getVascBackendState().getPageIndex(); int page = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (page<5) { if (page<5) {
return false; return false;
} }
int pages = getTablePagesDataModel().getRowCount(); int pages = getTablePagesDataModel().getRowCount();
if (page>pages-5) { if (page>pages-6) {
return false; return false;
} }
return true; return true;
@ -261,7 +272,7 @@ public class JSFVascEntrySupportBean implements Serializable {
getTablePagesDataModel().setRowIndex(2); getTablePagesDataModel().setRowIndex(2);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
int page = getVascEntry().getVascFrontendData().getVascBackendState().getPageIndex(); int page = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (page==2 | page==3 | page==4) { if (page==2 | page==3 | page==4) {
getTablePagesDataModel().setRowIndex(3); getTablePagesDataModel().setRowIndex(3);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
@ -280,18 +291,18 @@ public class JSFVascEntrySupportBean implements Serializable {
public List<VascBackendPageNumber> getTablePagesExtendedEnd() { public List<VascBackendPageNumber> getTablePagesExtendedEnd() {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(6); List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(6);
int pages = getTablePagesDataModel().getRowCount(); int pages = getTablePagesDataModel().getRowCount();
int page = getVascEntry().getVascFrontendData().getVascBackendState().getPageIndex(); int page = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int off = pages-page; int off = pages-page;
if (off==4) { if (off==5) {
getTablePagesDataModel().setRowIndex(pages-6); getTablePagesDataModel().setRowIndex(pages-6);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
} }
if (off==3 | off==4) { if (off==4 | off==5) {
getTablePagesDataModel().setRowIndex(pages-5); getTablePagesDataModel().setRowIndex(pages-5);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
} }
if (off==2 | off==3 | off==4) { if (off==3 | off==4 | off==5) {
getTablePagesDataModel().setRowIndex(pages-4); getTablePagesDataModel().setRowIndex(pages-4);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
} }
@ -302,15 +313,12 @@ public class JSFVascEntrySupportBean implements Serializable {
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
getTablePagesDataModel().setRowIndex(pages-1); getTablePagesDataModel().setRowIndex(pages-1);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
return result; return result;
} }
public List<VascBackendPageNumber> getTablePagesExtendedCenter() { public List<VascBackendPageNumber> getTablePagesExtendedCenter() {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(3); List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(3);
int page = getVascEntry().getVascFrontendData().getVascBackendState().getPageIndex(); int page = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
getTablePagesDataModel().setRowIndex(page-1); getTablePagesDataModel().setRowIndex(page-1);
result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData()); result.add((VascBackendPageNumber)getTablePagesDataModel().getRowData());
getTablePagesDataModel().setRowIndex(page); getTablePagesDataModel().setRowIndex(page);
@ -330,6 +338,97 @@ public class JSFVascEntrySupportBean implements Serializable {
throw new IllegalArgumentException("Component is of link of button type: "+comp); throw new IllegalArgumentException("Component is of link of button type: "+comp);
} }
public boolean getHasMultiRowActions() {
int size = getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry()).size();
if (size==0) {
return false;
}
return true;
}
public List<SelectItem> getMultiRowActionItems() {
List<SelectItem> result = new ArrayList<SelectItem>(5);
SelectItem s = new SelectItem();
s.setLabel(i18nMap.get("generic.vasc.jsf.multiAction.name"));
s.setDescription(i18nMap.get("generic.vasc.jsf.multiAction.description"));
s.setValue("null");
result.add(s);
for (RowVascAction a:getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry())) {
s = new SelectItem();
s.setLabel(i18nMap.get(a.getName()));
s.setDescription(i18nMap.get(a.getDescription()));
s.setValue(a.getId());
result.add(s);
}
return result;
}
public void processMultiRowActionChange(ValueChangeEvent event) {
// first do normal global selection of action aka: globalAction(event); copyed:
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
String actionIdString = (String)event.getNewValue();
logger.finer("multri row id "+actionIdString);
// TODO: FIX this change listener is called before save action in row EDIT...
if (actionIdString==null) {
return;
}
// Default selection for fancy gui
if ("null".equals(actionIdString)) {
return;
}
logger.info("MultiRowAction: "+actionIdString);
FacesContext.getCurrentInstance().getViewRoot().addPhaseListener(new MultiRowAction(entry,actionIdString));
}
class MultiRowAction implements PhaseListener,Serializable {
private static final long serialVersionUID = 1L;
VascEntry vascEntry;
String actionId;
public MultiRowAction(VascEntry vascEntry,String actionId) {
this.vascEntry=vascEntry;
this.actionId=actionId;
}
public void beforePhase(PhaseEvent PhaseEvent) {
}
public void afterPhase(PhaseEvent PhaseEvent) {
if (vascEntry==null) {
return;
}
RowVascAction action = vascEntry.getRowActionById(actionId);
VascEntryState state = vascEntry.getVascFrontendData().getVascEntryState();
try {
for (Integer rowId:state.getMultiActionSelection().keySet()) {
Boolean value = state.getMultiActionSelection().get(rowId);
logger.fine("multiRow selected: "+rowId+" value: "+value);
if (value!=null && value==true) {
Object row = state.getEntryDataList().get(rowId);
logger.finer("row: "+row);
action.doRowAction(vascEntry, row);
}
}
setSelectedMultiRowAction("null"); // reset to selected ... value
state.getMultiActionSelection().clear(); // after down deselect all options
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
vascEntry=null;
}
}
public PhaseId getPhaseId(){
return PhaseId.UPDATE_MODEL_VALUES;
}
}
// All Actions // All Actions
public void searchAction(ActionEvent event) { public void searchAction(ActionEvent event) {
@ -353,7 +452,7 @@ public class JSFVascEntrySupportBean implements Serializable {
entry.getVascFrontendData().getVascFrontendHelper().sortAction(entry, field); entry.getVascFrontendData().getVascFrontendHelper().sortAction(entry, field);
sortOrder = entry.getVascFrontendData().getVascBackendState().isSortAscending(); sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
sortField = field.getId(); sortField = field.getId();
try { try {
@ -363,6 +462,44 @@ public class JSFVascEntrySupportBean implements Serializable {
} }
} }
public boolean getRenderBackAction() {
return getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null;
}
public void backAction(ActionEvent event) {
logger.fine("backAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = getVascEntry();
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent());
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void backEditAction(ActionEvent event) {
logger.fine("backEditAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = getVascEntry();
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent());
// select record to edit
Object rowObject = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
int index = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataList().indexOf(rowObject);
tableDataModel.setRowIndex(index);
try {
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascEventType.DATA_SELECT, rowObject);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendData().getVascFrontend().renderEdit();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void pageAction(ActionEvent event) { public void pageAction(ActionEvent event) {
logger.fine("pageAction"); logger.fine("pageAction");
Integer pageIndex = new Integer(getComponentType(event.getComponent())); Integer pageIndex = new Integer(getComponentType(event.getComponent()));
@ -382,7 +519,7 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
int pageIndex = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
pageIndex++; pageIndex++;
selectedDirectPage=pageIndex+""; selectedDirectPage=pageIndex+"";
entry.getVascFrontendData().getVascFrontendHelper().pageAction(entry, pageIndex); entry.getVascFrontendData().getVascFrontendHelper().pageAction(entry, pageIndex);
@ -398,7 +535,7 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
int pageIndex = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
pageIndex--; pageIndex--;
selectedDirectPage=pageIndex+""; selectedDirectPage=pageIndex+"";
entry.getVascFrontendData().getVascFrontendHelper().pageAction(entry, pageIndex); entry.getVascFrontendData().getVascFrontendHelper().pageAction(entry, pageIndex);
@ -411,12 +548,12 @@ public class JSFVascEntrySupportBean implements Serializable {
public boolean getHasPageNextAction() { public boolean getHasPageNextAction() {
VascEntry entry = getVascEntry(); VascEntry entry = getVascEntry();
int pageIndex = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
pageIndex++; pageIndex++;
// copyed from helper // copyed from helper
Long total = entry.getVascFrontendData().getTotalBackendRecords(); Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
logger.finer("Checking has next action for next pageIndex"+pageIndex+" of total: "+total+" and pageSize: "+entry.getVascFrontendData().getVascBackendState().getPageSize()); logger.finer("Checking has next action for next pageIndex"+pageIndex+" of total: "+total+" and pageSize: "+entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize());
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascBackendState().getPageSize())) { if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
return false; return false;
} }
return true; return true;
@ -424,7 +561,7 @@ public class JSFVascEntrySupportBean implements Serializable {
public boolean getHasPagePreviousAction() { public boolean getHasPagePreviousAction() {
VascEntry entry = getVascEntry(); VascEntry entry = getVascEntry();
int pageIndex = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (pageIndex==0) { if (pageIndex==0) {
return false; return false;
} }
@ -500,6 +637,24 @@ public class JSFVascEntrySupportBean implements Serializable {
this.selected=selected; // renderView clears selected ! this.selected=selected; // renderView clears selected !
} }
public void moveAction(ActionEvent event) {
logger.fine("moveAction");
String moveAction = getComponentType(event.getComponent());
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
Object selected = comp.getSupportBean().getSelectedTableRecord().getRecord();
if ("up".equals(moveAction)) {
entry.getVascFrontendData().getVascFrontendHelper().moveAction(entry,selected,true);
}
if ("down".equals(moveAction)) {
entry.getVascFrontendData().getVascFrontendHelper().moveAction(entry,selected,false);
}
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void linkEditAction(ActionEvent event) { public void linkEditAction(ActionEvent event) {
logger.fine("linkEditAction"); logger.fine("linkEditAction");
String linkId = getComponentType(event.getComponent()); String linkId = getComponentType(event.getComponent());
@ -517,11 +672,30 @@ public class JSFVascEntrySupportBean implements Serializable {
this.selected=selected; // renderView clears selected ! this.selected=selected; // renderView clears selected !
} }
public void linkListAction(ActionEvent event) {
logger.fine("linkListAction");
String linkId = getComponentType(event.getComponent());
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascLinkEntry link = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getVascEntry().getVascLinkEntryById(linkId);
comp.initGoto(link,comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent());
Object o = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
int index = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getEntryDataList().indexOf(o);
VascDataBackendBean selected = new VascDataBackendBean(entry,o,index);
this.selected=selected;
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
this.selected=selected;
}
public void cancelAction(ActionEvent event) { public void cancelAction(ActionEvent event) {
logger.fine("cancelAction"); logger.fine("cancelAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent()); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().setEntryDataObject(null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
try { try {
entry.getVascFrontendData().getVascFrontend().renderView(); entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) { } catch (Exception e) {
@ -548,7 +722,7 @@ public class JSFVascEntrySupportBean implements Serializable {
} }
*/ */
entry.getVascFrontendData().setEntryDataObject(selected.getRecord()); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(selected.getRecord());
entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry); entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry);
try { try {
@ -792,6 +966,20 @@ public class JSFVascEntrySupportBean implements Serializable {
return editSelectItemModels; return editSelectItemModels;
} }
/**
* @return the selectedMultiRowAction
*/
public String getSelectedMultiRowAction() {
return selectedMultiRowAction;
}
/**
* @param selectedMultiRowAction the selectedMultiRowAction to set
*/
public void setSelectedMultiRowAction(String selectedMultiRowAction) {
this.selectedMultiRowAction = selectedMultiRowAction;
}
} }
class JSFVascSupportI18nMapController implements Map<String,String> { class JSFVascSupportI18nMapController implements Map<String,String> {

View file

@ -99,8 +99,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
//String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); //String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
VascDataBackendBean selBean = null; VascDataBackendBean selBean = null;
if (entry.getVascFrontendData().isEditCreate()) { if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
selBean = new VascDataBackendBean(entry,entry.getVascFrontendData().getEntryDataObject()); int index = entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()+1;
selBean = new VascDataBackendBean(entry,entry.getVascFrontendData().getVascEntryState().getEntryDataObject(),index);
} else { } else {
selBean = comp.getSupportBean().getSelectedTableRecord(); selBean = comp.getSupportBean().getSelectedTableRecord();
} }

View file

@ -27,56 +27,25 @@
package com.idcanet.vasc.frontends.web.jsf; package com.idcanet.vasc.frontends.web.jsf;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.el.ELContext;
import javax.el.MethodExpression;
import javax.el.ValueExpression; import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase; import javax.faces.component.UIComponentBase;
import javax.faces.component.UIInput;
import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
import javax.faces.component.html.HtmlCommandLink;
import javax.faces.component.html.HtmlMessage;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.MethodExpressionActionListener;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import com.idcanet.vasc.core.AbstractVascFrontend;
import com.idcanet.vasc.core.VascBackend; import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendFilter;
import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryState;
import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontendData; import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.VascLinkEntry; import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener; import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryExporter;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType; import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.ui.VascOptionValueModelListener; import com.idcanet.vasc.impl.DefaultVascFactory;
import com.idcanet.vasc.core.ui.VascValueModel;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFBoolean;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFLabel;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFList;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFText;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFTextArea;
import com.idcanet.vasc.impl.VascBackendProxyFilter;
import com.idcanet.vasc.impl.VascBackendProxyPaged;
import com.idcanet.vasc.impl.VascBackendProxySearch;
import com.idcanet.vasc.impl.VascBackendProxySort;
/** /**
* Renders an JSF vasc entry views. * Renders an JSF vasc entry views.
@ -97,11 +66,14 @@ public class JSFVascUIComponent extends UIComponentBase {
public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId";
public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId"; public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId";
public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId"; public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId";
public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns";
private JSFVascFrontendRenderer renderer = null; private JSFVascFrontendRenderer renderer = null;
private JSFVascEntrySupportBean supportBean = null; private JSFVascEntrySupportBean supportBean = null;
private String renderFacetState = null; private String renderFacetState = null;
private VascLinkEntry link = null; private VascLinkEntry link = null;
private VascEntryState linkState = null;
private VascEntryState state = null;
private Logger logger = null; private Logger logger = null;
private Boolean initClear = null; private Boolean initClear = null;
@ -162,6 +134,9 @@ public class JSFVascUIComponent extends UIComponentBase {
} }
if (comp instanceof JSFVascUIComponent) { if (comp instanceof JSFVascUIComponent) {
JSFVascUIComponent ui = (JSFVascUIComponent)comp; JSFVascUIComponent ui = (JSFVascUIComponent)comp;
if (entryId==null) {
return ui;
}
if (entryId.equals(ui.getVascEntry().getId())) { if (entryId.equals(ui.getVascEntry().getId())) {
return ui; return ui;
} }
@ -201,6 +176,16 @@ public class JSFVascUIComponent extends UIComponentBase {
logger.fine("init goto "+link); logger.fine("init goto "+link);
this.link=link; this.link=link;
} }
protected void initGoto(VascLinkEntry link,VascEntryState state) {
logger.fine("init goto link: "+link);
this.link=link;
this.linkState=state;
}
protected void initGoto(VascEntryState state) {
logger.fine("init goto "+state);
this.state=state;
}
public Boolean getInitClear() { public Boolean getInitClear() {
return initClear; return initClear;
@ -210,7 +195,7 @@ public class JSFVascUIComponent extends UIComponentBase {
public void encodeBegin(FacesContext context) throws IOException { public void encodeBegin(FacesContext context) throws IOException {
logger.fine("Comp encodeBegin link: "+link); logger.fine("Comp encodeBegin link: "+link);
boolean init = false; boolean init = false;
if (renderer==null | link!=null) { if (renderer==null | link!=null | state!=null) {
renderFacetState = "listView"; renderFacetState = "listView";
VascEntry entry = createClonedVascEntry(); VascEntry entry = createClonedVascEntry();
renderer = new JSFVascFrontendRenderer(); renderer = new JSFVascFrontendRenderer();
@ -220,11 +205,14 @@ public class JSFVascUIComponent extends UIComponentBase {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e); entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
} }
supportBean = new JSFVascEntrySupportBean(entry); supportBean = new JSFVascEntrySupportBean(entry);
// copy search string for preadded search string from application layer
supportBean.setSearchString(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSearchString());
init = true; init = true;
// no need to add multiple // no need to add multiple
if (link!=null) { if (renderer==null) {
logger.finer("Adding phase listener: JSFVascValidatePhaseListener"); logger.info("Adding phase listener: JSFVascValidatePhaseListener");
context.getViewRoot().addPhaseListener(new JSFVascValidatePhaseListener()); context.getViewRoot().addPhaseListener(new JSFVascValidatePhaseListener());
} }
@ -238,7 +226,7 @@ public class JSFVascUIComponent extends UIComponentBase {
// set init for component renderer // set init for component renderer
if (init) { if (init) {
initClear = false; initClear = false;
if (link!=null) { if (link!=null | state!=null) {
initClear = true; initClear = true;
} }
} }
@ -290,55 +278,49 @@ public class JSFVascUIComponent extends UIComponentBase {
entryName = link.getVascEntryId(); entryName = link.getVascEntryId();
} }
VascEntry entry = vascController.getVascEntryControllerResolver().getVascEntryController().getVascEntryById(entryName); VascEntry entry = vascController.getVascEntryController().getVascEntryById(entryName);
if (entry==null) { if (entry==null) {
throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController); throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController);
} }
frontendData.setVascController(vascController); frontendData.setVascController(vascController);
entry.setVascFrontendData(frontendData); entry.setVascFrontendData(frontendData);
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()); frontendData.getVascEntryState().setVascBackend(backend);
frontendData.getVascEntryState().setVascEntry(entry);
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
filter.initFilter(entry);
backend = new VascBackendProxyFilter(backend,entry,filter);
}
if (backend.isSearchable()==false) {
backend = new VascBackendProxySearch(backend,entry);
}
if (backend.isSortable()==false) {
backend = new VascBackendProxySort(backend,entry);
}
if (backend.isPageable()==false) {
backend = new VascBackendProxyPaged(backend,entry);
}
frontendData.setVascBackend(backend);
if (link!=null) { if (link!=null) {
try { // save state
Object selected = getSupportBean().getSelected().getRecord(); if (linkState==null) {
for (String parameterName:link.getEntryParameterFieldIdKeys()) { frontendData.getVascEntryState().setParent(getVascEntry().getVascFrontendData().getVascEntryState());
String fieldId = link.getEntryParameterFieldId(parameterName); } else {
VascEntryField v = getVascEntry().getVascEntryFieldById(fieldId); frontendData.getVascEntryState().setParent(linkState);
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
// set data parameter on new vasc entry
entry.getVascFrontendData().getVascBackendState().setDataParameter(parameterName, selectedValue);
logger.fine("Setting link parameter: "+parameterName+" with: "+selectedValue);
} }
for (String fieldId:link.getEntryCreateFieldValueKeys()) { // Set parameters
String selectedfieldId = link.getEntryParameterFieldId(fieldId); try {
Object selectedValue = selected; Object selected = getSupportBean().getSelected().getRecord();
if (selectedfieldId!=null) { for (String parameterName:link.getEntryParameterFieldIdKeys()) {
VascEntryField v = getVascEntry().getVascEntryFieldById(selectedfieldId); String fieldId = link.getEntryParameterFieldId(parameterName);
selectedValue = v.getVascEntryFieldValue().getValue(v, selected); VascEntryField v = getVascEntry().getVascEntryFieldById(fieldId);
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
// set data parameter on new vasc entry
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
logger.fine("Setting link parameter: "+parameterName+" with: "+selectedValue);
} }
// create listener for new objects for (String fieldId:link.getEntryCreateFieldValueKeys()) {
entry.addVascEntryEventListener(VascEventType.DATA_CREATE, new CreateEntryFieldValuesListener2(fieldId,selectedValue)); String selectedfieldId = link.getEntryParameterFieldId(fieldId);
} Object selectedValue = selected;
if (selectedfieldId!=null) {
VascEntryField v = getVascEntry().getVascEntryFieldById(selectedfieldId);
selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
}
// create listener for new objects
entry.addVascEntryEventListener(VascEventType.DATA_CREATE, new CreateEntryFieldValuesListener2(fieldId,selectedValue));
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -43,13 +43,16 @@ import javax.faces.component.UIInput;
import javax.faces.component.UIOutput; import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot; import javax.faces.component.UIViewRoot;
import javax.faces.component.html.HtmlCommandLink; import javax.faces.component.html.HtmlCommandLink;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.component.html.HtmlMessage; import javax.faces.component.html.HtmlMessage;
import javax.faces.component.html.HtmlOutputText; import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlSelectBooleanCheckbox;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.faces.event.MethodExpressionActionListener; import javax.faces.event.MethodExpressionActionListener;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
import javax.faces.render.Renderer; import javax.faces.render.Renderer;
import javax.faces.validator.Validator; import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException; import javax.faces.validator.ValidatorException;
@ -218,6 +221,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
} }
public void validate(FacesContext context, UIComponent component,Object object) throws ValidatorException { public void validate(FacesContext context, UIComponent component,Object object) throws ValidatorException {
// always oke, we are runned by phase listener // always oke, we are runned by phase listener
System.out.println("Validate normal.");
} }
public void validatePhase(FacesContext context, UIComponent component,Object object) throws ValidatorException { public void validatePhase(FacesContext context, UIComponent component,Object object) throws ValidatorException {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component);
@ -231,7 +235,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
ve7.setValue(FacesContext.getCurrentInstance().getELContext(), object); ve7.setValue(FacesContext.getCurrentInstance().getELContext(), object);
List<String> errors = entry.getVascFrontendData().getVascFrontendHelper().validateObjectField(field); List<String> errors = entry.getVascFrontendData().getVascFrontendHelper().validateObjectField(field);
//System.out.println("Validate: "+component+" errors: "+errors.size()+" value: "+object); System.out.println("Validate: "+component+" errors: "+errors.size()+" value: "+object);
if (errors.isEmpty()) { if (errors.isEmpty()) {
return; // no errors return; // no errors
} }
@ -267,13 +271,11 @@ public class JSFVascUIComponentRenderer extends Renderer {
com.idcanet.vasc.core.ui.VascUIComponent editor = option.getVascEntryFieldType().provideEditorUIComponent(i,option); com.idcanet.vasc.core.ui.VascUIComponent editor = option.getVascEntryFieldType().provideEditorUIComponent(i,option);
model = new VascValueModel(option.getVascEntryFieldType().provideEditorVascValueModel(i,option)); model = new VascValueModel(option.getVascEntryFieldType().provideEditorVascValueModel(i,option));
model.addListener(new VascOptionValueModelListener(option)); model.addListener(new VascOptionValueModelListener(option));
model.setValue(null); model.setValue(option.getDefaultValue());
UIInput jsfEdit = (UIInput)editor.createComponent(entry,option,model,grid); UIInput jsfEdit = (UIInput)editor.createComponent(entry,option,model,grid);
jsfEdit.addValueChangeListener(new ModelChangeListener(model));
//ValueExpression ve7 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+getSelectedRecordName()+"."+option.getBackendName()+"}", Object.class); // i==0 is for multi field editor support... which is stell very in progress aka not working
//jsfEdit.setValueExpression("value", ve7);
// i==0 is for multi field editor support... which is stell very in progress
if (i==0) { if (i==0) {
entry.getVascFrontendData().addFieldVascUIComponents(option, editor,jsfEdit); entry.getVascFrontendData().addFieldVascUIComponents(option, editor,jsfEdit);
} }
@ -281,6 +283,20 @@ public class JSFVascUIComponentRenderer extends Renderer {
} }
entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry); entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
} }
public class ModelChangeListener implements ValueChangeListener,Serializable {
private static final long serialVersionUID = 1L;
VascValueModel model;
public ModelChangeListener(VascValueModel model) {
this.model=model;
}
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
try {
model.setValue(event.getNewValue());
} catch (VascException e) {
throw new AbortProcessingException(e);
}
}
}
private void addColumns(FacesContext fc,JSFVascUIComponent comp,UIComponent table) { private void addColumns(FacesContext fc,JSFVascUIComponent comp,UIComponent table) {
@ -291,6 +307,38 @@ public class JSFVascUIComponentRenderer extends Renderer {
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
String tableRecordVar = (String)comp.getAttributes().get(JSFVascUIComponent.TABLE_RECORD_VAR_KEY); String tableRecordVar = (String)comp.getAttributes().get(JSFVascUIComponent.TABLE_RECORD_VAR_KEY);
if (!entry.getVascFrontendData().getVascFrontendHelper().getMultiRowActions(entry).isEmpty()) {
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
colUp.setId(viewRoot.createUniqueId());
/*
// Select box head in table
HtmlCommandLink selectAll = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
selectAll.setId(viewRoot.createUniqueId());
selectAll.setType("selectAll");
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".selectAllAction}");
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
selectAll.addActionListener(meActionListener);
HtmlOutputText orderUp = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
orderUp.setId(viewRoot.createUniqueId());
orderUp.setEscape(false);
orderUp.setValue("selectAll");
selectAll.getChildren().add(orderUp);
colUp.setHeader(selectAll);
*/
HtmlSelectBooleanCheckbox select = (HtmlSelectBooleanCheckbox)application.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
select.setId(viewRoot.createUniqueId());
ValueExpression ve1 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),"#{"+entrySupportVar+".vascEntry.vascFrontendData.vascEntryState.multiActionSelection["+tableRecordVar+".recordId]}",Object.class);
select.setValueExpression("value", ve1);
colUp.getChildren().add(select);
table.getChildren().add(colUp);
}
for (VascEntryField c:entry.getVascEntryFields()) { for (VascEntryField c:entry.getVascEntryFields()) {
if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) { if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) {
continue; continue;
@ -340,14 +388,16 @@ public class JSFVascUIComponentRenderer extends Renderer {
table.getChildren().add(col); table.getChildren().add(col);
} }
if (entry.getVascFrontendData().getVascBackend().isRecordMoveable()) { if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE); UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
colUp.setId(viewRoot.createUniqueId()); colUp.setId(viewRoot.createUniqueId());
HtmlCommandLink linkUp = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE); HtmlCommandLink linkUp = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
linkUp.setId(viewRoot.createUniqueId()); linkUp.setId(viewRoot.createUniqueId());
linkUp.setType("up"); linkUp.setType("up");
//linkUp.addActionListener(new MoveActionListener()); MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".moveAction}");
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
linkUp.addActionListener(meActionListener);
HtmlOutputText orderUp = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); HtmlOutputText orderUp = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
orderUp.setId(viewRoot.createUniqueId()); orderUp.setId(viewRoot.createUniqueId());
@ -361,7 +411,9 @@ public class JSFVascUIComponentRenderer extends Renderer {
HtmlCommandLink linkDown = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE); HtmlCommandLink linkDown = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
linkDown.setId(viewRoot.createUniqueId()); linkDown.setId(viewRoot.createUniqueId());
linkDown.setType("down"); linkDown.setType("down");
//linkDown.addActionListener(new MoveActionListener()); MethodExpression actionExpression2 = getMethodExpression("#{"+entrySupportVar+".moveAction}");
MethodExpressionActionListener meActionListener2 = new MethodExpressionActionListener(actionExpression2);
linkDown.addActionListener(meActionListener2);
UIColumn colDown = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE); UIColumn colDown = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
colDown.setId(viewRoot.createUniqueId()); colDown.setId(viewRoot.createUniqueId());
@ -375,7 +427,13 @@ public class JSFVascUIComponentRenderer extends Renderer {
table.getChildren().add(colDown); table.getChildren().add(colDown);
} }
String disableLinkColumns = (String)comp.getAttributes().get(JSFVascUIComponent.DISABLE_LINK_COLUMNS);
for (VascLinkEntry vascLink:entry.getVascLinkEntries()) { for (VascLinkEntry vascLink:entry.getVascLinkEntries()) {
if (disableLinkColumns!=null && disableLinkColumns.equals("true")) {
continue; // do not all columns
}
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE); UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
col.setId(viewRoot.createUniqueId()); col.setId(viewRoot.createUniqueId());
@ -393,7 +451,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
link.addActionListener(meActionListener); link.addActionListener(meActionListener);
// rm this , bacause of unneeded copy, should add name to link // rm this , bacause of unneeded copy, should add name to link
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(vascLink.getVascEntryId()); VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(vascLink.getVascEntryId());
HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
out.setId(viewRoot.createUniqueId()); out.setId(viewRoot.createUniqueId());
@ -424,8 +482,6 @@ public class JSFVascUIComponentRenderer extends Renderer {
HtmlCommandLink link = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE); HtmlCommandLink link = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
link.setId(viewRoot.createUniqueId()); link.setId(viewRoot.createUniqueId());
link.setType(action.getId()); link.setType(action.getId());
//link.setImmediate(true);
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".rowAction}"); MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".rowAction}");
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression); MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
link.addActionListener(meActionListener); link.addActionListener(meActionListener);

View file

@ -50,10 +50,7 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
private ValueExpression injectEditFieldsId = null; private ValueExpression injectEditFieldsId = null;
private ValueExpression injectTableOptionsId = null; private ValueExpression injectTableOptionsId = null;
private ValueExpression injectTableColumnsId = null; private ValueExpression injectTableColumnsId = null;
private ValueExpression disableLinkColumns = null;
// noty used
private ValueExpression bundleName = null;
private ValueExpression locale = null;
@Override @Override
public String getComponentType() { public String getComponentType() {
@ -79,6 +76,7 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
processProperty(component, injectEditFieldsId, JSFVascUIComponent.INJECT_EDIT_FIELDS_ID); processProperty(component, injectEditFieldsId, JSFVascUIComponent.INJECT_EDIT_FIELDS_ID);
processProperty(component, injectTableOptionsId,JSFVascUIComponent.INJECT_TABLE_OPTIONS_ID); processProperty(component, injectTableOptionsId,JSFVascUIComponent.INJECT_TABLE_OPTIONS_ID);
processProperty(component, injectTableColumnsId,JSFVascUIComponent.INJECT_TABLE_COLUMNS_ID); processProperty(component, injectTableColumnsId,JSFVascUIComponent.INJECT_TABLE_COLUMNS_ID);
processProperty(component, disableLinkColumns ,JSFVascUIComponent.DISABLE_LINK_COLUMNS);
} }
public void release() { public void release() {
@ -91,6 +89,7 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
injectEditFieldsId = null; injectEditFieldsId = null;
injectTableOptionsId = null; injectTableOptionsId = null;
injectTableColumnsId = null; injectTableColumnsId = null;
disableLinkColumns = null;
} }
protected final void processProperty(final UIComponent component, final ValueExpression property,final String propertyName) { protected final void processProperty(final UIComponent component, final ValueExpression property,final String propertyName) {
@ -133,34 +132,6 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
this.entryName = entryName; this.entryName = entryName;
} }
/**
* @return the bundleName
*/
public ValueExpression getBundleName() {
return bundleName;
}
/**
* @param bundleName the bundleName to set
*/
public void setBundleName(ValueExpression bundleName) {
this.bundleName = bundleName;
}
/**
* @return the locale
*/
public ValueExpression getLocale() {
return locale;
}
/**
* @param locale the locale to set
*/
public void setLocale(ValueExpression locale) {
this.locale = locale;
}
/** /**
* @return the vascFrontendData * @return the vascFrontendData
*/ */
@ -244,4 +215,18 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
public void setTableRecordVar(ValueExpression tableRecordVar) { public void setTableRecordVar(ValueExpression tableRecordVar) {
this.tableRecordVar = tableRecordVar; this.tableRecordVar = tableRecordVar;
} }
/**
* @return the disableLinkColumns
*/
public ValueExpression getDisableLinkColumns() {
return disableLinkColumns;
}
/**
* @param disableLinkColumns the disableLinkColumns to set
*/
public void setDisableLinkColumns(ValueExpression disableLinkColumns) {
this.disableLinkColumns = disableLinkColumns;
}
} }

View file

@ -33,13 +33,14 @@ public class JSFVascValidatePhaseListener implements PhaseListener {
return PhaseId.PROCESS_VALIDATIONS; return PhaseId.PROCESS_VALIDATIONS;
} }
private void validateUIInput(UIComponent component,FacesContext context) { private void validateUIInput(UIComponent component,FacesContext context) {
System.out.println("Validate vasc: "+component);
if (component instanceof UIInput) { if (component instanceof UIInput) {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component); JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component);
if (comp==null) { if (comp==null) {
return; // non-vasc ui-input return; // non-vasc ui-input
} }
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
if (entry.getVascFrontendData().getEntryDataObject()==null) { if (entry.getVascFrontendData().getVascEntryState().getEntryDataObject()==null) {
return; // we are not in edit mode. return; // we are not in edit mode.
} }
UIInput in = (UIInput)component; UIInput in = (UIInput)component;

View file

@ -201,7 +201,7 @@ public class OldVascUIComponent extends UIComponentBase {
vascEntityName = entryNameRealId; vascEntityName = entryNameRealId;
} }
VascEntry entry = vascControllerObj.getVascEntryControllerResolver().getVascEntryController().getVascEntryById(vascEntityName); VascEntry entry = vascControllerObj.getVascEntryController().getVascEntryById(vascEntityName);
if (entry==null) { if (entry==null) {
throw new NullPointerException("Could not locate '"+vascEntityName+"' from : "+vascControllerObj+" ("+entryName.getExpressionString()+")"); throw new NullPointerException("Could not locate '"+vascEntityName+"' from : "+vascControllerObj+" ("+entryName.getExpressionString()+")");
} }
@ -212,7 +212,7 @@ public class OldVascUIComponent extends UIComponentBase {
frontendData.setVascController(vascControllerObj); frontendData.setVascController(vascControllerObj);
entry.setVascFrontendData(frontendData); entry.setVascFrontendData(frontendData);
VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()); VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendController().getVascBackendById(entry.getBackendId());
for (VascBackendFilter filter:entry.getVascBackendFilters()) { for (VascBackendFilter filter:entry.getVascBackendFilters()) {
filter.initFilter(entry); filter.initFilter(entry);
@ -227,30 +227,33 @@ public class OldVascUIComponent extends UIComponentBase {
if (backend.isPageable()==false) { if (backend.isPageable()==false) {
backend = new VascBackendProxyPaged(backend,entry); backend = new VascBackendProxyPaged(backend,entry);
} }
frontendData.setVascBackend(backend); frontendData.getVascEntryState().setVascBackend(backend);
entry.addVascEntryEventListener(VascEntryEventListener.VascEventType.DATA_LIST_UPDATE, new VascEntryEventListener() { entry.addVascEntryEventListener(VascEntryEventListener.VascEventType.DATA_LIST_UPDATE, new VascEntryEventListener() {
private static final long serialVersionUID = 1L;
public void vascEvent(VascEntry entry, VascEventType type,Object dataNotUsed) { public void vascEvent(VascEntry entry, VascEventType type,Object dataNotUsed) {
List<Object> data = entry.getVascFrontendData().getEntryDataList(); List<Object> data = entry.getVascFrontendData().getVascEntryState().getEntryDataList();
for (VascEntryField field:entry.getVascEntryFields()) { for (VascEntryField field:entry.getVascEntryFields()) {
if (field.getVascEntryFieldValue()==null) { if (field.getVascEntryFieldValue()==null) {
VascEntryFieldValue v = entry.getVascFrontendData().getVascBackend().provideVascEntryFieldValue(field); VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(field);
field.setVascEntryFieldValue(v); field.setVascEntryFieldValue(v);
} }
} }
List<Object> result = new ArrayList<Object>(data.size()); List<Object> result = new ArrayList<Object>(data.size());
int index = 0;
for (Object o:data) { for (Object o:data) {
VascDataBackendBean b = new VascDataBackendBean(entry,o); VascDataBackendBean b = new VascDataBackendBean(entry,o,index);
result.add(b); result.add(b);
index++;
} }
tableDataModel.setWrappedData(result); tableDataModel.setWrappedData(result);
pagesDataModel.setWrappedData(entry.getVascFrontendData().getVascFrontendHelper().getVascBackendPageNumbers(entry)); pagesDataModel.setWrappedData(entry.getVascFrontendData().getVascFrontendHelper().getVascBackendPageNumbers(entry));
// ui value // ui value
ValueExpression ren3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['totalPageResults']}", Integer.class); ValueExpression ren3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['totalPageResults']}", Integer.class);
ren3.setValue(FacesContext.getCurrentInstance().getELContext(), getVascEntry().getVascFrontendData().getEntryDataList().size()); ren3.setValue(FacesContext.getCurrentInstance().getELContext(), getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataList().size());
ValueExpression ren4 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['totalResults']}", Integer.class); ValueExpression ren4 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['totalResults']}", Integer.class);
ren4.setValue(FacesContext.getCurrentInstance().getELContext(), getVascEntry().getVascFrontendData().getTotalBackendRecords()); ren4.setValue(FacesContext.getCurrentInstance().getELContext(), getVascEntry().getVascFrontendData().getVascEntryState().getTotalBackendRecords());
} }
@Override @Override
public VascEntryEventListener clone() throws CloneNotSupportedException { public VascEntryEventListener clone() throws CloneNotSupportedException {
@ -436,7 +439,7 @@ public class OldVascUIComponent extends UIComponentBase {
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected); Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
// set data parameter on new vasc entry // set data parameter on new vasc entry
entry.getVascFrontendData().getVascBackendState().setDataParameter(parameterName, selectedValue); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
} }
for (String fieldId:link.getEntryCreateFieldValueKeys()) { for (String fieldId:link.getEntryCreateFieldValueKeys()) {
@ -475,6 +478,7 @@ public class OldVascUIComponent extends UIComponentBase {
} }
class CreateEntryFieldValuesListener implements VascEntryEventListener { class CreateEntryFieldValuesListener implements VascEntryEventListener {
private static final long serialVersionUID = 1L;
private String fieldId = null; private String fieldId = null;
private Object value = null; private Object value = null;
public CreateEntryFieldValuesListener(String fieldId,Object value) { public CreateEntryFieldValuesListener(String fieldId,Object value) {
@ -579,7 +583,7 @@ public class OldVascUIComponent extends UIComponentBase {
return; // non-vasc ui-input return; // non-vasc ui-input
} }
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
if (entry.getVascFrontendData().getEntryDataObject()==null) { if (entry.getVascFrontendData().getVascEntryState().getEntryDataObject()==null) {
return; // we are not in edit mode. return; // we are not in edit mode.
} }
UIInput in = (UIInput)component; UIInput in = (UIInput)component;
@ -1013,7 +1017,7 @@ public class OldVascUIComponent extends UIComponentBase {
public void processAction(ActionEvent event) { public void processAction(ActionEvent event) {
OldVascUIComponent comp = OldVascUIComponent.findVascParent(event.getComponent()); OldVascUIComponent comp = OldVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().setEntryDataObject(null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.selected}", Object.class); ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.selected}", Object.class);
VascDataBackendBean editObject = (VascDataBackendBean) ve2.getValue(FacesContext.getCurrentInstance().getELContext()); VascDataBackendBean editObject = (VascDataBackendBean) ve2.getValue(FacesContext.getCurrentInstance().getELContext());
if (editObject!=null) { if (editObject!=null) {
@ -1049,7 +1053,7 @@ public class OldVascUIComponent extends UIComponentBase {
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.selected}", Object.class); ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.selected}", Object.class);
VascDataBackendBean editObject = (VascDataBackendBean) ve2.getValue(FacesContext.getCurrentInstance().getELContext()); VascDataBackendBean editObject = (VascDataBackendBean) ve2.getValue(FacesContext.getCurrentInstance().getELContext());
entry.getVascFrontendData().setEntryDataObject(editObject.getRecord()); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(editObject.getRecord());
entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry); entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry);
try { try {
@ -1086,7 +1090,7 @@ public class OldVascUIComponent extends UIComponentBase {
ValueExpression ren2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['sortOrder']}", Boolean.class); ValueExpression ren2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['sortOrder']}", Boolean.class);
ValueExpression ren3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['sortField']}", String.class); ValueExpression ren3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['sortField']}", String.class);
ren2.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendData().getVascBackendState().isSortAscending()); ren2.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending());
ren3.setValue(FacesContext.getCurrentInstance().getELContext(), field.getId()); ren3.setValue(FacesContext.getCurrentInstance().getELContext(), field.getId());
try { try {
@ -1303,7 +1307,7 @@ public class OldVascUIComponent extends UIComponentBase {
gotoGroup.setId(viewRoot.createUniqueId()); gotoGroup.setId(viewRoot.createUniqueId());
gridHeader.getChildren().add(gotoGroup); gridHeader.getChildren().add(gotoGroup);
VascBackend backend = entry.getVascFrontendData().getVascBackend(); VascBackend backend = entry.getVascFrontendData().getVascEntryState().getVascBackend();
// create pageing // create pageing
if (backend.isPageable()) { if (backend.isPageable()) {
@ -1469,7 +1473,7 @@ public class OldVascUIComponent extends UIComponentBase {
table.getChildren().add(col); table.getChildren().add(col);
} }
if (entry.getVascFrontendData().getVascBackend().isRecordMoveable()) { if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE); UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
colUp.setId(viewRoot.createUniqueId()); colUp.setId(viewRoot.createUniqueId());
@ -1519,7 +1523,7 @@ public class OldVascUIComponent extends UIComponentBase {
link.addActionListener(new VascLinkActionListener(vascLink.getId())); link.addActionListener(new VascLinkActionListener(vascLink.getId()));
// rm this , bacause of unneeded copy, should add name to link // rm this , bacause of unneeded copy, should add name to link
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(vascLink.getVascEntryId()); VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(vascLink.getVascEntryId());
HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
out.setId(viewRoot.createUniqueId()); out.setId(viewRoot.createUniqueId());
@ -1626,8 +1630,9 @@ class JSFFrontendRenderer extends AbstractVascFrontend implements Serializable {
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry); entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
VascDataBackendBean selBean = null; VascDataBackendBean selBean = null;
if (entry.getVascFrontendData().isEditCreate()) { if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
selBean = new VascDataBackendBean(entry,entry.getVascFrontendData().getEntryDataObject()); int index = entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()+1;
selBean = new VascDataBackendBean(entry,entry.getVascFrontendData().getVascEntryState().getEntryDataObject(),index);
} else { } else {
selBean = comp.getSelectedTableBean(); selBean = comp.getSelectedTableBean();
} }

View file

@ -46,10 +46,12 @@ public class VascDataBackendBean implements Serializable {
private VascEntry entry = null; private VascEntry entry = null;
private Object record = null; private Object record = null;
private boolean realValue = false; private boolean realValue = false;
private int recordId = 0;
public VascDataBackendBean(VascEntry entry,Object record) { public VascDataBackendBean(VascEntry entry,Object record,int recordId) {
this.entry=entry; this.entry=entry;
this.record=record; this.record=record;
this.recordId=recordId;
} }
public boolean isRealValue() { public boolean isRealValue() {
@ -104,6 +106,10 @@ public class VascDataBackendBean implements Serializable {
return record; return record;
} }
public int getRecordId() {
return recordId;
}
// GET/SET bean methods for using in EL // GET/SET bean methods for using in EL

View file

@ -28,7 +28,6 @@ package com.idcanet.vasc.frontends.web.jsf.ui;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.el.ValueExpression; import javax.el.ValueExpression;
@ -73,10 +72,25 @@ public class JSFList extends AbstractJSFBaseComponent {
String id = component.getId(); String id = component.getId();
ValueExpression itemsTestVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+id+"']}", TestModel.class); ValueExpression itemsTestVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+id+"']}", TestModel.class);
//ValueExpression itemsDisVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{vascActionBean.values['jsfListItemDis_"+id+"']}", Boolean.class);
//itemsDisVE.setValue(FacesContext.getCurrentInstance().getELContext(), false);
TestModel t = new TestModel(); List<VascSelectItem> items;
List<SelectItem> value = new ArrayList<SelectItem>(50);
VascSelectItemModel itemModel = (VascSelectItemModel)entryField.getVascEntryFieldType().getDataObject();
try {
items = itemModel.getVascSelectItems(entryField.getVascEntry());
} catch (VascException e) {
throw new VascException(e);
}
for (VascSelectItem v:items) {
SelectItem si = new SelectItem();
si.setLabel(v.getLabel());
si.setValue(v.getValue());
si.setDisabled(v.isDisabled());
value.add(si);
}
TestModel t = new TestModel(items);
t.addAll(value);
t.entryField=entryField; t.entryField=entryField;
itemsTestVE.setValue(FacesContext.getCurrentInstance().getELContext(), t); itemsTestVE.setValue(FacesContext.getCurrentInstance().getELContext(), t);
@ -114,48 +128,8 @@ class TestModel extends ArrayList<SelectItem> implements Serializable {
public VascEntryField entryField; public VascEntryField entryField;
private List<VascSelectItem> items; private List<VascSelectItem> items;
public TestModel(List<VascSelectItem> items) {
@Override this.items=items;
public int size() {
if (super.isEmpty()) {
getItems();
}
return super.size();
}
@Override
public Iterator<SelectItem> iterator() {
if (super.isEmpty()) {
getItems();
}
return super.iterator();
}
@Override
public boolean isEmpty() {
if (super.isEmpty()) {
getItems();
}
return super.isEmpty();
}
public List<SelectItem> getItems() {
List<SelectItem> value = new ArrayList<SelectItem>(50);
VascSelectItemModel itemModel = (VascSelectItemModel)entryField.getVascEntryFieldType().getDataObject();
try {
items = itemModel.getVascSelectItems(entryField.getVascEntry());
} catch (VascException e) {
e.printStackTrace();
return value;
}
for (VascSelectItem v:items) {
SelectItem si = new SelectItem();
si.setLabel(v.getLabel());
si.setValue(v.getValue());
si.setDisabled(v.isDisabled());
this.add(si);
}
return value;
} }
public List<VascSelectItem> getVascItems() { public List<VascSelectItem> getVascItems() {

View file

@ -78,7 +78,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
} }
// Check if backendId is valid // Check if backendId is valid
VascBackend back = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() ); VascBackend back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
if (back==null) { if (back==null) {
throw new IllegalArgumentException("The VascEntry backendId is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id); throw new IllegalArgumentException("The VascEntry backendId is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
} }
@ -233,15 +233,15 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
} }
if (vef.getVascEntryFieldValue()==null) { if (vef.getVascEntryFieldValue()==null) {
VascBackend back2 = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() ); VascBackend back2 = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef)); vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef));
} }
if (vef.getVascEntryFieldType()==null) { if (vef.getVascEntryFieldType()==null) {
Object defValue = vef.getDefaultValue(); Object defValue = vef.getDefaultValue();
if (defValue != null) { if (defValue != null) {
for (String typeId: vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) { for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId); VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
if (type.getAutoDetectClass()!=null) { if (type.getAutoDetectClass()!=null) {
if (type.getAutoDetectClass().isAssignableFrom(defValue.getClass())) { if (type.getAutoDetectClass().isAssignableFrom(defValue.getClass())) {
@ -252,7 +252,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
} }
} }
if (vef.getVascEntryFieldType()==null) { if (vef.getVascEntryFieldType()==null) {
vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField")); vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField"));
} }
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit"); //vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
} }
@ -260,13 +260,15 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
//for (VascValidator vv:vef.getVascValidators()) { //for (VascValidator vv:vef.getVascValidators()) {
//} //}
} }
Collections.sort(entry.getVascEntryFields(),new Comparator() {
public int compare(Object o1, Object o2) {
VascEntryField v1 = (VascEntryField)o1; class OrderIndexComparator implements Comparator<VascEntryField> {
VascEntryField v2 = (VascEntryField)o2; public int compare(VascEntryField v1, VascEntryField v2) {
return v1.getOrderIndex().compareTo(v2.getOrderIndex()); return v1.getOrderIndex().compareTo(v2.getOrderIndex());
} }
}); }
Collections.sort(entry.getVascEntryFields(),new OrderIndexComparator());
// place primary key in front // place primary key in front
int index = 0; int index = 0;

View file

@ -1,51 +0,0 @@
/*
* 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;
import com.idcanet.vasc.core.VascBackendController;
import com.idcanet.vasc.core.VascBackendControllerResolver;
/**
*
* @author Willem Cazander
* @version 1.0 Sep 18, 2008
*/
public class DefaultVascBackendControllerResolver implements VascBackendControllerResolver {
private VascBackendController vascBackendController = null;
/**
* @see com.idcanet.vasc.core.VascBackendControllerResolver#getVascBackendController()
*/
public VascBackendController getVascBackendController() {
return vascBackendController;
}
public void setVascBackendController(VascBackendController vascBackendController) {
this.vascBackendController=vascBackendController;
}
}

View file

@ -26,12 +26,12 @@
package com.idcanet.vasc.impl; package com.idcanet.vasc.impl;
import com.idcanet.vasc.core.VascBackendControllerResolver; import com.idcanet.vasc.core.VascBackendController;
import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntryControllerResolver; import com.idcanet.vasc.core.VascEntryController;
import com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver; import com.idcanet.vasc.core.VascEntryFieldTypeController;
import com.idcanet.vasc.core.VascEventChannelControllerResolver; import com.idcanet.vasc.core.VascEventChannelController;
import com.idcanet.vasc.core.VascUserRoleControllerResolver; import com.idcanet.vasc.core.VascUserRoleController;
/** /**
* *
@ -41,79 +41,79 @@ import com.idcanet.vasc.core.VascUserRoleControllerResolver;
*/ */
public class DefaultVascController implements VascController { public class DefaultVascController implements VascController {
private VascBackendControllerResolver vascBackendControllerResolver = null; private VascBackendController vascBackendController = null;
private VascEntryControllerResolver vascEntryControllerResolver = null; private VascEntryController vascEntryController = null;
private VascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = null; private VascEntryFieldTypeController vascEntryFieldTypeController = null;
private VascEventChannelControllerResolver vascEventChannelControllerResolver = null; private VascEventChannelController vascEventChannelController = null;
private VascUserRoleControllerResolver vascUserRoleControllerResolver = null; private VascUserRoleController vascUserRoleController = null;
/** /**
* @return the vascEventChannelControllerResolver * @return the vascEventChannelController
*/ */
public VascEventChannelControllerResolver getVascEventChannelControllerResolver() { public VascEventChannelController getVascEventChannelController() {
return vascEventChannelControllerResolver; return vascEventChannelController;
} }
/** /**
* @param vascEventChannelControllerResolver the vascEventChannelControllerResolver to set * @param vascEventChannelController the vascEventChannelController to set
*/ */
public void setVascEventChannelControllerResolver(VascEventChannelControllerResolver vascEventChannelControllerResolver) { public void setVascEventChannelController(VascEventChannelController vascEventChannelController) {
this.vascEventChannelControllerResolver = vascEventChannelControllerResolver; this.vascEventChannelController = vascEventChannelController;
} }
/** /**
* @return the vascBackendControllerResolver * @return the vascBackendController
*/ */
public VascBackendControllerResolver getVascBackendControllerResolver() { public VascBackendController getVascBackendController() {
return vascBackendControllerResolver; return vascBackendController;
} }
/** /**
* @param vascBackendControllerResolver the vascBackendControllerResolver to set * @param vascBackendController the vascBackendController to set
*/ */
public void setVascBackendControllerResolver(VascBackendControllerResolver vascBackendControllerResolver) { public void setVascBackendController(VascBackendController vascBackendController) {
this.vascBackendControllerResolver = vascBackendControllerResolver; this.vascBackendController = vascBackendController;
} }
/** /**
* @return the vascEntryControllerResolver * @return the vascEntryController
*/ */
public VascEntryControllerResolver getVascEntryControllerResolver() { public VascEntryController getVascEntryController() {
return vascEntryControllerResolver; return vascEntryController;
} }
/** /**
* @param vascEntryControllerResolver the vascEntryControllerResolver to set * @param vascEntryController the vascEntryController to set
*/ */
public void setVascEntryControllerResolver(VascEntryControllerResolver vascEntryControllerResolver) { public void setVascEntryController(VascEntryController vascEntryController) {
this.vascEntryControllerResolver = vascEntryControllerResolver; this.vascEntryController = vascEntryController;
} }
/** /**
* @return the vascEntryFieldControllerResolver * @return the vascEntryFieldController
*/ */
public VascEntryFieldTypeControllerResolver getVascEntryFieldTypeControllerResolver() { public VascEntryFieldTypeController getVascEntryFieldTypeController() {
return vascEntryFieldTypeControllerResolver; return vascEntryFieldTypeController;
} }
/** /**
* @param vascEntryFieldControllerResolver the vascEntryFieldControllerResolver to set * @param vascEntryFieldController the vascEntryFieldController to set
*/ */
public void setVascEntryFieldTypeControllerResolver(VascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver) { public void setVascEntryFieldTypeController(VascEntryFieldTypeController vascEntryFieldTypeController) {
this.vascEntryFieldTypeControllerResolver = vascEntryFieldTypeControllerResolver; this.vascEntryFieldTypeController = vascEntryFieldTypeController;
} }
/** /**
* @return the vascUserRoleControllerResolver * @return the vascUserRoleController
*/ */
public VascUserRoleControllerResolver getVascUserRoleControllerResolver() { public VascUserRoleController getVascUserRoleController() {
return vascUserRoleControllerResolver; return vascUserRoleController;
} }
/** /**
* @param vascUserRoleControllerResolver the vascUserRoleControllerResolver to set * @param vascUserRoleController the vascUserRoleController to set
*/ */
public void setVascUserRoleControllerResolver(VascUserRoleControllerResolver vascUserRoleControllerResolver) { public void setVascUserRoleController(VascUserRoleController vascUserRoleController) {
this.vascUserRoleControllerResolver = vascUserRoleControllerResolver; this.vascUserRoleController = vascUserRoleController;
} }
} }

View file

@ -52,6 +52,7 @@ import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
*/ */
public class DefaultVascEntry implements VascEntry { public class DefaultVascEntry implements VascEntry {
private static final long serialVersionUID = 1L;
private String id = null; private String id = null;
private String name = null; private String name = null;
private String helpId = null; private String helpId = null;

View file

@ -1,52 +0,0 @@
/*
* 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;
import com.idcanet.vasc.core.VascEntryController;
import com.idcanet.vasc.core.VascEntryControllerResolver;
/**
*
* @author Willem Cazander
* @version 1.0 Sep 18, 2008
*/
public class DefaultVascEntryControllerResolver implements VascEntryControllerResolver {
private VascEntryController vascEntryController = null;
/**
* @see com.idcanet.vasc.core.VascEntryControllerResolver#getVascEntryController()
*/
public VascEntryController getVascEntryController() {
return vascEntryController;
}
public void setVascEntryController(VascEntryController vascEntryController) {
this.vascEntryController=vascEntryController;
}
}

View file

@ -43,6 +43,8 @@ import com.idcanet.vasc.validators.VascValidator;
*/ */
public class DefaultVascEntryField implements VascEntryField { public class DefaultVascEntryField implements VascEntryField {
private static final long serialVersionUID = 1L;
private VascEntry vascEntry = null; private VascEntry vascEntry = null;
private String id = null; private String id = null;

View file

@ -0,0 +1,16 @@
/**
*
*/
package com.idcanet.vasc.impl;
import com.idcanet.vasc.core.AbstractVascEntryState;
/**
* Holds all state values
*
* @author Willem Cazander
* @version 1.0 Dec 15, 2009
*/
public class DefaultVascEntryState extends AbstractVascEntryState {
private static final long serialVersionUID = 1L;
}

View file

@ -1,55 +0,0 @@
/*
* 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;
import com.idcanet.vasc.core.VascEventChannelController;
import com.idcanet.vasc.core.VascEventChannelControllerResolver;
/**
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2008
*/
public class DefaultVascEventChannelControllerResolver implements VascEventChannelControllerResolver {
private VascEventChannelController vascEventChannelController = null;
/**
* @return the vascEventChannelController
*/
public VascEventChannelController getVascEventChannelController() {
return vascEventChannelController;
}
/**
* @param vascEventChannelController the vascEventChannelController to set
*/
public void setVascEventChannelController(
VascEventChannelController vascEventChannelController) {
this.vascEventChannelController = vascEventChannelController;
}
}

View file

@ -0,0 +1,123 @@
/*
* 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;
import java.util.Locale;
import java.util.ResourceBundle;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendFilter;
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;
/**
* Default Vasc Factory for creating some base object plumming for vasc useage.
*
* @author Willem Cazander
* @version 1.0 Dec 15, 2009
*/
public class DefaultVascFactory {
static public VascController getDefaultVascController(Long userId,String userName,String...roles) throws VascException {
// config full controller for local jvm use
DefaultVascController c = new DefaultVascController();
DefaultVascBackendController vascBackendController = new DefaultVascBackendController();
c.setVascBackendController(vascBackendController);
DefaultVascEntryController vascEntryController = new DefaultVascEntryController();
c.setVascEntryController(vascEntryController);
DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController();
c.setVascEntryFieldTypeController(vascEntryFieldTypeController);
DefaultVascUserRoleController vascUserRoleController = new DefaultVascUserRoleController(userId,userName,roles);
c.setVascUserRoleController(vascUserRoleController);
return c;
}
static public VascFrontendData getDefaultVascFrontendData(String resourceBundle,Locale locale) {
ResourceBundle bundle = ResourceBundle.getBundle(resourceBundle, locale);
return getDefaultVascFrontendData(bundle);
}
static public VascFrontendData getDefaultVascFrontendData(ResourceBundle resourceBundle) {
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); // controller is set by vasc
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(resourceBundle));
vascFrontendData.setVascFrontendHelper(new DefaultVascFrontendHelper());
//vascFrontendData.setVascEntryResourceImageResolver(new ImageResources());
vascFrontendData.setVascEntryState(new DefaultVascEntryState());
vascFrontendData.getVascEntryState().setVascBackendState(new DefaultVascBackendState());
vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100); // default page size is zero aka disabled
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;
}
static public VascBackend getProxyVascBackend(VascEntry entry) {
// Get the real backend
VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendController().getVascBackendById(entry.getBackendId());
// logs all actions log logger
backend = new VascBackendProxyTimerLogger(backend,entry);
// only cached one result, checks for paramater differnce
backend = new VascBackendProxyCache(backend,entry);
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
filter.initFilter(entry);
backend = new VascBackendProxyFilter(backend,entry,filter);
}
if (backend.isSearchable()==false) {
backend = new VascBackendProxySearch(backend,entry);
}
if (backend.isSortable()==false) {
backend = new VascBackendProxySort(backend,entry);
}
if (backend.isPageable()==false) {
backend = new VascBackendProxyPaged(backend,entry);
}
return backend;
}
}

View file

@ -31,11 +31,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFinalizer; import com.idcanet.vasc.core.VascEntryFinalizer;
import com.idcanet.vasc.core.VascEntryState;
import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontend; import com.idcanet.vasc.core.VascFrontend;
import com.idcanet.vasc.core.VascFrontendData; import com.idcanet.vasc.core.VascFrontendData;
@ -46,7 +45,6 @@ import com.idcanet.vasc.core.entry.VascEntryResourceImageResolver;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver; import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
import com.idcanet.vasc.core.ui.VascUIComponent; import com.idcanet.vasc.core.ui.VascUIComponent;
/** /**
* *
* @author Willem Cazander * @author Willem Cazander
@ -54,11 +52,7 @@ import com.idcanet.vasc.core.ui.VascUIComponent;
*/ */
public class DefaultVascFrontendData implements VascFrontendData { public class DefaultVascFrontendData implements VascFrontendData {
private List<Object> entryDataList = null;
private Object entryDataObject = null;
private VascFrontend vascFrontend = null; private VascFrontend vascFrontend = null;
private VascBackend vascBackend = null;
private VascBackendState vascBackendState = null;
private VascEntryFinalizer vascEntryFinalizer = null; private VascEntryFinalizer vascEntryFinalizer = null;
private VascFrontendHelper vascFrontendHelper = null; private VascFrontendHelper vascFrontendHelper = null;
private VascEntryResourceResolver vascEntryResourceResolver = null; private VascEntryResourceResolver vascEntryResourceResolver = null;
@ -66,50 +60,20 @@ public class DefaultVascFrontendData implements VascFrontendData {
private Map<String,String> uiComponents = null; private Map<String,String> uiComponents = null;
private VascController vascController = null; private VascController vascController = null;
private VascEntryEventListener exceptionListener = null; private VascEntryEventListener exceptionListener = null;
private boolean isEditCreate = false; private VascEntryState state = null;
private Long totalBackendRecords = null;
private Map<VascEntryField,VascUIComponent> fieldComps = null; private Map<VascEntryField,VascUIComponent> fieldComps = null;
private Map<VascEntryField,Object> fieldEditors = null; private Map<VascEntryField,Object> fieldEditors = null;
private List<VascEntryFieldValidatorService> validatorServices = null; private List<VascEntryFieldValidatorService> validatorServices = null;
public DefaultVascFrontendData() { public DefaultVascFrontendData() {
entryDataList = new ArrayList<Object>(0);
uiComponents = new HashMap<String,String>(8); uiComponents = new HashMap<String,String>(8);
fieldComps = new HashMap<VascEntryField,VascUIComponent>(8); fieldComps = new HashMap<VascEntryField,VascUIComponent>(8);
fieldEditors = new HashMap<VascEntryField,Object>(8); fieldEditors = new HashMap<VascEntryField,Object>(8);
validatorServices = new ArrayList<VascEntryFieldValidatorService>(4); validatorServices = new ArrayList<VascEntryFieldValidatorService>(4);
} }
/**
* @return the entryDataList
*/
public List<Object> getEntryDataList() {
return entryDataList;
}
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> entryDataList) {
this.entryDataList = entryDataList;
}
/**
* @return the entryDataObject
*/
public Object getEntryDataObject() {
return entryDataObject;
}
/**
* @param entryDataObject the entryDataObject to set
*/
public void setEntryDataObject(Object entryDataObject) {
this.entryDataObject = entryDataObject;
}
/** /**
* @return the vascFrontend * @return the vascFrontend
*/ */
@ -244,20 +208,6 @@ public class DefaultVascFrontendData implements VascFrontendData {
return fieldComps.get(field); return fieldComps.get(field);
} }
/**
* @return the vascBackend
*/
public VascBackend getVascBackend() {
return vascBackend;
}
/**
* @param vascBackend the vascBackend to set
*/
public void setVascBackend(VascBackend vascBackend) {
this.vascBackend = vascBackend;
}
/** /**
* @return the exceptionListener * @return the exceptionListener
*/ */
@ -300,45 +250,11 @@ public class DefaultVascFrontendData implements VascFrontendData {
return validatorServices; return validatorServices;
} }
/** public VascEntryState getVascEntryState() {
* @return the isEditCreate return state;
*/
public boolean isEditCreate() {
return isEditCreate;
} }
/** public void setVascEntryState(VascEntryState state) {
* @param isEditCreate the isEditCreate to set this.state=state;
*/
public void setEditCreate(boolean isEditCreate) {
this.isEditCreate = isEditCreate;
}
/**
* @return the vascBackendState
*/
public VascBackendState getVascBackendState() {
return vascBackendState;
}
/**
* @param vascBackendState the vascBackendState to set
*/
public void setVascBackendState(VascBackendState vascBackendState) {
this.vascBackendState = vascBackendState;
}
/**
* @return the totalBackendRecords
*/
public Long getTotalBackendRecords() {
return totalBackendRecords;
}
/**
* @param totalBackendRecords the totalBackendRecords to set
*/
public void setTotalBackendRecords(Long totalBackendRecords) {
this.totalBackendRecords = totalBackendRecords;
} }
} }

View file

@ -72,7 +72,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (renderView(field)==false) { if (renderView(field)==false) {
return false; return false;
} }
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController(); VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesCreate()!=null && u.hasRole(field.getRolesCreate())) { if (field.getRolesCreate()!=null && u.hasRole(field.getRolesCreate())) {
return true; return true;
} }
@ -89,12 +89,12 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (renderView(field)==false) { if (renderView(field)==false) {
return false; return false;
} }
if (field.getVascEntry().getVascFrontendData().isEditCreate()) { if (field.getVascEntry().getVascFrontendData().getVascEntryState().isEditCreate()) {
if (renderCreate(field)==false) { if (renderCreate(field)==false) {
return false; return false;
} }
} }
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController(); VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesEdit()!=null && u.hasRole(field.getRolesEdit())) { if (field.getRolesEdit()!=null && u.hasRole(field.getRolesEdit())) {
return true; return true;
} }
@ -111,7 +111,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (renderView(field)==false) { if (renderView(field)==false) {
return false; return false;
} }
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController(); VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesEditReadOnly()!=null && u.hasRole(field.getRolesEditReadOnly())) { if (field.getRolesEditReadOnly()!=null && u.hasRole(field.getRolesEditReadOnly())) {
return true; return true;
} }
@ -128,7 +128,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (renderView(field)==false) { if (renderView(field)==false) {
return false; return false;
} }
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController(); VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesList()!=null && u.hasRole(field.getRolesList())) { if (field.getRolesList()!=null && u.hasRole(field.getRolesList())) {
return true; return true;
} }
@ -183,11 +183,11 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
*/ */
public List<VascBackendPageNumber> getVascBackendPageNumbers(VascEntry entry) { public List<VascBackendPageNumber> getVascBackendPageNumbers(VascEntry entry) {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(30); List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(30);
VascBackendState state = entry.getVascFrontendData().getVascBackendState(); VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
if (state.getPageSize()==0) { if (state.getPageSize()==0) {
return result; // paging disabled return result; // paging disabled
} }
Long total = entry.getVascFrontendData().getTotalBackendRecords(); Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
if (total==null) { if (total==null) {
return result; // no pages return result; // no pages
} }
@ -209,12 +209,9 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
VascEntryEventListener listener = entry.getVascFrontendData().getExceptionListener(); VascEntryEventListener listener = entry.getVascFrontendData().getExceptionListener();
if (listener==null) { if (listener==null) {
logger.log(Level.WARNING,exception.getMessage(),exception); logger.log(Level.WARNING,exception.getMessage(),exception);
throw new RuntimeException("Exception happend: "+exception.getMessage(),exception);
} }
try { listener.vascEvent(entry,VascEventType.EXCEPTION , exception);
listener.vascEvent(entry,VascEventType.EXCEPTION , exception);
} catch (Exception eee) {
logger.log(Level.WARNING,"Error in ExceptionListener: "+eee.getMessage(),eee);
}
} }
/** /**
@ -222,7 +219,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
*/ */
public Object createObject(VascEntry entry) { public Object createObject(VascEntry entry) {
try { try {
Object object = entry.getVascFrontendData().getVascBackend().provideVascEntryRecordCreator(entry.clone()).newRecord(entry); Object object = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryRecordCreator(entry.clone()).newRecord(entry);
for (VascEntryField field:entry.getVascEntryFields()) { for (VascEntryField field:entry.getVascEntryFields()) {
Object value = field.getVascEntryFieldValue().getValue(field, object); Object value = field.getVascEntryFieldValue().getValue(field, object);
if (value==null & field.getDefaultValue()!=null) { if (value==null & field.getDefaultValue()!=null) {
@ -247,8 +244,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
} }
protected int removeObjectFromDataList(VascEntry entry,Object object) { protected int removeObjectFromDataList(VascEntry entry,Object object) {
int indexOld = entry.getVascFrontendData().getEntryDataList().indexOf(object); int indexOld = entry.getVascFrontendData().getVascEntryState().getEntryDataList().indexOf(object);
if (entry.getVascFrontendData().getEntryDataList().remove(object)) { if (entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(object)) {
return indexOld; // java worked well for use return indexOld; // java worked well for use
} }
@ -261,7 +258,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
// is only null when creating objects // is only null when creating objects
if (idObject!=null) { if (idObject!=null) {
int index = 0; int index = 0;
for (Object o:entry.getVascFrontendData().getEntryDataList()) { for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId()); field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
Object id = field.getVascEntryFieldValue().getValue(field, o); Object id = field.getVascEntryFieldValue().getValue(field, o);
if (idObject.equals(id)) { if (idObject.equals(id)) {
@ -269,8 +266,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
} }
index++; index++;
} }
if (index<entry.getVascFrontendData().getEntryDataList().size()) { if (index<entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()) {
entry.getVascFrontendData().getEntryDataList().remove(index); entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(index);
return index; return index;
} }
} }
@ -284,14 +281,14 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
* @see com.idcanet.vasc.core.VascFrontendHelper#mergeObject(com.idcanet.vasc.core.VascEntry) * @see com.idcanet.vasc.core.VascFrontendHelper#mergeObject(com.idcanet.vasc.core.VascEntry)
*/ */
public Object mergeObject(VascEntry entry) { public Object mergeObject(VascEntry entry) {
Object object = entry.getVascFrontendData().getEntryDataObject(); Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
Object result = null; Object result = null;
try { try {
fireVascEvent(entry,VascEventType.DATA_PRE_UPDATE,object); fireVascEvent(entry,VascEventType.DATA_PRE_UPDATE,object);
int index = removeObjectFromDataList(entry,object); int index = removeObjectFromDataList(entry,object);
result = entry.getVascFrontendData().getVascBackend().merge(object); result = entry.getVascFrontendData().getVascEntryState().getVascBackend().merge(object);
entry.getVascFrontendData().getEntryDataList().add(index, result); entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result);
entry.getVascFrontendData().setEntryDataObject(null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
fireVascEvent(entry,VascEventType.DATA_POST_UPDATE,result); fireVascEvent(entry,VascEventType.DATA_POST_UPDATE,result);
fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE,result); fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE,result);
} catch (Exception e) { } catch (Exception e) {
@ -306,14 +303,14 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
* @param object * @param object
*/ */
public void deleteObject(VascEntry entry) { public void deleteObject(VascEntry entry) {
Object object = entry.getVascFrontendData().getEntryDataObject(); Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
try { try {
entry.getVascFrontendData().getVascBackend().delete(object); entry.getVascFrontendData().getVascEntryState().getVascBackend().delete(object);
} catch (Exception e) { } catch (Exception e) {
handleException(entry,e); handleException(entry,e);
} }
removeObjectFromDataList(entry,object); removeObjectFromDataList(entry,object);
entry.getVascFrontendData().setEntryDataObject(null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
fireVascEvent(entry,VascEventType.DATA_DELETE, object); fireVascEvent(entry,VascEventType.DATA_DELETE, object);
fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE, object); fireVascEvent(entry,VascEventType.DATA_LIST_UPDATE, object);
} }
@ -322,17 +319,17 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
* @see com.idcanet.vasc.core.VascFrontendHelper#refreshData(com.idcanet.vasc.core.VascEntry) * @see com.idcanet.vasc.core.VascFrontendHelper#refreshData(com.idcanet.vasc.core.VascEntry)
*/ */
public void refreshData(VascEntry entry) { public void refreshData(VascEntry entry) {
entry.getVascFrontendData().setEntryDataObject(null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
try { try {
for (String key:entry.getEntryParameterKeys()) { for (String key:entry.getEntryParameterKeys()) {
Object value = entry.getEntryParameter(key); Object value = entry.getEntryParameter(key);
entry.getVascFrontendData().getVascBackendState().setDataParameter(key, value); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(key, value);
} }
entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascBackend().execute(entry.getVascFrontendData().getVascBackendState())); entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(entry.getVascFrontendData().getVascEntryState().getVascBackendState()));
// also update total every time // also update total every time
Long total = entry.getVascFrontendData().getVascBackend().fetchTotalExecuteSize(entry.getVascFrontendData().getVascBackendState()); Long total = entry.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState());
entry.getVascFrontendData().setTotalBackendRecords(total); entry.getVascFrontendData().getVascEntryState().setTotalBackendRecords(total);
} catch (Exception e) { } catch (Exception e) {
handleException(entry, e); handleException(entry, e);
} }
@ -352,12 +349,12 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
throw new NullPointerException("Can't validate null field."); throw new NullPointerException("Can't validate null field.");
} }
VascEntry entry = field.getVascEntry(); VascEntry entry = field.getVascEntry();
if (entry.getVascFrontendData().getEntryDataObject()==null) { if (entry.getVascFrontendData().getVascEntryState().getEntryDataObject()==null) {
throw new NullPointerException("Can't validate null entry object."); throw new NullPointerException("Can't validate null entry object.");
} }
List<String> error = new ArrayList<String>(3); List<String> error = new ArrayList<String>(3);
try { try {
Object objectSelected = entry.getVascFrontendData().getEntryDataObject(); Object objectSelected = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
Object objectValue = field.getVascEntryFieldValue().getValue(field, objectSelected); Object objectValue = field.getVascEntryFieldValue().getValue(field, objectSelected);
for (VascEntryFieldValidatorService s:entry.getVascFrontendData().getVascValidatorServices()) { for (VascEntryFieldValidatorService s:entry.getVascFrontendData().getVascValidatorServices()) {
error.addAll(s.validateObjectField(field, objectSelected, objectValue)); error.addAll(s.validateObjectField(field, objectSelected, objectValue));
@ -407,7 +404,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
// TODO: move back to rendered when jsf fixes // TODO: move back to rendered when jsf fixes
if (entry.getVascFrontendData().getVascFrontendHelper().renderCreate(f) == false & if (entry.getVascFrontendData().getVascFrontendHelper().renderCreate(f) == false &
entry.getVascFrontendData().isEditCreate()) { entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
//entry.getVascFrontendData().getFieldVascUIComponent(f).setRendered(false); //entry.getVascFrontendData().getFieldVascUIComponent(f).setRendered(false);
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(true); entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(true);
} else { } else {
@ -417,10 +414,10 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
// only when editing set edit readonlys // only when editing set edit readonlys
if (entry.getVascFrontendData().getVascFrontendHelper().renderEditReadOnly(f) & if (entry.getVascFrontendData().getVascFrontendHelper().renderEditReadOnly(f) &
entry.getVascFrontendData().isEditCreate()==false) { entry.getVascFrontendData().getVascEntryState().isEditCreate()==false) {
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(true); entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(true);
} else { } else {
if (entry.getVascFrontendData().isEditCreate()==false) { // todo: remove when jsf fixes if (entry.getVascFrontendData().getVascEntryState().isEditCreate()==false) { // todo: remove when jsf fixes
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(false); entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(false);
} }
} }
@ -428,22 +425,22 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
} }
public void sortAction(VascEntry entry,VascEntryField field) { public void sortAction(VascEntry entry,VascEntryField field) {
String curSort = entry.getVascFrontendData().getVascBackendState().getSortField(); String curSort = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSortField();
if (field.getBackendName().equals(curSort)) { if (field.getBackendName().equals(curSort)) {
entry.getVascFrontendData().getVascBackendState().setSortAscending(!entry.getVascFrontendData().getVascBackendState().isSortAscending()); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortAscending(!entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending());
} }
String sortID = field.getBackendName(); String sortID = field.getBackendName();
entry.getVascFrontendData().getVascBackendState().setSortField(sortID); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(sortID);
entry.getVascFrontendData().getVascBackendState().setPageIndex(0); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_SORT, field); fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_SORT, field);
refreshData(entry); refreshData(entry);
} }
public void searchAction(VascEntry entry,String searchString) { public void searchAction(VascEntry entry,String searchString) {
entry.getVascFrontendData().getVascBackendState().setSearchString(searchString); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSearchString(searchString);
entry.getVascFrontendData().getVascBackendState().setSortField(null); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(null);
entry.getVascFrontendData().getVascBackendState().setPageIndex(0); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_SEARCH, searchString); fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_SEARCH, searchString);
refreshData(entry); refreshData(entry);
@ -453,12 +450,12 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (pageIndex<1) { if (pageIndex<1) {
pageIndex = 0; pageIndex = 0;
} }
Long total = entry.getVascFrontendData().getTotalBackendRecords(); // note: total is only null when pageAction is done before first refresh, which should never happen anyway. Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); // note: total is only null when pageAction is done before first refresh, which should never happen anyway.
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascBackendState().getPageSize())) { if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
pageIndex = new Long(total/entry.getVascFrontendData().getVascBackendState().getPageSize()).intValue(); pageIndex = new Long(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()).intValue();
} }
entry.getVascFrontendData().getVascBackendState().setPageIndex(pageIndex); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(pageIndex);
fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_PAGE, pageIndex); fireVascEvent(entry,VascEntryEventListener.VascEventType.DATA_PAGE, pageIndex);
// lets load data; // lets load data;
@ -466,14 +463,14 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
} }
public void moveAction(VascEntry entry,Object record,boolean moveUp) { public void moveAction(VascEntry entry,Object record,boolean moveUp) {
if (entry.getVascFrontendData().getVascBackend().isRecordMoveable()) { if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
try { try {
VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId()); VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
Object primaryId = p.getVascEntryFieldValue().getValue(p, record); Object primaryId = p.getVascEntryFieldValue().getValue(p, record);
if (moveUp) { if (moveUp) {
entry.getVascFrontendData().getVascBackend().doRecordMoveUpById(entry.getVascFrontendData().getVascBackendState(),primaryId); entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveUpById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
} else { } else {
entry.getVascFrontendData().getVascBackend().doRecordMoveDownById(entry.getVascFrontendData().getVascBackendState(),primaryId); entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveDownById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
} }
} catch (Exception e) { } catch (Exception e) {
handleException(entry, e); handleException(entry, e);
@ -483,4 +480,14 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
refreshData(entry); refreshData(entry);
} }
} }
public List<RowVascAction> getMultiRowActions(VascEntry entry) {
List<RowVascAction> result = new ArrayList<RowVascAction>(5);
for (RowVascAction a:entry.getRowActions()) {
if (a.isMultiRowAction()) {
result.add(a);
}
}
return result;
}
} }

View file

@ -42,6 +42,7 @@ import com.idcanet.vasc.core.VascLinkEntry;
*/ */
public class DefaultVascLinkEntry implements VascLinkEntry { public class DefaultVascLinkEntry implements VascLinkEntry {
private static final long serialVersionUID = 1L;
private String id = null; private String id = null;
private String vascEntryId = null; private String vascEntryId = null;
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3); private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);

View file

@ -60,7 +60,7 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
*/ */
public List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException { public List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException {
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100); List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(entryId); VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(entryId);
if (keyFieldId==null) { if (keyFieldId==null) {
keyFieldId = ve.getPrimaryKeyFieldId(); keyFieldId = ve.getPrimaryKeyFieldId();
@ -78,7 +78,9 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
throw new VascException("Could not find: "+displayFieldId+" from: "+ve.getId()); throw new VascException("Could not find: "+displayFieldId+" from: "+ve.getId());
} }
VascBackend back = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(ve.getBackendId()); // 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);
try { try {
if (nullLabel!=null) { if (nullLabel!=null) {
if (nullKeyValue==null) { if (nullKeyValue==null) {
@ -102,7 +104,7 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
VascEntryField fieldClone = key.clone(); VascEntryField fieldClone = key.clone();
fieldClone.getVascValidators().clear(); fieldClone.getVascValidators().clear();
VascEntryFieldValue v = entry.getVascFrontendData().getVascBackend().provideVascEntryFieldValue(fieldClone); VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
key.setVascEntryFieldValue(v); key.setVascEntryFieldValue(v);
} }
if (dis.getVascEntryFieldValue()==null) { if (dis.getVascEntryFieldValue()==null) {
@ -110,7 +112,7 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
VascEntryField fieldClone = dis.clone(); VascEntryField fieldClone = dis.clone();
fieldClone.getVascValidators().clear(); fieldClone.getVascValidators().clear();
VascEntryFieldValue v = entry.getVascFrontendData().getVascBackend().provideVascEntryFieldValue(fieldClone); VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
dis.setVascEntryFieldValue(v); dis.setVascEntryFieldValue(v);
} }

View file

@ -1,54 +0,0 @@
/*
* 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;
import com.idcanet.vasc.core.VascUserRoleController;
import com.idcanet.vasc.core.VascUserRoleControllerResolver;
/**
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2008
*/
public class DefaultVascUserRoleControllerResolver implements VascUserRoleControllerResolver {
private VascUserRoleController vascUserRoleController = null;
/**
* @return the vascUserRoleController
*/
public VascUserRoleController getVascUserRoleController() {
return vascUserRoleController;
}
/**
* @param vascUserRoleController the vascUserRoleController to set
*/
public void setVascUserRoleController(VascUserRoleController vascUserRoleController) {
this.vascUserRoleController = vascUserRoleController;
}
}

View file

@ -0,0 +1,103 @@
/*
* 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 java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.AbstractVascBackendProxy;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascException;
/**
* Does simple caching for the data.
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2009
*/
public class VascBackendProxyCache extends AbstractVascBackendProxy {
private Long records = null;
private List<Object> data = null;
private String dataSearchString = null;
private Map<String,Object> dataState = null;
public VascBackendProxyCache(VascBackend backend,VascEntry entry) {
super(backend);
dataState = new HashMap<String,Object>(10);
}
private boolean isStateChanged(VascBackendState state) {
boolean changed = false;
for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key);
Object valueLast = dataState.get(key);
dataState.put(key, value);
if (value==null & valueLast==null) {
continue;
}
if (value==null & valueLast!=null) {
changed = true;
break;
}
if (value.equals(valueLast)==false) {
changed = true;
break;
}
}
if (state.getSearchString()!=null && state.getSearchString().equals(dataSearchString)==false) {
changed = true;
}
dataSearchString = state.getSearchString();
return changed;
}
/**
* @see com.idcanet.vasc.core.VascBackend#execute(VascBackendState state)
*/
@Override
public List<Object> execute(VascBackendState state) throws VascException {
boolean changed = isStateChanged(state);
if (data==null | changed) {
data = backend.execute(state);
}
return data;
}
@Override
public long fetchTotalExecuteSize(VascBackendState state) {
boolean changed = isStateChanged(state);
if (records==null | changed) {
records = backend.fetchTotalExecuteSize(state);
}
return records;
}
}

View file

@ -27,9 +27,7 @@
package com.idcanet.vasc.impl; package com.idcanet.vasc.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.AbstractVascBackendProxy; import com.idcanet.vasc.core.AbstractVascBackendProxy;
import com.idcanet.vasc.core.VascBackend; import com.idcanet.vasc.core.VascBackend;
@ -47,13 +45,9 @@ import com.idcanet.vasc.core.VascException;
public class VascBackendProxyPaged extends AbstractVascBackendProxy { public class VascBackendProxyPaged extends AbstractVascBackendProxy {
private long records = 0; private long records = 0;
private List<Object> data = null;
private String dataSearchString = null;
private Map<String,Object> dataState = null;
public VascBackendProxyPaged(VascBackend backend,VascEntry entry) { public VascBackendProxyPaged(VascBackend backend,VascEntry entry) {
super(backend); super(backend);
dataState = new HashMap<String,Object>(10);
} }
/** /**
@ -69,34 +63,7 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
*/ */
@Override @Override
public List<Object> execute(VascBackendState state) throws VascException { public List<Object> execute(VascBackendState state) throws VascException {
boolean changed = false; List<Object> allData = backend.execute(state);
for (String key:state.getDataParameterKeys()) {
Object value = state.getDataParameter(key);
Object valueLast = dataState.get(key);
dataState.put(key, value);
if (value==null & valueLast==null) {
continue;
}
if (value==null & valueLast!=null) {
changed = true;
break;
}
if (value.equals(valueLast)==false) {
changed = true;
break;
}
}
if (state.getSearchString()!=null && state.getSearchString().equals(dataSearchString)==false) {
changed = true;
}
dataSearchString = state.getSearchString();
if (data==null | changed) {
data = backend.execute(state);
}
List<Object> allData = data;
int pageSize = state.getPageSize(); int pageSize = state.getPageSize();
if (pageSize==0) { if (pageSize==0) {
records = allData.size(); records = allData.size();

View file

@ -100,7 +100,7 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
} }
Object res; Object res;
try { try {
res = method.invoke(o,null); res = method.invoke(o,new Object[]{});
} catch (Exception e) { } catch (Exception e) {
throw new VascException(e); throw new VascException(e);
} }

View file

@ -0,0 +1,163 @@
/*
* 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 java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idcanet.vasc.core.AbstractVascBackendProxy;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascException;
/**
* Does simple caching for the data.
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2009
*/
public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
protected Logger logger = null;
protected Level logLevel = Level.INFO;
public VascBackendProxyTimerLogger(VascBackend backend,VascEntry entry) {
super(backend);
logger = Logger.getLogger(VascBackendProxyTimerLogger.class.getName());
}
/**
* @see com.idcanet.vasc.core.VascBackend#execute(VascBackendState state)
*/
@Override
public List<Object> execute(VascBackendState state) throws VascException {
long t1 = System.currentTimeMillis();
try {
return backend.execute(state);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-execute backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
@Override
public long fetchTotalExecuteSize(VascBackendState state) {
long t1 = System.currentTimeMillis();
try {
return backend.fetchTotalExecuteSize(state);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-fetchTotalExecuteSize backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#doRecordMoveDownById(com.idcanet.vasc.core.VascBackendState, java.lang.Object)
*/
@Override
public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascException {
long t1 = System.currentTimeMillis();
try {
return backend.doRecordMoveDownById(state, primaryId);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-doRecordMoveDownById backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#doRecordMoveUpById(com.idcanet.vasc.core.VascBackendState, java.lang.Object)
*/
@Override
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
long t1 = System.currentTimeMillis();
try {
return backend.doRecordMoveUpById(state, primaryId);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-doRecordMoveUpById backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#delete(java.lang.Object)
*/
@Override
public void delete(Object object) throws VascException {
long t1 = System.currentTimeMillis();
try {
backend.delete(object);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-delete backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#merge(java.lang.Object)
*/
@Override
public Object merge(Object object) throws VascException {
long t1 = System.currentTimeMillis();
try {
return backend.merge(object);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-merge backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#persist(java.lang.Object)
*/
@Override
public void persist(Object object) throws VascException {
long t1 = System.currentTimeMillis();
try {
backend.persist(object);
} finally {
long t2 = System.currentTimeMillis();
logger.log(logLevel,"vasc-persist backend: "+getId()+" in "+(t2-t1)+" ms");
}
}
/**
* @return the logLevel
*/
public Level getLogLevel() {
return logLevel;
}
/**
* @param logLevel the logLevel to set
*/
public void setLogLevel(Level logLevel) {
this.logLevel = logLevel;
}
}

View file

@ -37,6 +37,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
*/ */
public class AddRowAction extends AbstractVascAction implements RowVascAction { public class AddRowAction extends AbstractVascAction implements RowVascAction {
private static final long serialVersionUID = 1L;
static public final String ACTION_ID = "addRowAction"; static public final String ACTION_ID = "addRowAction";
protected String getActionId() { protected String getActionId() {
@ -45,9 +46,9 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction {
public void doRowAction(VascEntry entry,Object rowObject) throws Exception { public void doRowAction(VascEntry entry,Object rowObject) throws Exception {
entry.getVascFrontendData().setEditCreate(true); entry.getVascFrontendData().getVascEntryState().setEditCreate(true);
Object object = entry.getVascFrontendData().getVascFrontendHelper().createObject(entry); Object object = entry.getVascFrontendData().getVascFrontendHelper().createObject(entry);
entry.getVascFrontendData().setEntryDataObject(object); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(object);
entry.getVascFrontendData().getVascFrontend().renderEdit(); entry.getVascFrontendData().getVascFrontend().renderEdit();
} }

View file

@ -62,13 +62,13 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
} }
p.write("\n"); p.write("\n");
int oldIndex = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
Long total = entry.getVascFrontendData().getTotalBackendRecords(); Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
int pages = total.intValue()/entry.getVascFrontendData().getVascBackendState().getPageSize(); int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
for (int page=0;page<pages;page++) { for (int page=0;page<pages;page++) {
entry.getVascFrontendData().getVascBackendState().setPageIndex(page); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
for (Object o:entry.getVascFrontendData().getEntryDataList()) { for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
for (VascEntryField c:entry.getVascEntryFields()) { for (VascEntryField c:entry.getVascEntryFields()) {
p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t"); p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t");
} }
@ -80,7 +80,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
p.flush(); p.flush();
// restore old page size // restore old page size
entry.getVascFrontendData().getVascBackendState().setPageIndex(oldIndex); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(oldIndex);
} }

View file

@ -37,6 +37,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
*/ */
public class DeleteRowAction extends AbstractVascAction implements RowVascAction { public class DeleteRowAction extends AbstractVascAction implements RowVascAction {
private static final long serialVersionUID = 1L;
static public final String ACTION_ID = "deleteRowAction"; static public final String ACTION_ID = "deleteRowAction";
protected String getActionId() { protected String getActionId() {
@ -47,7 +48,7 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction
if (rowObject==null) { if (rowObject==null) {
return; // nothing selected return; // nothing selected
} }
entry.getVascFrontendData().setEntryDataObject(rowObject); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendData().getVascFrontend().renderDelete(); entry.getVascFrontendData().getVascFrontend().renderDelete();
} }

View file

@ -38,6 +38,7 @@ import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
*/ */
public class EditRowAction extends AbstractVascAction implements RowVascAction { public class EditRowAction extends AbstractVascAction implements RowVascAction {
private static final long serialVersionUID = 1L;
static public final String ACTION_ID = "editRowAction"; static public final String ACTION_ID = "editRowAction";
protected String getActionId() { protected String getActionId() {
@ -49,9 +50,9 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
if (rowObject==null) { if (rowObject==null) {
return; // nothing selected return; // nothing selected
} }
entry.getVascFrontendData().setEditCreate(false); entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascEventType.DATA_SELECT, rowObject); entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascEventType.DATA_SELECT, rowObject);
entry.getVascFrontendData().setEntryDataObject(rowObject); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendData().getVascFrontend().renderEdit(); entry.getVascFrontendData().getVascFrontend().renderEdit();
} }

View file

@ -37,6 +37,7 @@ import com.idcanet.vasc.core.actions.GlobalVascAction;
*/ */
public class RefreshDataGlobalAction extends AbstractVascAction implements GlobalVascAction { public class RefreshDataGlobalAction extends AbstractVascAction implements GlobalVascAction {
private static final long serialVersionUID = 1L;
static public final String ACTION_ID = "refreshDataAction"; static public final String ACTION_ID = "refreshDataAction";
protected String getActionId() { protected String getActionId() {

View file

@ -59,13 +59,13 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
p.write("<?xml version=\"1.0\"?>\n"); p.write("<?xml version=\"1.0\"?>\n");
p.write("<data>\n"); p.write("<data>\n");
int oldIndex = entry.getVascFrontendData().getVascBackendState().getPageIndex(); int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
Long total = entry.getVascFrontendData().getTotalBackendRecords(); Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
int pages = total.intValue()/entry.getVascFrontendData().getVascBackendState().getPageSize(); int pages = total.intValue()/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
for (int page=0;page<pages;page++) { for (int page=0;page<pages;page++) {
entry.getVascFrontendData().getVascBackendState().setPageIndex(page); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
for (Object o:entry.getVascFrontendData().getEntryDataList()) { for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
p.write("\t<row>\n"); p.write("\t<row>\n");
for (VascEntryField c:entry.getVascEntryFields()) { for (VascEntryField c:entry.getVascEntryFields()) {
p.write("\t\t<column name=\""+c.getId()+"\"><![CDATA["); p.write("\t\t<column name=\""+c.getId()+"\"><![CDATA[");
@ -80,7 +80,7 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
p.flush(); p.flush();
// restore old page size // restore old page size
entry.getVascFrontendData().getVascBackendState().setPageIndex(oldIndex); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(oldIndex);
} }
public String getMineType() { public String getMineType() {

View file

@ -38,6 +38,7 @@ import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue;
*/ */
public class BeanPropertyVascEntryFieldValue implements VascEntryFieldValue { public class BeanPropertyVascEntryFieldValue implements VascEntryFieldValue {
private static final long serialVersionUID = 1L;
private String property = null; private String property = null;
private DefaultElementObjectPropertyValue helper = null; private DefaultElementObjectPropertyValue helper = null;

View file

@ -36,6 +36,7 @@ import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
*/ */
public class BeanVascEntryRecordCreator implements VascEntryRecordCreator { public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
private static final long serialVersionUID = 1L;
private Class<?> objectClass = null; private Class<?> objectClass = null;
public BeanVascEntryRecordCreator() { public BeanVascEntryRecordCreator() {

View file

@ -110,12 +110,10 @@ public class HibernateValidatorService implements VascEntryFieldValidatorService
//cannot use an exclude list because the parameter name could match a method name //cannot use an exclude list because the parameter name could match a method name
annotationParameters.put( method.getName(), method.invoke( annotation ) ); annotationParameters.put( method.getName(), method.invoke( annotation ) );
} }
} } catch (IllegalAccessException e) {
catch (IllegalAccessException e) {
//really should not happen, but we degrade nicely //really should not happen, but we degrade nicely
//log.warning( "Unable to access {}", StringHelper.qualify( clazz.toString(), method.getName() ) ); //log.warning( "Unable to access {}", StringHelper.qualify( clazz.toString(), method.getName() ) );
} } catch (InvocationTargetException e) {
catch (InvocationTargetException e) {
//really should not happen, but we degrade nicely //really should not happen, but we degrade nicely
//log.warn( "Unable to access {}", StringHelper.qualify( clazz.toString(), method.getName() ) ); //log.warn( "Unable to access {}", StringHelper.qualify( clazz.toString(), method.getName() ) );
} }
@ -127,15 +125,15 @@ public class HibernateValidatorService implements VascEntryFieldValidatorService
//do not resolve the property eagerly to allow validator.apply to work wo interpolator //do not resolve the property eagerly to allow validator.apply to work wo interpolator
} }
public String interpolate(String message, Validator validator, MessageInterpolator defaultInterpolator) { @SuppressWarnings("unchecked")
public String interpolate(String message, Validator validator, MessageInterpolator defaultInterpolator) {
if ( annotationMessage!=null && annotationMessage.equals( message ) ) { if ( annotationMessage!=null && annotationMessage.equals( message ) ) {
//short cut //short cut
if (interpolateMessage == null) { if (interpolateMessage == null) {
interpolateMessage = replace( annotationMessage ); interpolateMessage = replace( annotationMessage );
} }
return interpolateMessage; return interpolateMessage;
} } else {
else {
//TODO keep them in a weak hash map, but this might not even be useful //TODO keep them in a weak hash map, but this might not even be useful
return replace( message ); return replace( message );
} }
@ -157,25 +155,20 @@ public class HibernateValidatorService implements VascEntryFieldValidatorService
} }
if ( !el && "{".equals( token ) ) { if ( !el && "{".equals( token ) ) {
escaped = true; escaped = true;
} } else if ( escaped && "}".equals( token ) ) {
else if ( escaped && "}".equals( token ) ) {
escaped = false; escaped = false;
} } else if ( !escaped ) {
else if ( !escaped ) {
if ( "{".equals( token ) ) el = false; if ( "{".equals( token ) ) el = false;
buf.append( token ); buf.append( token );
} } else {
else {
Object variable = annotationParameters.get( token ); Object variable = annotationParameters.get( token );
if ( variable != null ) { if ( variable != null ) {
buf.append( variable ); buf.append( variable );
} } else {
else { String string = vascEntry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(token);
String string = null; if ( string != null ) {
buf.append(replace(string));
string = vascEntry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(token); }
if ( string != null ) buf.append( replace( string ) );
} }
} }
} }

View file

@ -39,6 +39,7 @@ import com.idcanet.vasc.core.VascEntryFieldType;
*/ */
public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType { public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType {
private static final long serialVersionUID = 1L;
@Override @Override
public VascEntryFieldType clone() throws CloneNotSupportedException { public VascEntryFieldType clone() throws CloneNotSupportedException {
DefaultVascEntryFieldType clone = new DefaultVascEntryFieldType(); DefaultVascEntryFieldType clone = new DefaultVascEntryFieldType();

View file

@ -1,56 +0,0 @@
/*
* 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 com.idcanet.vasc.core.VascEntryFieldTypeController;
import com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver;
/**
*
* @author Willem Cazander
* @version 1.0 Sep 14, 2008
*/
public class DefaultVascEntryFieldTypeControllerResolver implements VascEntryFieldTypeControllerResolver {
VascEntryFieldTypeController vascEntryFieldTypeController = null;
/**
* @see com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver#getVascEntryFieldTypeController()
*/
public VascEntryFieldTypeController getVascEntryFieldTypeController() {
return vascEntryFieldTypeController;
}
/**
* @param vascEntryFieldTypeController the vascEntryFieldTypeController to set
*/
public void setVascEntryFieldTypeController(VascEntryFieldTypeController vascEntryFieldTypeController) {
this.vascEntryFieldTypeController = vascEntryFieldTypeController;
}
}

View file

@ -41,11 +41,12 @@ import com.idcanet.vasc.core.ui.VascValueModel;
*/ */
public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType { public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
private static final long serialVersionUID = 1L;
private Object getIndexValue(VascEntryField entryField,int index) throws VascException { private Object getIndexValue(VascEntryField entryField,int index) throws VascException {
Object record = entryField.getVascEntry().getVascFrontendData().getEntryDataObject(); Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record); Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
if (value instanceof List) { if (value instanceof List<?>) {
return ((List<?>)value).get(index); return ((List<?>)value).get(index);
} }
if (value instanceof String[]) { if (value instanceof String[]) {
@ -60,12 +61,13 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
throw new VascException("Unknown object type"); throw new VascException("Unknown object type");
} }
@SuppressWarnings("unchecked")
private void setIndexValue(VascEntryField entryField,int index,Object newValue) throws VascException { private void setIndexValue(VascEntryField entryField,int index,Object newValue) throws VascException {
Object record = entryField.getVascEntry().getVascFrontendData().getEntryDataObject(); Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record); Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
if (value instanceof List) { if (value instanceof List<?>) {
((List<Object>)value).set(index, newValue); ((List<Object>)value).set(index, newValue); // TODO: fix @SuppressWarnings here
return; return;
} }
if (value instanceof String[]) { if (value instanceof String[]) {
@ -94,10 +96,10 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
public int getUIComponentCount(VascEntryField entryField) throws VascException { public int getUIComponentCount(VascEntryField entryField) throws VascException {
Object record = entryField.getVascEntry().getVascFrontendData().getEntryDataObject(); Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record); Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
if (value instanceof List) { if (value instanceof List<?>) {
return ((List<?>)value).size()+1; return ((List<?>)value).size()+1;
} }
if (value instanceof String[]) { if (value instanceof String[]) {

View file

@ -282,14 +282,14 @@ public class AnnotationParserElement extends AbstractElement {
VascController vascController = VascParser.getVascController(this.getElementContext()); VascController vascController = VascParser.getVascController(this.getElementContext());
VascChoices vc = parser.getVascChoices (modelClass, field.getId()); VascChoices vc = parser.getVascChoices (modelClass, field.getId());
if (vc!=null) { if (vc!=null) {
VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"); VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField");
type.setDataObject(new VascChoicesSelectItemModel(vc)); type.setDataObject(new VascChoicesSelectItemModel(vc));
field.setVascEntryFieldType(type); field.setVascEntryFieldType(type);
} }
if (field.getVascEntryFieldType()==null) { if (field.getVascEntryFieldType()==null) {
String fieldType = parser.getVascFieldType (modelClass, field.getId()); String fieldType = parser.getVascFieldType (modelClass, field.getId());
if (fieldType!=null) { if (fieldType!=null) {
VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldType); VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldType);
field.setVascEntryFieldType(type); field.setVascEntryFieldType(type);
// copy properties // copy properties
@ -342,8 +342,8 @@ public class AnnotationParserElement extends AbstractElement {
if (methodCall!=null) { if (methodCall!=null) {
Class<?> retType = methodCall.getReturnType(); Class<?> retType = methodCall.getReturnType();
for (String typeId: vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) { for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId); VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
//String auto = ""; //String auto = "";
//if (type.getAutoDetectClass()!=null) { //if (type.getAutoDetectClass()!=null) {

View file

@ -63,14 +63,14 @@ public class SetParameterElement extends AbstractElement {
} }
if ("id".equals(value)) { if ("id".equals(value)) {
if ("int".equals(type)) { if ("int".equals(type)) {
Long userId = cont.getVascUserRoleControllerResolver().getVascUserRoleController().getUserId(); Long userId = cont.getVascUserRoleController().getUserId();
entry.setEntryParameter(name, userId.intValue()); entry.setEntryParameter(name, userId.intValue());
} else { } else {
Long userId = cont.getVascUserRoleControllerResolver().getVascUserRoleController().getUserId(); Long userId = cont.getVascUserRoleController().getUserId();
entry.setEntryParameter(name, userId); entry.setEntryParameter(name, userId);
} }
} else { } else {
String userName = cont.getVascUserRoleControllerResolver().getVascUserRoleController().getUserName(); String userName = cont.getVascUserRoleController().getUserName();
entry.setEntryParameter(name, userName); entry.setEntryParameter(name, userName);
} }
return; return;

View file

@ -52,7 +52,7 @@ public class VascBackendElementConfigurator extends AbstractElementConfigurator
VascBackend backend = (VascBackend)element.getElementObject(); VascBackend backend = (VascBackend)element.getElementObject();
VascController vascController = VascParser.getVascController(element.getElementContext()); VascController vascController = VascParser.getVascController(element.getElementContext());
VascBackendController backendController = vascController.getVascBackendControllerResolver().getVascBackendController(); VascBackendController backendController = vascController.getVascBackendController();
if (backendController instanceof VascBackendControllerLocal) { if (backendController instanceof VascBackendControllerLocal) {
try { try {

View file

@ -52,7 +52,7 @@ public class VascEntryElementConfigurator extends AbstractElementConfigurator {
VascEntry entry = (VascEntry)element.getElementObject(); VascEntry entry = (VascEntry)element.getElementObject();
VascController vascController = VascParser.getVascController(element.getElementContext()); VascController vascController = VascParser.getVascController(element.getElementContext());
VascEntryController entryController = vascController.getVascEntryControllerResolver().getVascEntryController(); VascEntryController entryController = vascController.getVascEntryController();
if (entryController instanceof VascEntryControllerLocal) { if (entryController instanceof VascEntryControllerLocal) {
try { try {

View file

@ -54,7 +54,7 @@ public class VascEntryFieldTypeAttributeConverter extends AbstractElementAttribu
String fieldID = parameterValue.toString(); String fieldID = parameterValue.toString();
VascController controller = VascParser.getVascController(element.getElementContext()); VascController controller = VascParser.getVascController(element.getElementContext());
Object result = controller.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID); Object result = controller.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID);
return result; return result;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2007 IDCA. All rights reserved. * Copyright 2004-2008 IDCA. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met: * following conditions are met:
@ -24,15 +24,28 @@
* should not be interpreted as representing official policies, either expressed or implied, of IDCA. * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/ */
package com.idcanet.vasc.core; package com.idcanet.vasc.validators;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**
* An annotation to validate an url field of a bean.
* Also works on String types
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Sep 4, 2008 * @version 1.0 Dec 15, 2009
*/ */
public interface VascBackendControllerResolver { @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD,ElementType.TYPE})
public @interface VascObjectUrl {
public VascBackendController getVascBackendController(); /**
* The regex to match on the url to forbid some urls.
* @return
*/
String forbidRegex();
} }

View file

@ -0,0 +1,117 @@
/*
* 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.validators;
import java.lang.annotation.Annotation;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Validates the url annotations
*
* @author Willem Cazander
* @version 1.0 Sep 5, 2008
*/
public class VascObjectUrlValidator implements VascValidator {
private Pattern pattern = null;
/**
* Sets the regulare expression on which this object filters an String.<br>
* <br>
* When set to <code>Null</code> matching is disabled.<br>
*
* @param regex The regulare expression to match to.
*/
public void setForbidRegEx(String regex) {
pattern = Pattern.compile(regex);
}
/**
* Returns the current regulare expression.
* @return The regulare expression.
*/
public String getForbidRegEx() {
if(pattern==null) {
return null;
}
return pattern.pattern();
}
/**
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
*/
public boolean isObjectValid(Object object) throws VascValidatorException {
if (object==null) {
return true;
}
URL url = null;
if (object instanceof URL) {
url = (URL)object;
}
if (object instanceof String) {
try {
url = new URL((String)object);
} catch (MalformedURLException e) {
throw new VascValidatorException("Url not valid: "+(String)object,e);
}
}
if (url==null) {
throw new VascValidatorException("Object could not be translated into url: "+object);
}
if (pattern==null) {
return true;
}
String urlString = url.toExternalForm();
// test if regex matches
Matcher m = pattern.matcher(urlString);
return !m.find(); // if found then url it NOT valid
}
/**
* @see com.idcanet.vasc.validators.VascValidator#getAnnotationType()
*/
public Class<?> getAnnotationType() {
return VascObjectNull.class;
}
/**
* @see com.idcanet.vasc.validators.VascValidator#initAnnotation(java.lang.annotation.Annotation)
*/
public void initAnnotation(Annotation annotation) {
VascObjectUrl a = VascObjectUrl.class.cast(annotation);
setForbidRegEx(a.forbidRegex());
}
public VascValidator clone() throws CloneNotSupportedException {
VascObjectUrlValidator result = new VascObjectUrlValidator();
result.pattern=pattern;
return result;
}
}

View file

@ -50,6 +50,7 @@ public class VascValidatorClassParser {
validators.add(new VascLongSizeValidator()); validators.add(new VascLongSizeValidator());
validators.add(new VascObjectNotNullValidator()); validators.add(new VascObjectNotNullValidator());
validators.add(new VascObjectNullValidator()); validators.add(new VascObjectNullValidator());
validators.add(new VascObjectUrlValidator());
validators.add(new VascStringEmailValidator()); validators.add(new VascStringEmailValidator());
validators.add(new VascStringLengthValidator()); validators.add(new VascStringLengthValidator());
validators.add(new VascStringRegexValidator()); validators.add(new VascStringRegexValidator());

View file

@ -87,15 +87,11 @@
</deferred-value> </deferred-value>
</attribute> </attribute>
<attribute> <attribute>
<name>bundleName</name> <name>disableLinkColumns</name>
<required>false</required> <required>false</required>
<deferred-value/> <deferred-value>
</attribute> <type>java.lang.String</type>
<attribute> </deferred-value>
<name>locale</name>
<required>false</required>
<deferred-value/>
</attribute> </attribute>
</tag> </tag>
</taglib> </taglib>

View file

@ -84,12 +84,12 @@ public class SwingTest extends TestCase {
JMenuBar menubar = new JMenuBar(); JMenuBar menubar = new JMenuBar();
JMenu vascMenu = new JMenu("Vasc Entries"); JMenu vascMenu = new JMenu("Vasc Entries");
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryIds()) { for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
JMenuItem item = new JMenuItem(id); JMenuItem item = new JMenuItem(id);
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(id); VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id);
TestTable.fill(ee,entry.getVascFrontendData().getVascController()); TestTable.fill(ee,entry.getVascFrontendData().getVascController());
viewEntry(ee); viewEntry(ee);
} catch (Exception e1) { } catch (Exception e1) {

View file

@ -31,20 +31,15 @@ import java.io.FileOutputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import com.idcanet.vasc.core.VascBackend; import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendControllerLocal;
import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer; import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
import com.idcanet.vasc.impl.DefaultVascBackendController; import com.idcanet.vasc.impl.DefaultVascFactory;
import com.idcanet.vasc.impl.DefaultVascBackendControllerResolver;
import com.idcanet.vasc.impl.DefaultVascEntryController;
import com.idcanet.vasc.impl.DefaultVascEntryControllerResolver;
import com.idcanet.vasc.impl.DefaultVascController;
import com.idcanet.vasc.impl.DefaultVascFrontendData; import com.idcanet.vasc.impl.DefaultVascFrontendData;
import com.idcanet.vasc.impl.DefaultVascFrontendHelper; import com.idcanet.vasc.impl.DefaultVascFrontendHelper;
import com.idcanet.vasc.impl.DefaultVascUserRoleController;
import com.idcanet.vasc.impl.DefaultVascUserRoleControllerResolver;
import com.idcanet.vasc.impl.VascBackendProxyPaged; import com.idcanet.vasc.impl.VascBackendProxyPaged;
import com.idcanet.vasc.impl.VascBackendProxySearch; import com.idcanet.vasc.impl.VascBackendProxySearch;
import com.idcanet.vasc.impl.VascBackendProxySort; import com.idcanet.vasc.impl.VascBackendProxySort;
@ -54,8 +49,6 @@ import com.idcanet.vasc.impl.actions.DeleteRowAction;
import com.idcanet.vasc.impl.actions.EditRowAction; import com.idcanet.vasc.impl.actions.EditRowAction;
import com.idcanet.vasc.impl.actions.RefreshDataGlobalAction; import com.idcanet.vasc.impl.actions.RefreshDataGlobalAction;
import com.idcanet.vasc.impl.actions.XMLExportGlobalAction; import com.idcanet.vasc.impl.actions.XMLExportGlobalAction;
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeController;
import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeControllerResolver;
import com.idcanet.vasc.impl.x4o.VascParser; import com.idcanet.vasc.impl.x4o.VascParser;
@ -67,38 +60,14 @@ import com.idcanet.vasc.impl.x4o.VascParser;
public class TestTable { public class TestTable {
static VascController getDefaultVascController() throws Exception { static VascController getDefaultVascController() throws Exception {
VascController c = DefaultVascFactory.getDefaultVascController(2288L,"idca.nl","user","admin");
// for test // for test
TestModelVascDataSource backend = new TestModelVascDataSource(); TestModelVascDataSource backend = new TestModelVascDataSource();
backend.setId("testBackend1"); backend.setId("testBackend1");
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backend);
// config full controller for local jvm use
DefaultVascController c = new DefaultVascController();
DefaultVascBackendControllerResolver vascBackendControllerResolver = new DefaultVascBackendControllerResolver();
DefaultVascBackendController vascBackendController = new DefaultVascBackendController();
vascBackendController.addVascBackend(backend);
vascBackendControllerResolver.setVascBackendController(vascBackendController);
c.setVascBackendControllerResolver(vascBackendControllerResolver);
DefaultVascEntryControllerResolver vascEntryControllerResolver = new DefaultVascEntryControllerResolver();
DefaultVascEntryController vascEntryController = new DefaultVascEntryController();
vascEntryControllerResolver.setVascEntryController(vascEntryController);
c.setVascEntryControllerResolver(vascEntryControllerResolver);
DefaultVascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = new DefaultVascEntryFieldTypeControllerResolver();
DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController();
vascEntryFieldTypeControllerResolver.setVascEntryFieldTypeController(vascEntryFieldTypeController);
c.setVascEntryFieldTypeControllerResolver(vascEntryFieldTypeControllerResolver);
DefaultVascUserRoleControllerResolver vascUserRoleControllerResolver = new DefaultVascUserRoleControllerResolver();
DefaultVascUserRoleController vascUserRoleController = new DefaultVascUserRoleController(2288L,"idca.nl","user","admin");
vascUserRoleControllerResolver.setVascUserRoleController(vascUserRoleController);
c.setVascUserRoleControllerResolver(vascUserRoleControllerResolver);
return c; return c;
} }
static public void fill(VascEntry entry,VascController c) { static public void fill(VascEntry entry,VascController c) {
@ -122,7 +91,7 @@ public class TestTable {
entry.setVascFrontendData(vascFrontendData); entry.setVascFrontendData(vascFrontendData);
} }
VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()); VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendController().getVascBackendById(entry.getBackendId());
if (backend.isSearchable()==false) { if (backend.isSearchable()==false) {
backend = new VascBackendProxySearch(backend,entry); backend = new VascBackendProxySearch(backend,entry);
} }
@ -132,7 +101,7 @@ public class TestTable {
if (backend.isSortable()==false) { if (backend.isSortable()==false) {
backend = new VascBackendProxySort(backend,entry); backend = new VascBackendProxySort(backend,entry);
} }
vascFrontendData.setVascBackend(backend); vascFrontendData.getVascEntryState().setVascBackend(backend);
entry.addRowAction(new AddRowAction()); entry.addRowAction(new AddRowAction());
@ -162,7 +131,7 @@ public class TestTable {
parser.setDebugOutputStream(new FileOutputStream(f)); parser.setDebugOutputStream(new FileOutputStream(f));
parser.parseResource("vasc/tables.xml"); parser.parseResource("vasc/tables.xml");
VascEntry entry = parser.getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById("test1"); VascEntry entry = parser.getVascController().getVascEntryController().getVascEntryById("test1");
fill(entry,c); fill(entry,c);
return entry; return entry;