Search in sources :

Example 1 with URLStringBuilder

use of web.URLStringBuilder in project common by zenlunatics.

the class Form method close.

// --------------------------------------------------------------------------
@Override
public void close() throws IOException {
    m_writer.tagClose();
    if (m_tabs != null)
        m_tabs.close();
    if (m_mode != View.Mode.READ_ONLY_FORM && m_buttons_location == Location.BOTTOM) {
        m_writer.write("<div style=\"text-align:center;\">");
        writeSubmit();
        m_writer.write("</div>");
    }
    if (m_mode == View.Mode.EDIT_FORM && !m_printer_friendly)
        if (m_view_def.m_tasks != null)
            for (Task task : m_view_def.m_tasks.values()) {
                m_writer.write("<div style=\"padding-left:10px;padding-right:10px\">");
                task.write(m_view_def.getName(), m_request.getParameter("db_key_value"), m_request);
                m_writer.write("</div>");
            }
    if (m_view_def.repeatHeadAtBottom())
        writeHead();
    m_writer.tagClose();
    m_writer.write("</form>");
    if (m_view_def.showPrintLinkForm() && (m_mode == View.Mode.EDIT_FORM || m_mode == View.Mode.READ_ONLY_FORM) && !m_printer_friendly) {
        m_writer.write("<tr><td style=\"padding:5px\"><p>");
        URLStringBuilder url = m_view_def.getURL(m_request);
        url.append("/print");
        url.set("db_mode", m_mode);
        m_writer.setAttribute("title", "view form for printing");
        m_writer.buttonIconOnClick("print", "window.open('" + url.toString() + "','','')");
        m_writer.write("</p></td></tr>");
    }
    if (m_view_def.m_form_hooks != null)
        for (FormHook form_hook : m_view_def.m_form_hooks) form_hook.after(m_view, m_mode, m_printer_friendly, m_request);
    m_writer.write("</div></div>");
    m_writer.tagClose();
}
Also used : URLStringBuilder(web.URLStringBuilder)

Example 2 with URLStringBuilder

use of web.URLStringBuilder in project common by zenlunatics.

the class View method getRowURL.

// --------------------------------------------------------------------------
private URLStringBuilder getRowURL(Mode mode) {
    URLStringBuilder url = new URLStringBuilder(m_request.getContext() + "/Views/");
    if (m_relationship == null && m_relationships.size() == 1 && m_relationships.get(0).sharesData())
        url.append(m_view_def.getFrom());
    else if (m_relationship != null && m_relationship.sharesData())
        url.append(getRoot().m_view_def.getFrom());
    else
        url.append(getRoot().m_view_def.getName());
    if (m_relationship != null)
        url.set("db_relationship", m_relationship.def.many_view_def_name);
    if (mode != Mode.ADD_FORM)
        url.set("db_key_value", m_state.key_value);
    return url;
}
Also used : URLStringBuilder(web.URLStringBuilder)

Example 3 with URLStringBuilder

use of web.URLStringBuilder in project common by zenlunatics.

the class View method componentOpen.

// --------------------------------------------------------------------------
public String componentOpen() throws IOException {
    URLStringBuilder url = new URLStringBuilder(m_request.getContext());
    url.append("/Views/");
    url.append(getRoot().m_view_def.getName());
    if (m_relationship != null)
        url.set("db_relationship", m_relationship.def.many_view_def_name);
    url.set("db_mode", m_mode.toString());
    if (m_view_def.center())
        m_writer.setAttribute("style", "display:table;margin:0 auto;");
    m_id = m_writer.componentOpen(url.toString(), m_view_def.showDoneLink() ? "done" : m_view_def.getRecordNamePlural().toLowerCase());
    return m_id;
}
Also used : URLStringBuilder(web.URLStringBuilder)

Example 4 with URLStringBuilder

use of web.URLStringBuilder in project common by zenlunatics.

the class LinkValueRenderer method writeValue.

// --------------------------------------------------------------------------
@Override
public void writeValue(View view, ColumnBase<?> column, Request request) throws IOException {
    if (m_show_if_set_column != null && !view.data().getBoolean(m_show_if_set_column))
        return;
    String text;
    if (m_text != null)
        text = m_text;
    else if (m_text_column != null)
        text = view.data().getString(m_text_column);
    else
        text = view.data().getString(column.getName());
    if (view.isPrinterFriendly()) {
        request.writer.write(text);
        return;
    }
    String on_click_before = m_on_click_before;
    String on_click_after = m_on_click_after;
    String href;
    if (m_names != null) {
        URLStringBuilder url = new URLStringBuilder(m_url_base);
        for (int i = 0; i < m_names.length; i++) url.set(m_names[i], view.data().getString(m_value_columns[i]));
        href = url.toString();
    } else {
        href = view.data().getString(m_href_column == null ? column.getName() : m_href_column);
        if (href.length() == 0)
            return;
        StringBuilder url = new StringBuilder();
        if (m_url_base != null)
            url.append(m_url_base);
        else if (href.length() > 0 && !(href.startsWith("http://") || href.startsWith("https://")) && m_on_click_before == null)
            url.append(request.getContext());
        if (m_dir_column != null) {
            if (url.length() > 0 && url.charAt(url.length() - 1) != '/')
                url.append('/');
            url.append(view.data().getString(m_dir_column));
            url.append('/');
        }
        if (href.length() > 0) {
            if (!(href.startsWith("http://") || href.startsWith("https://")) && Util.fileIsViewable(href)) {
                on_click_before = "new Dialog({url:'";
                on_click_after = "',title:'" + text + "'})";
            }
            url.append(href);
            href = url.toString();
        }
    }
    if (m_text_column != null && (text == null || text.length() == 0) && !href.equals(""))
        text = m_text_column;
    if (on_click_before == null) {
        if (m_target != null)
            request.writer.setAttribute("target", m_target);
        if (m_value_renderer != null) {
            request.writer.aOpen(href);
            m_value_renderer.writeValue(view, column, request);
            request.writer.tagClose();
        } else
            request.writer.a(text, href);
    } else {
        String on_click = getTemplateString(on_click_before, view) + href + getTemplateString(on_click_after, view);
        if (m_value_renderer != null) {
            request.writer.aOnClickOpen(on_click);
            m_value_renderer.writeValue(view, column, request);
            request.writer.tagClose();
        } else
            request.writer.aOnClick(text, on_click);
    }
}
Also used : URLStringBuilder(web.URLStringBuilder) URLStringBuilder(web.URLStringBuilder)

Example 5 with URLStringBuilder

use of web.URLStringBuilder in project common by zenlunatics.

the class GridView method writeLinkOpen.

// --------------------------------------------------------------------------
private void writeLinkOpen(String file, int parent, int picture_id, Request request) throws IOException {
    String extension = file.substring(file.lastIndexOf('.') + 1).toLowerCase();
    if (extension.equals("jpg")) {
        if (m_use_xhr) {
            URLStringBuilder url = m_view_def.getURL(request);
            url.set("picture", picture_id);
            if (parent != -1)
                url.set("parent", parent);
            request.writer.aOnClickOpen("c_(this).go('" + url + "')");
        } else {
            URLStringBuilder url = request.getURL();
            url.set("parent", m_parent);
            url.set("picture", picture_id);
            request.writer.aOnClickOpen("document.location.href='" + url.toString() + "'");
        }
    } else
        request.writer.aOpen(m_path + "/" + file);
}
Also used : URLStringBuilder(web.URLStringBuilder)

Aggregations

URLStringBuilder (web.URLStringBuilder)8 AccessPolicy (db.access.AccessPolicy)1 RecordOwnerAccessPolicy (db.access.RecordOwnerAccessPolicy)1