* @return return SQL String for update
* @throws PageException
*/
private SQL createSQL(DatasourceConnection dc,String[] keys, Struct meta) throws PageException {
String[] fields=null;
Form form = pageContext.formScope();
if(formfields!=null) fields=ListUtil.toStringArray(ListUtil.listToArrayRemoveEmpty(formfields,','));
else fields=CollectionUtil.keysAsString(pageContext.formScope());
StringBuffer set=new StringBuffer();
StringBuffer where=new StringBuffer();
ArrayList setItems=new ArrayList();
ArrayList whereItems=new ArrayList();
String field;
for(int i=0;i<fields.length;i++) {
field = StringUtil.trim(fields[i],null);
if(StringUtil.startsWithIgnoreCase(field, "form."))
field=field.substring(5);
if(!field.equalsIgnoreCase("fieldnames")) {
if(ArrayUtil.indexOfIgnoreCase(keys,field)==-1) {
if(set.length()==0) set.append(" set ");
else set.append(",");
set.append(field);
set.append("=?");
ColumnInfo ci=(ColumnInfo) meta.get(field);
if(ci!=null)setItems.add(new SQLItemImpl(form.get(field,null),ci.getType()));
else setItems.add(new SQLItemImpl(form.get(field,null)));
}
else {
if(where.length()==0) where.append(" where ");
else where.append(" and ");
where.append(field);
where.append("=?");
whereItems.add(new SQLItemImpl(form.get(field,null)));
}
}
}
if((setItems.size()+whereItems.size())==0) return null;