use of db.Rows in project common by zenlunatics.
the class FileRenderer method writeValue.
// --------------------------------------------------------------------------
@Override
public void writeValue(View view, ColumnBase<?> column, Request request) throws IOException {
Rows data = view.data();
String filename = data.getString("filename");
HTMLWriter writer = request.writer;
if (data.getBoolean("folder")) {
writer.aOnClickOpen("c_(this).replace('" + view.getViewDef().getURL(request).toString() + "&parent=" + data.getString("id") + "')");
writer.img("folder.gif");
writer.space();
writer.write(filename);
writer.tagClose();
} else {
writer.aOpen(m_path + '/' + filename);
writer.img("file.gif");
writer.space();
writer.write(m_use_titles ? data.getString("title") : filename);
writer.tagClose();
}
}
use of db.Rows in project common by zenlunatics.
the class ColumnBase method writeValue.
// --------------------------------------------------------------------------
public static boolean writeValue(String column_name, int display_length, View view, HTMLWriter writer) throws IOException {
Rows data = view.data();
if (data == null)
return false;
int index = column_name.lastIndexOf(" AS ");
if (index != -1)
column_name = column_name.substring(index + 4);
index = column_name.indexOf('.');
if (index != -1)
column_name = column_name.substring(index + 1);
int column_index = data.getColumnIndex(column_name);
int type = data.getColumnType(column_index);
if (type == Types.BOOLEAN || type == Types.BIT) {
if (view.getViewDef().allowQuickEdit()) {
writer.setAttribute("onclick", "qe_send_b('" + view.getViewDef().getName() + "',this)");
writer.checkbox(null, null, null, data.getBoolean(column_index), true);
} else
writer.write(data.getBoolean(column_index) ? "yes" : "no");
return true;
}
if (type == Types.DATE) {
Date date = data.getDate(column_index);
if (date != null) {
writer.writeDate(date);
return true;
}
return false;
}
if (type == Types.DOUBLE) {
writer.write(data.getDouble(column_index));
return true;
}
if (type == Types.INTEGER) {
writer.write(data.getInt(column_index));
return true;
}
if (type == Types.REAL) {
writer.write(data.getFloat(column_index));
return true;
}
if (type == Types.TIME) {
Time time = data.getTime(column_index);
if (time != null) {
writer.write(DateFormat.getTimeInstance(DateFormat.SHORT).format(time));
return true;
}
return false;
}
if (type == Types.TIMESTAMP) {
Timestamp timestamp = data.getTimestamp(column_index);
if (timestamp != null) {
writer.write(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(timestamp));
return true;
}
return false;
}
return writeString(data.getString(column_index), view, display_length, type == Types.BINARY, 0, writer);
}
use of db.Rows in project common by zenlunatics.
the class EmailColumn method writeValue.
// --------------------------------------------------------------------------
@Override
public boolean writeValue(View view, Map<String, Object> data, Request request) throws IOException {
Rows d = view.data();
if (d == null)
return false;
String value = d.getString(m_name);
if (value != null && value.length() > 0)
if (view.isPrinterFriendly())
request.writer.write(value);
else {
request.writer.write("<a href=\"mailto:");
request.writer.write(value);
request.writer.write("\">");
request.writer.write(value);
request.writer.write("</a>");
}
// request.writer.nbsp();
return true;
}
use of db.Rows in project common by zenlunatics.
the class PercentColumn method writeValue.
// --------------------------------------------------------------------------
@Override
public boolean writeValue(View view, Map<String, Object> data, Request request) throws IOException {
Rows d = view.data();
if (d == null)
return false;
int column_index = d.getColumnIndex(m_name);
int type = d.getColumnType(column_index);
switch(type) {
case Types.DOUBLE:
double dbl = d.getDouble(column_index);
if (!d.wasNull())
request.writer.writePercent(dbl);
return true;
case Types.INTEGER:
int i = d.getInt(column_index);
if (!d.wasNull())
request.writer.writePercent(i);
return true;
case Types.REAL:
float f = d.getFloat(column_index);
if (!d.wasNull())
request.writer.writePercent(f);
return true;
}
return false;
}
use of db.Rows in project common by zenlunatics.
the class Documents method writeItem.
// --------------------------------------------------------------------------
/**
* @throws IOException
*/
@Override
public void writeItem(int item_id, Request request) throws IOException {
FileColumn file_column = (FileColumn) request.site.getViewDef("documents", request.db).getColumn("filename");
Rows data = new Rows(request.db).select(new Select("*").from("documents").whereIdEquals(item_id));
if (data.next())
file_column.writeValue(data, request);
data.close();
}
Aggregations