2
0
Fork 0

[svn r396] a bit cleaning on backends and fixed a lot of jsf gui bugs

This commit is contained in:
willemc 2010-04-30 21:21:47 +02:00
parent 7ee4809086
commit 58347ef9fb
37 changed files with 1142 additions and 330 deletions

View file

@ -48,10 +48,12 @@ public class VascBundleKeyGenerator {
private boolean generateDescription = true;
private boolean generateImage = true;
private boolean generateHelpId = true;
private List<String> dubId = null;
public VascBundleKeyGenerator() {
models = new ArrayList<Class<?>>(30);
keys = new HashMap<String,String>(300);
dubId = new ArrayList<String>(30);
}
public void addModelClass(Class<?> model) {
@ -66,6 +68,7 @@ public class VascBundleKeyGenerator {
public void generateMissingKeys(StringBuffer buffer,ResourceBundle bundle) {
if (keys.isEmpty()==false) {
keys.clear();
dubId.clear();
}
for (Class<?> modelClass:models) {
generatorI18nKeys(modelClass);
@ -86,6 +89,7 @@ public class VascBundleKeyGenerator {
public void generateRemoveKeys(StringBuffer buffer,ResourceBundle bundle,String excludeRegex) {
if (keys.isEmpty()==false) {
keys.clear();
dubId.clear();
}
for (Class<?> modelClass:models) {
generatorI18nKeys(modelClass);
@ -107,6 +111,7 @@ public class VascBundleKeyGenerator {
public void generateKeys(StringBuffer buffer) {
if (keys.isEmpty()==false) {
keys.clear();
dubId.clear();
}
for (Class<?> modelClass:models) {
generatorI18nKeys(modelClass);
@ -138,7 +143,12 @@ public class VascBundleKeyGenerator {
if (isGenerateHelpId()) {
appendKey(vap.getVascI18nHelpId(bean),prop1);
}
String idKey = vap.getVascPrimaryKey(bean);
String nameKey = vap.getVascDisplayName(bean);
if (idKey!=null && idKey.equals(nameKey)) {
dubId.add("idKey and nameKey is the same: "+bean.getName());
}
for (Method method:bean.getMethods()) {
if (method.getName().startsWith("get")==false) { //a bit durty
@ -228,4 +238,8 @@ public class VascBundleKeyGenerator {
public void setGenerateHelpId(boolean generateHelpId) {
this.generateHelpId = generateHelpId;
}
public List<String> getDubIdNameKeys() {
return dubId;
}
}

View file

@ -0,0 +1,109 @@
/*
* Copyright 2004-2010 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.backends;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue;
/**
*
* @author Willem Cazander
* @version 1.0 Dec 05, 2009
*/
public class BeanVascEntryFieldValue implements VascEntryFieldValue {
private static final long serialVersionUID = 1L;
private DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue();
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public Object getValue(VascEntryField field, Object record) throws VascException {
if (field==null) {
throw new NullPointerException("Can't get value of null field.");
}
if (field.getBackendName()==null) {
throw new NullPointerException("Can't get value of null backendName field.");
}
if (record==null) {
throw new NullPointerException("Can't get value of null object.");
}
try {
Object o = bean.getProperty(record,field.getBackendName());
return o;
} catch (Exception e) {
throw new VascException(e);
}
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getDisplayValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
Object value = getValue(field,record);
if (value==null) {
return "";
}
if (field.getDisplayName()==null) {
if (value instanceof String) {
return (String)value;
}
return ""+value;
}
try {
Object result = bean.getProperty(value, field.getDisplayName());
if (result instanceof String) {
return (String)result;
}
return ""+result;
} catch (Exception e) {
throw new VascException(e);
}
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
*/
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
if (field==null) {
throw new NullPointerException("Can't set value of null field.");
}
if (field.getBackendName()==null) {
throw new NullPointerException("Can't set value of null backendName field.");
}
if (record==null) {
throw new NullPointerException("Can't set value of null object.");
}
try {
bean.setProperty(record, field.getBackendName(), value);
} catch (Exception e) {
throw new VascException(e);
}
}
}

View file

@ -1,7 +1,7 @@
/**
*
*/
package com.idcanet.vasc.backends.jpa;
package com.idcanet.vasc.backends;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
@ -16,6 +16,9 @@ public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
private Class<?> resultClass = null;
public BeanVascEntryRecordCreator(Class<?> resultClass) {
if (resultClass==null) {
throw new NullPointerException("Can't provide creator service with null class object.");
}
this.resultClass=resultClass;
}

View file

@ -0,0 +1,49 @@
/**
*
*/
package com.idcanet.vasc.backends;
import java.util.Map;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
/**
* @author willemc
*
*/
public class MapVascEntryFieldValue implements VascEntryFieldValue {
private static final long serialVersionUID = 1L;
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public Object getValue(VascEntryField field, Object record) throws VascException {
Map<String,Object> map = (Map<String,Object>)record;
Object r = map.get(field.getBackendName());
if (r==null) {
return ""; // create new value, ldap does not return data for field that an user does not have, but other do,...
}
return r;
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getDisplayValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
return ""+getValue(field,record); // not supported (this)ldap is already fully string based.
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
Map<String,Object> map = (Map<String,Object>)record;
map.put(field.getBackendName(), value);
}
}

View file

@ -0,0 +1,27 @@
/**
*
*/
package com.idcanet.vasc.backends;
import java.util.HashMap;
import java.util.Map;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
/**
* @author willemc
*
*/
public class MapVascEntryRecordCreator implements VascEntryRecordCreator {
private static final long serialVersionUID = 1L;
public Class<?> getObjectClass() {
return Map.class;
}
public Object newRecord(VascEntry entry) throws Exception {
return new HashMap<String,Object>(10);
}
}

View file

@ -34,6 +34,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.backends.MapVascEntryFieldValue;
import com.idcanet.vasc.backends.MapVascEntryRecordCreator;
import com.idcanet.vasc.core.AbstractVascBackend;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
@ -128,50 +130,14 @@ public class JdbcVascBackend extends AbstractVascBackend {
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
*/
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
VascEntryFieldValue result = new VascEntryFieldValue() {
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public Object getValue(VascEntryField field, Object record) throws VascException {
Map<String,Object> map = (Map<String,Object>)record;
Object o = map.get(field.getBackendName());
return o;
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getDisplayValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
return ""+getValue(field,record); // not supported
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
Map<String,Object> map = (Map<String,Object>)record;
map.put(field.getBackendName(), value);
}
};
return result;
return new MapVascEntryFieldValue();
}
/**
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
*/
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
return new VascEntryRecordCreator() {
public Class<?> getObjectClass() {
return Map.class;
}
public Object newRecord(VascEntry entry) throws Exception {
return new HashMap<String,Object>(10);
}
};
return new MapVascEntryRecordCreator();
}
/**

View file

@ -42,7 +42,7 @@ import javax.sql.DataSource;
public class JdniDataSourceJdbcConnectionProvider implements JdbcConnectionProvider {
/** The context in which database data sources are found. */
private String dataSourceContext = "java:comp/env/jdbc/";
private String dataSourceContext = "java:/";
private String dataSourceName = null;

View file

@ -1,67 +0,0 @@
/**
*
*/
package com.idcanet.vasc.backends.jpa;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue;
/**
* @author willemc
*
*/
public class BeanVascEntryFieldValue implements VascEntryFieldValue {
private static final long serialVersionUID = 1L;
private DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue();
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public Object getValue(VascEntryField field, Object record) throws VascException {
try {
Object o = bean.getProperty(record,field.getBackendName());
return o;
} catch (Exception e) {
throw new VascException(e);
}
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getDisplayValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
Object value = getValue(field,record);
if (value==null) {
return "";
}
if (field.getDisplayName()==null) {
if (value instanceof String) {
return (String)value;
}
return ""+value;
}
try {
Object result = bean.getProperty(value, field.getDisplayName());
if (result instanceof String) {
return (String)result;
}
return ""+result;
} catch (Exception e) {
throw new VascException(e);
}
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
*/
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
try {
bean.setProperty(record, field.getBackendName(), value);
} catch (Exception e) {
throw new VascException(e);
}
}
}

View file

@ -32,6 +32,8 @@ import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
import com.idcanet.vasc.backends.BeanVascEntryFieldValue;
import com.idcanet.vasc.backends.BeanVascEntryRecordCreator;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
@ -102,7 +104,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
}
i++;
}
if (isPageable() & state.getPageSize()>0) {
if (isPageable()) {
q.setFirstResult(state.getPageIndex());
q.setMaxResults(state.getPageSize());
}

View file

@ -31,6 +31,8 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import com.idcanet.vasc.backends.BeanVascEntryFieldValue;
import com.idcanet.vasc.backends.BeanVascEntryRecordCreator;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
@ -101,7 +103,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
//System.out.println("Set para index: "+i+" value: "+valueObject+" valueClass: "+valueObject.getClass()+" valueType: "+value.getValueType());
i++;
}
if (isPageable() & state.getPageSize()>0) {
if (isPageable()) {
q.setFirstResult(state.getPageIndex());
q.setMaxResults(state.getPageSize());
}
@ -421,4 +423,15 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
public void setQueryMoveDownUp(com.idcanet.xtes.xpql.query.Query queryMoveDownUp) {
this.queryMoveDownUp = queryMoveDownUp;
}
/**
* @see com.idcanet.vasc.core.VascBackend#isSearchable()
*/
public boolean isSearchable() {
if (query.getQueryParameterValue("text_search")==null) {
return false;
}
//return true;
return false;
}
}

View file

@ -32,6 +32,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.backends.MapVascEntryFieldValue;
import com.idcanet.vasc.backends.MapVascEntryRecordCreator;
import com.idcanet.vasc.core.AbstractVascBackend;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
@ -43,6 +45,7 @@ import com.novell.ldap.LDAPAttribute;
import com.novell.ldap.LDAPAttributeSet;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry;
import com.novell.ldap.LDAPModification;
import com.novell.ldap.LDAPSearchConstraints;
import com.novell.ldap.LDAPSearchResults;
@ -90,6 +93,8 @@ public class LdapVascBackend extends AbstractVascBackend {
LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setBatchSize( 0 );
cons.setTimeLimit( 10000 ) ;
cons.setReferralFollowing(true);
connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN;
@ -141,8 +146,72 @@ public class LdapVascBackend extends AbstractVascBackend {
LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection();
try {
Map<String,Object> map = (Map)object;
String keyValue = (String)map.get(keyAttribute);
LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setBatchSize( 0 );
cons.setTimeLimit( 10000 ) ;
cons.setReferralFollowing(true);
connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN;
String filter = "(&("+keyAttribute+"="+keyValue+"))";
System.out.println("ldap filter: "+filter);
LDAPSearchResults searchResults = connection.search(
searchBase, // object to read
searchScope, // scope - read single object
filter, // search filter
null, // return all attributes
false); // return attrs and values
if (searchResults.hasMore()==false) {
// no result to mod
return object;
}
LDAPEntry entry = searchResults.next();
List<LDAPModification> mods = new ArrayList<LDAPModification>(20);
for (String key:map.keySet()) {
Object value = map.get(key);
LDAPAttribute attr = entry.getAttribute(key);
String[] s = attr.getStringValueArray();
if (s.length==1) {
String v = (String)value;
if (attr.getStringValue().equals(v)==false) {
LDAPModification mod = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute(key,v));
mods.add(mod);
}
map.put(attr.getName(), attr.getStringValue());
} else {
List<String> multiValue = new ArrayList<String>(s.length);
for (String ss:s) {
multiValue.add(ss);
}
List<String> v = null;
if (value instanceof String) {
v = new ArrayList<String>(1);
v.add((String)value);
} else {
v = (List<String>)value;
}
if (v.equals(multiValue)==false) {
LDAPAttribute a = new LDAPAttribute(key);
for (String vv:v) {
a.addValue(vv);
}
LDAPModification mod = new LDAPModification(LDAPModification.REPLACE,a);
mods.add(mod);
}
}
}
LDAPModification[] m = new LDAPModification[mods.size()];
mods.toArray(m);
connection.modify(entry.getDN(), m);
return object;
} catch (Exception e) {
throw new VascException(e);
} finally {
if (connection!=null) {
connection.clone();
@ -177,7 +246,26 @@ public class LdapVascBackend extends AbstractVascBackend {
LdapConnectionProvider prov = getLdapConnectionProvider();
LDAPConnection connection = prov.getLdapConnection();
try {
Map<String,Object> map = (Map)object;
String keyValue = (String)map.get(keyAttribute);
int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN;
String filter = "(&("+ldapFilter+")("+keyAttribute+"="+keyValue+"))";
LDAPSearchResults searchResults = connection.search(
searchBase, // object to read
searchScope, // scope - read single object
filter, // search filter
null, // return all attributes
false); // return attrs and values
if (searchResults.hasMore()==false) {
// no result to mod
return;
}
LDAPEntry entry = searchResults.next();
connection.delete(entry.getDN());
} catch (Exception e) {
throw new VascException(e);
} finally {
if (connection!=null) {
connection.clone();
@ -189,53 +277,14 @@ public class LdapVascBackend extends AbstractVascBackend {
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
*/
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
return new VascEntryRecordCreator() {
public Class<?> getObjectClass() {
return Map.class;
}
public Object newRecord(VascEntry entry) throws Exception {
return new HashMap<String,Object>(10);
}
};
return new MapVascEntryRecordCreator();
}
/**
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
*/
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
VascEntryFieldValue result = new VascEntryFieldValue() {
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public Object getValue(VascEntryField field, Object record) throws VascException {
Map<String,Object> map = (Map<String,Object>)record;
Object r = map.get(field.getBackendName());
if (r==null) {
return ""; // create new value, ldap does not return data for field that an user does not have, but other do,...
}
return r;
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getDisplayValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
*/
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
return ""+getValue(field,record); // not supported (this)ldap is already fully string based.
}
/**
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
Map<String,Object> map = (Map<String,Object>)record;
map.put(field.getBackendName(), value);
}
};
return result;
return new MapVascEntryFieldValue();
}
/**

View file

@ -26,6 +26,8 @@
package com.idcanet.vasc.core;
import java.util.Map;
/**
*
@ -101,4 +103,32 @@ abstract public class AbstractVascBackend implements VascBackend {
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException {
return 0l;
}
/**
* @see com.idcanet.vasc.core.VascBackend#executePageSummary()
*/
public Map<String, Object> executePageSummary() {
return null;
}
/**
* @see com.idcanet.vasc.core.VascBackend#executeTotalSummary()
*/
public Map<String, Object> executeTotalSummary() {
return null;
}
/**
* @see com.idcanet.vasc.core.VascBackend#isPageSummary()
*/
public boolean isPageSummary() {
return false;
}
/**
* @see com.idcanet.vasc.core.VascBackend#isTotalSummary()
*/
public boolean isTotalSummary() {
return false;
}
}

View file

@ -27,6 +27,7 @@
package com.idcanet.vasc.core;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
@ -152,4 +153,32 @@ abstract public class AbstractVascBackendProxy implements VascBackend {
public boolean isRecordMoveable() {
return backend.isRecordMoveable();
}
/**
* @see com.idcanet.vasc.core.VascBackend#executePageSummary()
*/
public Map<String, Object> executePageSummary() {
return backend.executePageSummary();
}
/**
* @see com.idcanet.vasc.core.VascBackend#executeTotalSummary()
*/
public Map<String, Object> executeTotalSummary() {
return backend.executeTotalSummary();
}
/**
* @see com.idcanet.vasc.core.VascBackend#isPageSummary()
*/
public boolean isPageSummary() {
return backend.isPageSummary();
}
/**
* @see com.idcanet.vasc.core.VascBackend#isTotalSummary()
*/
public boolean isTotalSummary() {
return backend.isTotalSummary();
}
}

View file

@ -27,6 +27,7 @@
package com.idcanet.vasc.core;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
@ -49,9 +50,21 @@ public interface VascBackend {
public void delete(Object object) throws VascException;
/**
* Creates a new Field acces obj the the given field entry.
* note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle.
* @param field
* @return
*/
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field);
/**
* Creates a new RecordCreater obj the the given entry.
* note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle.
* @param vascEntry
* @return
*/
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry);
/**
@ -86,6 +99,13 @@ public interface VascBackend {
public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascException;
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException;
public boolean isPageSummary();
public Map<String,Object> executePageSummary();
public boolean isTotalSummary();
public Map<String,Object> executeTotalSummary();
/*
public boolean hasSettings();
public Map<String,String> getSettings();

View file

@ -50,6 +50,8 @@ public interface VascFrontendHelper {
public Integer getTotalColumnsWidth(VascEntry entry);
public List<VascLinkEntry> getVascLinkEntryByType(VascEntry entry,VascLinkEntryType type);
/**
* Returns the total amount of pages
* @return

View file

@ -52,14 +52,14 @@ public interface VascLinkEntry extends Cloneable,Serializable {
public List<String> getEntryCreateFieldValueKeys();
/**
* @return the viewAsDetail
* @return the vascLinkEntryType
*/
public Boolean getViewAsDetail();
public VascLinkEntryType getVascLinkEntryType();
/**
* @param viewAsDetail the viewAsDetail to set
* @param vascLinkEntryType the vascLinkEntryType to set
*/
public void setViewAsDetail(Boolean viewAsDetail);
public void setVascLinkEntryType(VascLinkEntryType vascLinkEntryType);
/**
* @return the doActionId
@ -71,6 +71,16 @@ public interface VascLinkEntry extends Cloneable,Serializable {
*/
public void setDoActionId(String doActionId);
/**
* @return the name
*/
public String getName();
/**
* @param name the name to set
*/
public void setName(String name);
/**
* Force impl to have public clone methode
* @return

View file

@ -0,0 +1,44 @@
/*
* 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;
/**
* The type of a VascLinkEntry
*
* @author Willem Cazander
* @version 1.0 Mrt 16, 2010
*/
public enum VascLinkEntryType implements Serializable {
EDIT_INLINE,
EDIT_TAB,
LIST;
public static VascLinkEntryType DEFAULT_TYPE = VascLinkEntryType.EDIT_TAB;
}

View file

@ -56,11 +56,16 @@ import com.idcanet.vasc.core.VascBackendPageNumber;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryState;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.VascLinkEntryType;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryExporter;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.impl.actions.AddRowAction;
import com.idcanet.vasc.impl.actions.DeleteRowAction;
import com.idcanet.vasc.impl.actions.EditRowAction;
/**
*
@ -132,6 +137,43 @@ public class JSFVascEntrySupportBean implements Serializable {
return r;
}
public String getParentSelectedDisplayName() {
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
return ""; // no parent
}
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
Object row = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
if (row==null) {
return "no-selection";
}
VascEntryField v = parent.getVascEntryFieldById(parent.getDisplayNameFieldId());
VascEntryFieldValue ve = v.getVascEntryFieldValue();
String result = "no-data";
try {
result = ve.getDisplayValue(v, row);
} catch (VascException e) {
e.printStackTrace();
}
return result;
}
public String getSelectedDisplayName() {
Object row = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
if (row==null) {
return "no-selection";
}
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
VascEntryFieldValue ve = v.getVascEntryFieldValue();
String result = "no-data";
try {
result = ve.getDisplayValue(v, row);
} catch (VascException e) {
e.printStackTrace();
}
return result;
}
public int getTotalColumnCount() {
int t = 0;
t += getTotalFieldColumnCount();
@ -165,14 +207,27 @@ public class JSFVascEntrySupportBean implements Serializable {
}
public int getTotalLinkColumnCount() {
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(FacesContext.getCurrentInstance().getViewRoot(),entry.getId());
String disableLinkColumns = (String)comp.getAttributes().get(JSFVascUIComponent.DISABLE_LINK_COLUMNS);
if (disableLinkColumns!=null && disableLinkColumns.equals("true")) {
return 0; // not added too table.
}
return entry.getVascLinkEntries().size();
return getVascLinkEntriesList().size();
}
public List<VascLinkEntry> getVascLinkEntriesList() {
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.LIST);
}
public List<VascLinkEntry> getVascLinkEntriesEditTab() {
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.EDIT_TAB);
}
public List<VascLinkEntry> getVascLinkEntriesEditInline() {
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.EDIT_INLINE);
}
public List<VascLinkEntry> getVascLinkEntriesEditTabParentState() {
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
List<VascLinkEntry> result = new ArrayList<VascLinkEntry>(0);
return result;
}
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry(),VascLinkEntryType.EDIT_TAB);
}
public long getPageTotalRecordCount() {
long result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
return result;
@ -338,6 +393,51 @@ public class JSFVascEntrySupportBean implements Serializable {
throw new IllegalArgumentException("Component is of link of button type: "+comp);
}
public List<RowVascAction> getParentCustomRowActions() {
List<RowVascAction> result = new ArrayList<RowVascAction>(5);
VascEntry entry = getVascEntry();
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
return result;
}
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
for (RowVascAction action:parent.getRowActions()) {
String actionId = action.getId();
if (AddRowAction.ACTION_ID.equals(actionId)) {
continue;
}
if (DeleteRowAction.ACTION_ID.equals(actionId)) {
continue;
}
if (EditRowAction.ACTION_ID.equals(actionId)) {
continue;
}
result.add(action);
}
return result;
}
public void parentCustomRowaction(ActionEvent event) {
String actionIdString = getComponentType(event.getComponent());
logger.fine("parentCustomRowaction: "+actionIdString);
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
return;
}
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
RowVascAction action = parent.getRowActionById(actionIdString);
Object parentSelected = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
logger.fine("parentCustomRowaction do on: "+action+" parentSelection: "+parentSelected);
try {
action.doRowAction(parent,parentSelected);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
logger.fine("parentCustomRowaction DONE");
}
public boolean getHasMultiRowActions() {
int size = getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry()).size();
if (size==0) {
@ -466,10 +566,19 @@ public class JSFVascEntrySupportBean implements Serializable {
return getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null;
}
public boolean getRenderBackEditAction() {
if (getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null) {
if (getVascEntry().getVascFrontendData().getVascEntryState().getParent().getVascEntry().getRowActionById("editRowAction")==null) {
return false; // parent is not editable
}
return true;
}
return false;
}
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();
@ -482,21 +591,18 @@ public class JSFVascEntrySupportBean implements Serializable {
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);
}
//String idField = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry().getPrimaryKeyFieldId();
// VascEntryField field = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry().getVascEntryFieldById(idField);
// try {
// Object id = field.getVascEntryFieldValue().getValue(field, rowObject);
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent(),rowObject);
// } catch (VascException e1) {
// TODO Auto-generated catch block
// e1.printStackTrace();
//}
}
@ -627,6 +733,7 @@ public class JSFVascEntrySupportBean implements Serializable {
VascDataBackendBean selected = comp.getSupportBean().getSelectedTableRecord();
logger.finer("Set selected: "+selected);
VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(selected.getRecord());
VascLinkEntry l = entry.getVascLinkEntryById(linkId);
comp.initGoto(l);
try {
@ -695,6 +802,7 @@ public class JSFVascEntrySupportBean implements Serializable {
logger.fine("cancelAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
this.getSelected().setRealValue(false);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
try {
entry.getVascFrontendData().getVascFrontend().renderView();
@ -745,7 +853,7 @@ public class JSFVascEntrySupportBean implements Serializable {
}
public void processDirectDownloadChange(ValueChangeEvent event){
// first do normal global selection of action aka: globalAction(event); copyed:
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
@ -782,8 +890,9 @@ public class JSFVascEntrySupportBean implements Serializable {
}
selectedExporterAction = "null"; // reset selection to top one.
FacesContext fc = FacesContext.getCurrentInstance();
try {
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse();
String filename = "export-list."+ex.getType();
response.setHeader("Content-disposition", "attachment; filename=" + filename);
@ -793,10 +902,10 @@ public class JSFVascEntrySupportBean implements Serializable {
ex.doExport(out, entry);
out.close();
fc.responseComplete();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
} finally {
fc.responseComplete();
}
}
@ -858,6 +967,7 @@ public class JSFVascEntrySupportBean implements Serializable {
* @param selected the selected to set
*/
public void setSelected(VascDataBackendBean selected) {
logger.info("Set selected records: "+selected+" on: "+this);
this.selected = selected;
}
@ -979,8 +1089,19 @@ public class JSFVascEntrySupportBean implements Serializable {
public void setSelectedMultiRowAction(String selectedMultiRowAction) {
this.selectedMultiRowAction = selectedMultiRowAction;
}
/**
* @return the selectAllValue
*/
public Boolean getSelectAllValue() {
return false;
}
/**
* @param selectAllValue the selectAllValue to set
*/
public void setSelectAllValue(Boolean selectAllValue) {
}
}
class JSFVascSupportI18nMapController implements Map<String,String> {
private VascEntry entry = null;

View file

@ -93,10 +93,8 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
logger.finer("renderEdit");
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
comp.setRenderFacetState("editView");
comp.setRenderFacetState("editView");
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
//String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
VascDataBackendBean selBean = null;
if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
@ -130,9 +128,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
comp.setRenderFacetState("listView");
if (comp.getSupportBean().getSelected()!=null) {
comp.getSupportBean().getSelected().setRealValue(false);
comp.getSupportBean().setSelected(null);
}
//if (comp.getSupportBean().getSelected()!=null) {
// comp.getSupportBean().getSelected().setRealValue(false);
// comp.getSupportBean().setSelected(null);
//}
}
}

View file

@ -27,7 +27,9 @@
package com.idcanet.vasc.frontends.web.jsf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import javax.el.ValueExpression;
@ -45,6 +47,7 @@ import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.frontends.web.jsf.ui.JSFListModel;
import com.idcanet.vasc.impl.DefaultVascFactory;
/**
@ -74,6 +77,7 @@ public class JSFVascUIComponent extends UIComponentBase {
private VascLinkEntry link = null;
private VascEntryState linkState = null;
private VascEntryState state = null;
private Object stateEditId = null;
private Logger logger = null;
private Boolean initClear = null;
@ -187,6 +191,12 @@ public class JSFVascUIComponent extends UIComponentBase {
this.state=state;
}
protected void initGoto(VascEntryState state,Object stateEditId) {
logger.fine("init goto "+state);
this.state=state;
this.stateEditId=stateEditId;
}
public Boolean getInitClear() {
return initClear;
}
@ -194,9 +204,14 @@ public class JSFVascUIComponent extends UIComponentBase {
@Override
public void encodeBegin(FacesContext context) throws IOException {
logger.fine("Comp encodeBegin link: "+link);
// no need to add multiple
if (renderer==null) {
logger.finer("Adding phase listener: JSFVascValidatePhaseListener");
context.getViewRoot().addPhaseListener(new JSFVascValidatePhaseListener());
}
boolean init = false;
if (renderer==null | link!=null | state!=null) {
renderFacetState = "listView";
renderFacetState = "listView";
VascEntry entry = createClonedVascEntry();
renderer = new JSFVascFrontendRenderer();
try {
@ -209,13 +224,36 @@ public class JSFVascUIComponent extends UIComponentBase {
supportBean.setSearchString(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSearchString());
init = true;
}
if (stateEditId!=null) {
Object rowObject = stateEditId;
// no need to add multiple
if (renderer==null) {
logger.info("Adding phase listener: JSFVascValidatePhaseListener");
context.getViewRoot().addPhaseListener(new JSFVascValidatePhaseListener());
// setup for renderEdit() of frontend
List<Object> list = new ArrayList<Object>(1);
list.add(new VascDataBackendBean(supportBean.getVascEntry(),rowObject,0));
supportBean.getTableDataModel().setWrappedData(list);
supportBean.getTableDataModel().setRowIndex(0);
// edit action copyed
try {
VascEntry entry = supportBean.getVascEntry();
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) {
e.printStackTrace();
}
}
// refresh all drop down lists..
for (String key:supportBean.getEditSelectItemModels().keySet()) {
Object o = supportBean.getEditSelectItemModels().get(key);
if (o instanceof JSFListModel) {
JSFListModel t = (JSFListModel)o;
t.requestRefresh();
}
}
// set the support bean
@ -277,6 +315,9 @@ public class JSFVascUIComponent extends UIComponentBase {
if (link!=null) {
entryName = link.getVascEntryId();
}
if (state!=null) {
entryName = state.getVascEntry().getId();
}
VascEntry entry = vascController.getVascEntryController().getVascEntryById(entryName);
if (entry==null) {
@ -289,6 +330,11 @@ public class JSFVascUIComponent extends UIComponentBase {
frontendData.getVascEntryState().setVascBackend(backend);
frontendData.getVascEntryState().setVascEntry(entry);
if (state!=null) {
// copy prevois parent
frontendData.getVascEntryState().setParent(state.getParent());
}
if (link!=null) {
// save state
if (linkState==null) {
@ -303,6 +349,14 @@ public class JSFVascUIComponent extends UIComponentBase {
for (String parameterName:link.getEntryParameterFieldIdKeys()) {
String fieldId = link.getEntryParameterFieldId(parameterName);
VascEntryField v = getVascEntry().getVascEntryFieldById(fieldId);
if (v==null) {
logger.warning("Could nog get VascEntryField for fieldID: "+fieldId);
continue;
}
if (v.getVascEntryFieldValue()==null) {
logger.warning("Could not get VascEntryFieldValue for fieldID: "+fieldId);
continue;
}
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
// set data parameter on new vasc entry

View file

@ -61,8 +61,10 @@ import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.VascLinkEntryType;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.ui.VascOptionValueModelListener;
import com.idcanet.vasc.core.ui.VascUIComponent;
import com.idcanet.vasc.core.ui.VascValueModel;
import com.idcanet.vasc.impl.actions.AddRowAction;
@ -95,6 +97,10 @@ public class JSFVascUIComponentRenderer extends Renderer {
// check if injection is needed
if (comp.getInitClear()!=null) {
injectAll(facesContext,comp,comp.getInitClear());
// hack for edit back action to set field disabled
VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
}
// render the current facet of the vasc component
@ -119,8 +125,8 @@ public class JSFVascUIComponentRenderer extends Renderer {
String injectTableColumnsId = (String)comp.getAttributes().get(JSFVascUIComponent.INJECT_TABLE_COLUMNS_ID);
UIComponent injectEditFieldsComponent = JSFVascUIComponent.findComponentById(comp.getFacet("editView"),injectEditFieldsId);
UIComponent injectTableOptionsComponent = JSFVascUIComponent.findComponentById(comp.getCurrentView(),injectTableOptionsId);
UIComponent injectTableColumnsComponent = JSFVascUIComponent.findComponentById(comp.getCurrentView(),injectTableColumnsId);
UIComponent injectTableOptionsComponent = JSFVascUIComponent.findComponentById(comp.getFacet("listView"),injectTableOptionsId);
UIComponent injectTableColumnsComponent = JSFVascUIComponent.findComponentById(comp.getFacet("listView"),injectTableColumnsId);
if (injectEditFieldsComponent==null) {
throw new NullPointerException("Could not find injectEditFieldsId: "+injectEditFieldsId);
}
@ -166,15 +172,15 @@ public class JSFVascUIComponentRenderer extends Renderer {
if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) {
continue;
}
//System.out.println("Multi edit size: "+c.getVascEntryFieldType().getUIComponentCount(c)+" of: "+c.getVascEntryFieldType());
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
com.idcanet.vasc.core.ui.VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
VascValueModel model = new VascValueModel();
model.setValue(i18n(entry,c.getName()));
label.createComponent(entry,c,model,grid);
com.idcanet.vasc.core.ui.VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
//model.setValue(c.getVascEntryFieldValue().getValue(c, bean));
//model.addListener(new VascColumnValueModelListener(c,bean));
@ -215,36 +221,47 @@ public class JSFVascUIComponentRenderer extends Renderer {
class VascJSFInputValidator2 implements Validator,Serializable {
private static final long serialVersionUID = -5715250529474737642L;
String fieldId = null;
private Logger logger = null;
private String fieldId = null;
public VascJSFInputValidator2(String fieldId) {
this.fieldId=fieldId;
logger = Logger.getLogger(VascJSFInputValidator2.class.getName());
}
public void validate(FacesContext context, UIComponent component,Object object) throws ValidatorException {
// always oke, we are runned by phase listener
System.out.println("Validate normal.");
}
public void validatePhase(FacesContext context, UIComponent component,Object object) throws ValidatorException {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component);
VascEntry entry = comp.getVascEntry();
StringBuffer buf;
try {
VascEntryField field = entry.getVascEntryFieldById(fieldId);
int index = VascDataBackendBean.getIndexId(field);
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
logger.fine("sup-sel: "+comp.getSupportBean().getSelected()+" index: "+index);
// note we have to set the value to the vasc backend before we can run validation
int index = VascDataBackendBean.getIndexId(field);
ValueExpression ve7 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".selected.field"+index+"}", Object.class);
ve7.setValue(FacesContext.getCurrentInstance().getELContext(), object);
List<String> errors = entry.getVascFrontendData().getVascFrontendHelper().validateObjectField(field);
System.out.println("Validate: "+component+" errors: "+errors.size()+" value: "+object);
logger.fine("Validate: "+component+" errors: "+errors.size()+" value: "+object);
if (errors.isEmpty()) {
return; // no errors
}
StringBuffer buf = new StringBuffer(200);
buf = new StringBuffer(200);
for (String err:errors) {
buf.append(err);
buf.append('\n');
}
} catch (Exception e) {
e.printStackTrace();
return;
}
FacesMessage message = new FacesMessage(buf.toString());
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(message);
@ -263,18 +280,20 @@ public class JSFVascUIComponentRenderer extends Renderer {
for (VascEntryField option:entry.getListOptions()) {
for (int i=0;i<option.getVascEntryFieldType().getUIComponentCount(option);i++) {
com.idcanet.vasc.core.ui.VascUIComponent label = option.getVascEntryFieldType().provideLabelUIComponent(i,option);
VascUIComponent label = option.getVascEntryFieldType().provideLabelUIComponent(i,option);
VascValueModel model = new VascValueModel();
model.setValue(i18n(entry,option.getName()));
label.createComponent(entry,option,model,grid);
com.idcanet.vasc.core.ui.VascUIComponent editor = option.getVascEntryFieldType().provideEditorUIComponent(i,option);
VascUIComponent editor = option.getVascEntryFieldType().provideEditorUIComponent(i,option);
model = new VascValueModel(option.getVascEntryFieldType().provideEditorVascValueModel(i,option));
model.addListener(new VascOptionValueModelListener(option));
model.setValue(option.getDefaultValue());
UIInput jsfEdit = (UIInput)editor.createComponent(entry,option,model,grid);
jsfEdit.addValueChangeListener(new ModelChangeListener(model));
editor.setDisabled(false); // TODO: HACK for JSFLIST for model remove me !
// i==0 is for multi field editor support... which is stell very in progress aka not working
if (i==0) {
entry.getVascFrontendData().addFieldVascUIComponents(option, editor,jsfEdit);
@ -331,6 +350,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
HtmlSelectBooleanCheckbox select = (HtmlSelectBooleanCheckbox)application.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
select.setId(viewRoot.createUniqueId());
select.setStyleClass("js_table_select_all");
ValueExpression ve1 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),"#{"+entrySupportVar+".vascEntry.vascFrontendData.vascEntryState.multiActionSelection["+tableRecordVar+".recordId]}",Object.class);
select.setValueExpression("value", ve1);
@ -427,14 +447,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
table.getChildren().add(colDown);
}
String disableLinkColumns = (String)comp.getAttributes().get(JSFVascUIComponent.DISABLE_LINK_COLUMNS);
for (VascLinkEntry vascLink:entry.getVascLinkEntries()) {
if (disableLinkColumns!=null && disableLinkColumns.equals("true")) {
continue; // do not all columns
}
for (VascLinkEntry vascLink:entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry, VascLinkEntryType.LIST)) {
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
col.setId(viewRoot.createUniqueId());
@ -450,12 +463,9 @@ public class JSFVascUIComponentRenderer extends Renderer {
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
link.addActionListener(meActionListener);
// rm this , bacause of unneeded copy, should add name to link
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(vascLink.getVascEntryId());
HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
out.setId(viewRoot.createUniqueId());
out.setValue(i18n(entry,ve.getName()));
out.setValue(i18n(entry,vascLink.getName()));
link.getChildren().add(out);
col.getChildren().add(link);
@ -505,4 +515,4 @@ public class JSFVascUIComponentRenderer extends Renderer {
return facesCtx.getApplication().getExpressionFactory().createMethodExpression(elContext, name, null, argtypes);
}
}
};

View file

@ -3,6 +3,9 @@
*/
package com.idcanet.vasc.frontends.web.jsf;
import java.util.Iterator;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
@ -16,13 +19,22 @@ import javax.faces.validator.ValidatorException;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.frontends.web.jsf.JSFVascUIComponentRenderer.VascJSFInputValidator2;
/**
* @author willemc
*
* JSFVascValidatePhaseListener runs the vasc field edit fields.
*
* @author Willem Cazander
* @version 1.0 Nov 15, 2009
*/
public class JSFVascValidatePhaseListener implements PhaseListener {
private static final long serialVersionUID = 1L;
private Logger logger = null;
public JSFVascValidatePhaseListener() {
logger = Logger.getLogger(JSFVascValidatePhaseListener.class.getName());
}
public void afterPhase(PhaseEvent event) {
FacesContext context = event.getFacesContext();
validateUIInput(context.getViewRoot(),context);
@ -33,9 +45,9 @@ public class JSFVascValidatePhaseListener implements PhaseListener {
return PhaseId.PROCESS_VALIDATIONS;
}
private void validateUIInput(UIComponent component,FacesContext context) {
System.out.println("Validate vasc: "+component);
if (component instanceof UIInput) {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component);
logger.finer("Validate UIInput: "+component+" comp: "+comp);
if (comp==null) {
return; // non-vasc ui-input
}
@ -49,11 +61,8 @@ public class JSFVascValidatePhaseListener implements PhaseListener {
VascJSFInputValidator2 validator = (VascJSFInputValidator2)v;
try {
in.setValid(true);
//Object value = in.getValue();
//System.out.println("Checking value: "+value);
validator.validatePhase(context, in, in.getValue());
} catch (ValidatorException ve) {
//System.out.println("Error");
in.setValid(false);
// note: ve has the message already but this is the UIInput way
@ -72,7 +81,9 @@ public class JSFVascValidatePhaseListener implements PhaseListener {
}
}
}
for (UIComponent child:component.getChildren()) {
Iterator<UIComponent> kids = component.getFacetsAndChildren();
while (kids.hasNext()) {
UIComponent child = kids.next();
validateUIInput(child,context);
}
}

View file

@ -151,7 +151,7 @@ public class VascRequestFacesFilter implements Filter {
facesContext.setViewRoot(viewRoot);
}
try {
request.getRequestDispatcher(templateFile).include(request, response);
request.getRequestDispatcher(templateFile).forward(request, response);
} catch (ViewExpiredException e) {
// lets try again
response.sendRedirect(request.getRequestURL().toString());

View file

@ -27,7 +27,6 @@
package com.idcanet.vasc.frontends.web.jsf.ui;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.el.ValueExpression;
@ -39,13 +38,11 @@ import javax.faces.component.html.HtmlSelectOneMenu;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.model.SelectItem;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.ui.VascSelectItem;
import com.idcanet.vasc.core.ui.VascSelectItemModel;
import com.idcanet.vasc.core.ui.VascValueModel;
import com.idcanet.vasc.frontends.web.jsf.JSFVascUIComponent;
@ -67,42 +64,17 @@ public class JSFList extends AbstractJSFBaseComponent {
componentId = component.getId();
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent((UIComponent)gui);
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
String id = component.getId();
ValueExpression itemsTestVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+id+"']}", TestModel.class);
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;
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
ValueExpression itemsTestVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+componentId+"']}", JSFListModel.class);
JSFListModel t = new JSFListModel(entryField);
itemsTestVE.setValue(FacesContext.getCurrentInstance().getELContext(), t);
component.setConverter(new VascConverter(t));
UISelectItems item = (UISelectItems)application.createComponent(UISelectItems.COMPONENT_TYPE);
item.setId(viewRoot.createUniqueId());
ValueExpression itemsVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+id+"']}", List.class);
item.setValueExpression("value", itemsVE);
component.getChildren().add(item);
((UIComponent)gui).getChildren().add(component);
setValueTestModel(component);
return component;
}
@ -121,27 +93,30 @@ public class JSFList extends AbstractJSFBaseComponent {
HtmlSelectOneMenu component = (HtmlSelectOneMenu)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
component.setDisabled(disabled);
}
}
class TestModel extends ArrayList<SelectItem> implements Serializable {
private static final long serialVersionUID = -5266070864271715383L;
public VascEntryField entryField;
private List<VascSelectItem> items;
public TestModel(List<VascSelectItem> items) {
this.items=items;
}
public List<VascSelectItem> getVascItems() {
return items;
private void setValueTestModel(HtmlSelectOneMenu component) {
Application application = FacesContext.getCurrentInstance().getApplication();
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
UISelectItems item = (UISelectItems)application.createComponent(UISelectItems.COMPONENT_TYPE);
item.setId(viewRoot.createUniqueId());
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,null);
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
String id = component.getId();
ValueExpression itemsVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+id+"']}", List.class);
item.setValueExpression("value", itemsVE);
component.getChildren().clear();
component.getChildren().add(item);
}
}
class VascConverter implements Converter,Serializable {
private static final long serialVersionUID = 6198813637409531713L;
private TestModel testModel = null;
private JSFListModel testModel = null;
public VascConverter(TestModel testModel) {
public VascConverter(JSFListModel testModel) {
this.testModel=testModel;
}

View file

@ -0,0 +1,180 @@
/*
* Copyright 2004-2007 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.frontends.web.jsf.ui;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import javax.faces.model.SelectItem;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.ui.VascSelectItem;
import com.idcanet.vasc.core.ui.VascSelectItemModel;
/**
*
*
* @author Willem Cazander
* @version 1.0 Mar 28, 2009
*/
public class JSFListModel implements Serializable,List<SelectItem> {
private static final long serialVersionUID = -5266070864271715383L;
private VascEntryField entryField;
private List<VascSelectItem> items = null;
private List<SelectItem> selectItems = null;
private boolean refresh = true;
public JSFListModel() {
items = new ArrayList<VascSelectItem>(40);
selectItems = new ArrayList<SelectItem>(40);
}
public JSFListModel(VascEntryField entryField) {
this();
this.entryField=entryField;
}
public List<VascSelectItem> getVascItems() {
refresh();
return items;
}
public List<SelectItem> getSelectItems() {
refresh();
return selectItems;
}
public void requestRefresh() {
refresh = true;
}
private void refresh() {
if (refresh==false) {
return;
}
refresh=false;
items.clear();
selectItems.clear();
VascSelectItemModel itemModel = (VascSelectItemModel)entryField.getVascEntryFieldType().getDataObject();
try {
items = itemModel.getVascSelectItems(entryField.getVascEntry());
} catch (VascException e) {
throw new RuntimeException(e);
}
for (VascSelectItem v:items) {
selectItems.add(convert(v));
}
}
private SelectItem convert(VascSelectItem v) {
SelectItem si = new SelectItem();
si.setLabel(v.getLabel());
si.setValue(v.getValue());
si.setDisabled(v.isDisabled());
return si;
}
// === LIST interface
public void add(int arg0, SelectItem arg1) {
getSelectItems().add(arg0,arg1);
}
public boolean add(SelectItem arg0) {
return getSelectItems().add(arg0);
}
public boolean addAll(Collection<? extends SelectItem> arg0) {
return getSelectItems().addAll(arg0);
}
public boolean addAll(int arg0, Collection<? extends SelectItem> arg1) {
return getSelectItems().addAll(arg0,arg1);
}
public void clear() {
getSelectItems().clear();
}
public boolean contains(Object arg0) {
return getSelectItems().contains(arg0);
}
public boolean containsAll(Collection<?> arg0) {
return getSelectItems().containsAll(arg0);
}
public SelectItem get(int index) {
return getSelectItems().get(index);
}
public int indexOf(Object arg0) {
return getSelectItems().indexOf(arg0);
}
public boolean isEmpty() {
return getSelectItems().isEmpty();
}
public Iterator<SelectItem> iterator() {
return getSelectItems().iterator();
}
public int lastIndexOf(Object arg0) {
return getSelectItems().lastIndexOf(arg0);
}
public ListIterator<SelectItem> listIterator() {
return getSelectItems().listIterator();
}
public ListIterator<SelectItem> listIterator(int arg0) {
return getSelectItems().listIterator(arg0);
}
public SelectItem remove(int arg0) {
return getSelectItems().remove(arg0);
}
public boolean remove(Object arg0) {
return getSelectItems().remove(arg0);
}
public boolean removeAll(Collection<?> arg0) {
return getSelectItems().removeAll(arg0);
}
public boolean retainAll(Collection<?> arg0) {
return getSelectItems().retainAll(arg0);
}
public SelectItem set(int arg0, SelectItem arg1) {
return getSelectItems().set(arg0, arg1);
}
public int size() {
return getSelectItems().size();
}
public List<SelectItem> subList(int arg0, int arg1) {
return getSelectItems().subList(arg0, arg1);
}
public Object[] toArray() {
return getSelectItems().toArray();
}
public <T> T[] toArray(T[] a) {
return getSelectItems().toArray(a);
}
}

View file

@ -38,6 +38,7 @@ import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.VascEntryFinalizer;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.VascLinkEntryType;
import com.idcanet.vasc.core.actions.VascAction;
/**
@ -225,11 +226,14 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
if (vef.getList()==null) {
vef.setList(true);
}
if (vef.getCreate()==null) {
vef.setCreate(true);
}
if (vef.getEdit()==null) {
vef.setEdit(true);
}
if (vef.getEditReadOnly()==null) {
vef.setEditReadOnly(true);
vef.setEditReadOnly(false);
}
if (vef.getVascEntryFieldValue()==null) {
@ -293,6 +297,16 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
if (vid==null) {
throw new IllegalArgumentException("All VascLinkEntry need an id in entryId: "+id);
}
if (vle.getVascEntryId()==null) {
throw new IllegalArgumentException("All VascLinkEntry need an vascEntryId: "+id);
}
if (vle.getVascLinkEntryType()==null) {
vle.setVascLinkEntryType(VascLinkEntryType.DEFAULT_TYPE);
}
if (vle.getName()==null) {
vle.setName("vasc.entry."+vle.getVascEntryId()+".name");
}
}
for (VascEntryField vef:entry.getListOptions()) {
@ -339,11 +353,14 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
if (vef.getList()==null) {
vef.setList(true);
}
if (vef.getCreate()==null) {
vef.setCreate(true);
}
if (vef.getEdit()==null) {
vef.setEdit(true);
}
if (vef.getEditReadOnly()==null) {
vef.setEditReadOnly(true);
vef.setEditReadOnly(false);
}
if (vef.getVascEntryFieldValue()==null) {

View file

@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 IDCA. All rights reserved.
* Copyright 2004-2010 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:
@ -32,12 +32,15 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.idcanet.vasc.core.VascBackendFilter;
import com.idcanet.vasc.core.VascBackendPageNumber;
import com.idcanet.vasc.core.VascBackendState;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.VascFrontendHelper;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.VascLinkEntryType;
import com.idcanet.vasc.core.VascUserRoleController;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
@ -177,6 +180,20 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
return result;
}
public List<VascLinkEntry> getVascLinkEntryByType(VascEntry entry,VascLinkEntryType type) {
List<VascLinkEntry> result = new ArrayList<VascLinkEntry>(10);
for (VascLinkEntry link:entry.getVascLinkEntries()) {
if (type==null) {
result.add(link);
continue;
}
if (type.equals(link.getVascLinkEntryType())) {
result.add(link);
}
}
return result;
}
/**
* Returns the total amount of pages
* @return
@ -220,20 +237,26 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
public Object createObject(VascEntry entry) {
try {
Object object = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryRecordCreator(entry.clone()).newRecord(entry);
if (object==null) {
throw new IllegalStateException("Can't work with null object for backend storage.");
}
for (VascEntryField field:entry.getVascEntryFields()) {
if (field.getDefaultValue()==null) {
continue; // no default value to set.
}
Object value = field.getVascEntryFieldValue().getValue(field, object);
if (value==null & field.getDefaultValue()!=null) {
Object defaultValue = field.getDefaultValue();
if (defaultValue instanceof String) {
String def = (String)defaultValue;
if (def.equals("now()")) { // TODO: add default string parsers
defaultValue = new Date();
}
}
logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue);
field.getVascEntryFieldValue().setValue(field, object, defaultValue);
if (value!=null) {
continue; // value is already set by backend creator.
}
Object defaultValue = field.getDefaultValue();
if (defaultValue instanceof String) {
String def = (String)defaultValue;
if (def.equals("now()")) { // TODO: add default string parsers
defaultValue = new Date();
}
}
logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue);
field.getVascEntryFieldValue().setValue(field, object, defaultValue);
}
fireVascEvent(entry,VascEventType.DATA_CREATE, object);
return object;
@ -286,7 +309,16 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
try {
fireVascEvent(entry,VascEventType.DATA_PRE_UPDATE,object);
int index = removeObjectFromDataList(entry,object);
// merge object on backend
result = entry.getVascFrontendData().getVascEntryState().getVascBackend().merge(object);
// put object thrue the filters
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
result = filter.filterObject(result);
}
// put object back in list
entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
fireVascEvent(entry,VascEventType.DATA_POST_UPDATE,result);
@ -353,6 +385,17 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
throw new NullPointerException("Can't validate null entry object.");
}
List<String> error = new ArrayList<String>(3);
// skip non-create and non-edit fields
if (entry.getVascFrontendData().getVascFrontendHelper().renderCreate(field) == false &
entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
return error;
}
if (entry.getVascFrontendData().getVascFrontendHelper().renderEditReadOnly(field) &
entry.getVascFrontendData().getVascEntryState().isEditCreate()==false) {
return error;
}
try {
Object objectSelected = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
Object objectValue = field.getVascEntryFieldValue().getValue(field, objectSelected);

View file

@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.VascLinkEntryType;
/**
@ -47,9 +48,10 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
private String vascEntryId = null;
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
private Map<String,String> entryCreateFieldValues = new HashMap<String,String>(3);
private Boolean viewAsDetail = null;
private VascLinkEntryType vascLinkEntryType = null;
private String doActionId = null;
private String name = null;
/**
* @return the id
*/
@ -100,17 +102,17 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
}
/**
* @return the viewAsDetail
* @return the vascLinkEntryType
*/
public Boolean getViewAsDetail() {
return viewAsDetail;
public VascLinkEntryType getVascLinkEntryType() {
return vascLinkEntryType;
}
/**
* @param viewAsDetail the viewAsDetail to set
* @param vascLinkEntryType the vascLinkEntryType to set
*/
public void setViewAsDetail(Boolean viewAsDetail) {
this.viewAsDetail = viewAsDetail;
public void setVascLinkEntryType(VascLinkEntryType vascLinkEntryType) {
this.vascLinkEntryType = vascLinkEntryType;
}
/**
@ -127,6 +129,20 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
this.doActionId = doActionId;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @see java.lang.Object#clone()
*/
@ -134,11 +150,12 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
public VascLinkEntry clone() throws CloneNotSupportedException {
DefaultVascLinkEntry result = new DefaultVascLinkEntry();
result.doActionId=doActionId;
result.viewAsDetail=viewAsDetail;
result.vascLinkEntryType=vascLinkEntryType;
result.vascEntryId=vascEntryId;
result.entryParameterFieldIds=entryParameterFieldIds;
result.entryCreateFieldValues=entryCreateFieldValues;
result.id=id;
result.name=name;
return result;
}
}

View file

@ -27,7 +27,9 @@
package com.idcanet.vasc.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendState;
@ -54,6 +56,8 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
private String nullLabel = null;
private String nullKeyValue = null;
private Boolean returnKeyValue = null;
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
private Boolean useParentFields = null;
/**
* @see com.idcanet.vasc.core.ui.VascSelectItemModel#getVascSelectItems(com.idcanet.vasc.core.VascEntry)
@ -95,9 +99,41 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
VascBackendState state = new DefaultVascBackendState();
for (String key2:ve.getEntryParameterKeys()) {
Object value = ve.getEntryParameter(key2);
//System.out.println("Copy paras name: "+key2+" value: "+value+" class: "+value.getClass().getName());
state.setDataParameter(key2, value);
}
for (String paraName:entryParameterFieldIds.keySet()) {
VascEntry fieldEntry = entry;
if (useParentFields!=null && useParentFields==true) {
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
throw new IllegalStateException("Requested to use parent state field values but no parent state found.");
}
fieldEntry = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
}
String paraValueId = entryParameterFieldIds.get(paraName);
VascEntryField fieldOrg = fieldEntry.getVascEntryFieldById(paraValueId);
if (fieldOrg==null) {
//System.out.println("could not find field: "+paraValueId);
continue;
}
VascEntryField field = fieldOrg.clone();
field.getVascValidators().clear();
VascEntryFieldValue v = fieldEntry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(field);
Object record = fieldEntry.getVascFrontendData().getVascEntryState().getEntryDataObject();
if (record==null) {
//System.out.println("could not get selected records from state.");
continue;
}
Object value = v.getValue(fieldOrg, record);
//System.out.println("Set entry paras name: "+paraName+" value: "+value+" class: "+value.getClass().getName());
state.setDataParameter(paraName, value);
}
// TODO: FIX >>>>>>>>>>>>>>>>>>
if (key.getVascEntryFieldValue()==null) {
// TODO: fix this for better remote support
@ -218,4 +254,28 @@ public class DefaultVascSelectItemModel implements VascSelectItemModel {
public void setReturnKeyValue(Boolean returnKeyValue) {
this.returnKeyValue = returnKeyValue;
}
public String getEntryParameterFieldId(String parameterName) {
return entryParameterFieldIds.get(parameterName);
}
public void addEntryParameterFieldId(String parameterName,String valueFieldId) {
entryParameterFieldIds.put(parameterName, valueFieldId);
}
public List<String> getEntryParameterFieldIdKeys() {
return new ArrayList<String>(entryParameterFieldIds.keySet());
}
/**
* @return the useParentFields
*/
public Boolean getUseParentFields() {
return useParentFields;
}
/**
* @param useParentFields the useParentFields to set
*/
public void setUseParentFields(Boolean useParentFields) {
this.useParentFields = useParentFields;
}
}

View file

@ -65,7 +65,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
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().getVascEntryState().getVascBackendState().setPageIndex(page);
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {

View file

@ -62,7 +62,7 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
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().getVascEntryState().getVascBackendState().setPageIndex(page);
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {

View file

@ -104,5 +104,3 @@ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeCo
return result;
}
}

View file

@ -29,6 +29,7 @@ package com.idcanet.vasc.impl.type;
import java.util.List;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.ui.VascValueModel;
@ -42,6 +43,20 @@ import com.idcanet.vasc.core.ui.VascValueModel;
public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
private static final long serialVersionUID = 1L;
@Override
public VascEntryFieldType clone() throws CloneNotSupportedException {
MultiTextVascEntryFieldType clone = new MultiTextVascEntryFieldType();
clone.id=id;
clone.autoDetectClass=autoDetectClass;
clone.uiComponentId=uiComponentId;
clone.inputMask=inputMask;
for (String key:properties.keySet()) {
clone.properties.put(key,properties.get(key));
}
// mmm
clone.vascValidators.addAll(vascValidators);
return clone;
}
private Object getIndexValue(VascEntryField entryField,int index) throws VascException {
Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);
@ -94,7 +109,6 @@ public class MultiTextVascEntryFieldType extends DefaultVascEntryFieldType {
*/
@Override
public int getUIComponentCount(VascEntryField entryField) throws VascException {
Object record = entryField.getVascEntry().getVascFrontendData().getVascEntryState().getEntryDataObject();
Object value = entryField.getVascEntryFieldValue().getValue(entryField, record);

View file

@ -43,19 +43,17 @@ public class VascEntryFieldTypeAttributeConverter extends AbstractElementAttribu
/**
* @see com.idcanet.x4o.element.AbstractElementAttributeConverter#doConvertAttribute(com.idcanet.x4o.element.Element, java.lang.Object)
*/
public Object doConvertAttribute(Element element, Object parameterValue) throws ElementAttributeConverterException {
if (parameterValue==null) {
public Object doConvertAttribute(Element element, Object attributeValue) throws ElementAttributeConverterException {
if (attributeValue==null) {
throw new NullPointerException("can't convert null parameter");
}
if ("".equals(parameterValue)) {
parameterValue = "TextField"; // ??
if ("".equals(attributeValue)) {
attributeValue = "TextField"; // ??
}
String fieldID = parameterValue.toString();
String fieldID = attributeValue.toString();
VascController controller = VascParser.getVascController(element.getElementContext());
Object result = controller.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID);
Object result = controller.getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldID);
return result;
}
}

View file

@ -27,6 +27,7 @@
package com.idcanet.vasc.impl.x4o;
import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.impl.DefaultVascSelectItemModel;
import com.idcanet.x4o.element.AbstractElement;
import com.idcanet.x4o.element.ElementException;
@ -47,13 +48,22 @@ public class VascLinkEntryParameterElement extends AbstractElement {
String valueFieldId = getAttributes().get("valueFieldId");
String parameterName = getAttributes().get("name");
String selectedFieldId = getAttributes().get("selectedFieldId");
VascLinkEntry link = (VascLinkEntry)getParent().getElementObject();
if (parameterName!=null) {
// normal parameter
link.addEntryParameterFieldId(parameterName, valueFieldId);
} else {
link.addEntryCreateFieldValue(valueFieldId,selectedFieldId);
if (getParent().getElementObject() instanceof DefaultVascSelectItemModel) {
DefaultVascSelectItemModel m = (DefaultVascSelectItemModel)getParent().getElementObject();
m.addEntryParameterFieldId(parameterName, valueFieldId);
return;
}
if (getParent().getElementObject() instanceof VascLinkEntry) {
VascLinkEntry link = (VascLinkEntry)getParent().getElementObject();
if (parameterName!=null) {
// normal parameter
link.addEntryParameterFieldId(parameterName, valueFieldId);
} else {
link.addEntryCreateFieldValue(valueFieldId,selectedFieldId);
}
return;
}
throw new ElementException("Unsupported parent object: "+getParent().getElementObject());
}
}

View file

@ -23,14 +23,16 @@
</eld:elementClass>
<eld:elementClass tag="vascEntryFieldType" elementClassName="com.idcanet.vasc.impl.x4o.VascEntryFieldTypeElement"/>
<eld:elementClass tag="vascSelectItemModel" objectClassName="com.idcanet.vasc.impl.DefaultVascSelectItemModel"/>
<eld:elementClass tag="vascSelectItemModel" objectClassName="com.idcanet.vasc.impl.DefaultVascSelectItemModel"/>
<eld:elementClass tag="vascSelectItemEntryParameter" elementClassName="com.idcanet.vasc.impl.x4o.VascLinkEntryParameterElement"/>
<eld:elementClass tag="fieldSet" objectClassName="com.idcanet.vasc.impl.DefaultVascEntryFieldSet">
<eld:elementClassAttributeConverter attributeName="vascEntryFieldIds" bean.class="com.idcanet.vasc.impl.x4o.VascEntryFieldSetAttributeConverter"/>
</eld:elementClass>
<eld:elementClass tag="link" objectClassName="com.idcanet.vasc.impl.DefaultVascLinkEntry"/>
<eld:elementClass tag="link" objectClassName="com.idcanet.vasc.impl.DefaultVascLinkEntry">
<eld:elementClassAttributeConverter attributeName="vascLinkEntryType" enumClass="com.idcanet.vasc.core.VascLinkEntryType" bean.class="com.idcanet.x4o.impl.lang.EnumConverter"/>
</eld:elementClass>
<eld:elementClass tag="linkEntryParameter" elementClassName="com.idcanet.vasc.impl.x4o.VascLinkEntryParameterElement"/>
<eld:elementClass tag="linkEntryCreateFieldValue" elementClassName="com.idcanet.vasc.impl.x4o.VascLinkEntryParameterElement"/>

View file

@ -62,17 +62,21 @@ public class SwingTest extends TestCase {
assertEquals(true, true);
}
/*
public void testAll() throws Exception {
public static void main(String[] argu){
JFrame.setDefaultLookAndFeelDecorated(false);
try {
VascEntry entry = TestTable.getVascTable();
JFrame frame = viewEntry(entry);
SwingTest s = new SwingTest();
JFrame frame = s.viewEntry(entry);
while (frame.isVisible()) {
Thread.sleep(1000);
Thread.sleep(100000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
*/
public JFrame viewEntry(final VascEntry entry) throws Exception {
// get GUI