Search in sources :

Example 71 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class MeetingColorRenderer method writeValue.

@Override
public void writeValue(View view, ColumnBase<?> column, Request request) throws IOException {
    int row = view.data().getRow() - 1;
    HTMLWriter writer = request.writer;
    writer.write("<span id=\"p");
    writer.write(row);
    writer.write("\"  style=\"border-left:12px solid;height:0px\" />");
    writer.js("$('p" + row + "').style.borderColor=meeting.getColor(" + row + ");");
}
Also used : HTMLWriter(web.HTMLWriter)

Example 72 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Minutes method doGet.

// --------------------------------------------------------------------------
@Override
public boolean doGet(Request request) throws IOException {
    if (super.doGet(request))
        return true;
    int minutes_id = request.getPathSegmentInt(1);
    HTMLWriter writer = request.writer;
    try {
        ResultSet rs = request.db.select(new Select("text").from(m_table).whereIdEquals(minutes_id));
        if (rs.next()) {
            String text = rs.getString(1);
            if (text != null)
                writer.write("<div id=\"c_\">").writeWithLinks(text).br().buttonIconOnClick("print", "open_print_window(this)").write("</div>");
        }
        rs.getStatement().close();
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
    View attachments = new View(request.site.getViewDef(m_table + "_attachments", request.db), request);
    ColumnBase<?> column = attachments.getColumn("filename");
    attachments.select(new Select("*").from(m_table + "_attachments").where(m_table + "_id=" + minutes_id));
    if (attachments.data().isBeforeFirst()) {
        writer.hr().h4("Attachments");
        while (attachments.next()) {
            column.writeValue(attachments, null, request);
            writer.br();
        }
        writer.br();
    }
    Comments.writeComments(m_table, minutes_id, request);
    return true;
}
Also used : HTMLWriter(web.HTMLWriter) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) Select(db.Select) View(db.View)

Example 73 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Task method writeForm.

// --------------------------------------------------------------------------
private void writeForm(String view_def_name, String id, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.formOpen("POST", request.getContext() + "/db");
    writer.hiddenInput("db_task", m_name);
    writer.hiddenInput("db_view_def", view_def_name);
    writer.hiddenInput("db_key_value", id);
    writeFields(writer);
    writer.tagClose();
}
Also used : HTMLWriter(web.HTMLWriter)

Example 74 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class View method getColumnHTML.

// --------------------------------------------------------------------------
public String getColumnHTML(String column) {
    HTMLWriter save_writer = m_writer;
    HTMLWriter new_writer = m_writer.stringWriter();
    new_writer.setDateTimeFormatter(m_request.date_time_formatter);
    m_writer = new_writer;
    m_request.writer = new_writer;
    try {
        writeColumnHTML(column);
    } catch (IOException e) {
        m_request.abort(e);
    }
    m_writer = save_writer;
    m_request.writer = save_writer;
    return new_writer.getWriter().toString();
}
Also used : HTMLWriter(web.HTMLWriter) IOException(java.io.IOException)

Example 75 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class YearFilter method write.

// --------------------------------------------------------------------------
@Override
public String write(View view, Request request) throws IOException {
    int this_year = request.site.newCalendar().get(Calendar.YEAR);
    int year = this_year;
    String filter = view.getState().filter;
    if (filter != null) {
        int index = filter.indexOf("extract(year from date)='");
        if (index != -1 && filter.length() >= index + 29)
            year = Integer.parseInt(filter.substring(index + 25, index + 29));
    }
    int earliest_year = request.db.lookupInt("extract(year from min(date))", m_table, view.getState().getBaseFilter(), this_year);
    if (// postgres returns an answer even if there's no records
    earliest_year == 0)
        earliest_year = this_year;
    int latest_year = request.db.lookupInt("extract(year from max(date))", m_table, view.getState().getBaseFilter(), this_year);
    if (// postgres returns an answer even if there's no records
    latest_year == 0)
        latest_year = this_year;
    HTMLWriter writer = request.writer;
    String id = UUID.randomUUID().toString();
    writer.setAttribute("id", id);
    writer.setAttribute("class", "form-control");
    writer.setAttribute("style", "display:inline;font-size:inherit;height:inherit;width:inherit;");
    writer.tagOpen("select");
    for (int i = earliest_year; i <= latest_year; i++) {
        writer.write("<option");
        if (i == year)
            writer.write(" selected=\"selected\"");
        writer.write(">").write(i).write("</option>");
    }
    writer.tagClose();
    return id;
}
Also used : HTMLWriter(web.HTMLWriter)

Aggregations

HTMLWriter (web.HTMLWriter)109 Select (db.Select)18 SQLException (java.sql.SQLException)16 ResultSet (java.sql.ResultSet)14 Table (web.Table)12 JDBCTable (db.JDBCTable)10 Person (app.Person)7 Calendar (java.util.Calendar)7 ArrayList (java.util.ArrayList)6 JDBCColumn (db.JDBCColumn)5 View (db.View)5 DBObject (db.DBObject)4 Form (db.Form)4 File (java.io.File)4 AdminTask (web.AdminTask)4 FilePathStringBuilder (web.FilePathStringBuilder)4 Select (web.Select)4 Mode (db.View.Mode)3 IOException (java.io.IOException)3 NumberFormat (java.text.NumberFormat)3