Search in sources :

Example 1 with Rows

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();
    }
}
Also used : HTMLWriter(web.HTMLWriter) Rows(db.Rows)

Example 2 with Rows

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);
}
Also used : Time(java.sql.Time) Timestamp(java.sql.Timestamp) Date(java.util.Date) Rows(db.Rows)

Example 3 with Rows

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;
}
Also used : Rows(db.Rows)

Example 4 with Rows

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;
}
Also used : Rows(db.Rows)

Example 5 with Rows

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();
}
Also used : Select(db.Select) FileColumn(db.column.FileColumn) Rows(db.Rows)

Aggregations

Rows (db.Rows)8 Select (db.Select)3 FileColumn (db.column.FileColumn)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Time (java.sql.Time)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 HTMLWriter (web.HTMLWriter)1 Head (web.Head)1