Search in sources :

Example 51 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UISidebar method encodeEnd.

@Override
public void encodeEnd(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    // render the end of the panel
    ResponseWriter out = context.getResponseWriter();
    String cxPath = context.getExternalContext().getRequestContextPath();
    out.write("</td></tr>" + "</table><table cellspacing='0' cellpadding='0' width='100%'>" + "<tr><td style='height: 12px; width: 5px;'><img src='");
    out.write(cxPath);
    out.write("/images/parts/sidebar_bottom_grey_begin.gif' width='5' height='12' alt=''></td>" + "<td style='width: 100%; background-image: url(");
    out.write(cxPath);
    out.write("/images/parts/sidebar_bottom_grey_bg.gif)'>" + "<img src='");
    out.write(cxPath);
    out.write("/images/parts/sidebar_bottom_grey_bg.gif' width='48' height='12' alt=''></td>" + "<td align='right' style='width: 5px;'><img src='");
    out.write(cxPath);
    out.write("/images/parts/sidebar_bottom_grey_end.gif' width='5' height='12' alt=''></td></tr>" + "</table></td></tr></table>" + "</div>");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Example 52 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UISidebar method encodeChildren.

@Override
public void encodeChildren(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    if (getChildren().size() == 3) {
        ResponseWriter out = context.getResponseWriter();
        out.write("<table border='0' cellpadding='6' cellspacing='0' width='100%;'><tr><td>");
        // render the list
        UIModeList modeList = (UIModeList) getChildren().get(0);
        Utils.encodeRecursive(context, modeList);
        out.write("</td><td align='right'>");
        // render the actions
        UIActions actions = (UIActions) getChildren().get(1);
        Utils.encodeRecursive(context, actions);
        out.write("</td></tr></table>");
        // render the end of the header panel
        String cxPath = context.getExternalContext().getRequestContextPath();
        out.write("</td><td style='width: 5px; background-image: url(");
        out.write(cxPath);
        out.write("/images/parts/sidebar_top_grey_end.gif)' align='right' valign='top'>" + "<img src='");
        out.write(cxPath);
        out.write("/images/parts/sidebar_grey_03.gif' width='5' height='5' alt=''></td></tr>" + "</table><table cellspacing='0' cellpadding='0' width='100%'>" + "<tr><td width='100%' id='pluginBox'>");
        // render the plugin
        UIComponent plugin = (UIComponent) getChildren().get(2);
        Utils.encodeRecursive(context, plugin);
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) UIComponent(javax.faces.component.UIComponent) UIModeList(org.alfresco.web.ui.common.component.UIModeList)

Example 53 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIWorkflowHistory method encodeBegin.

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    WorkflowInstance wi = getValue();
    if (wi != null) {
        ResponseWriter out = context.getResponseWriter();
        ResourceBundle bundle = Application.getBundle(context);
        if (logger.isDebugEnabled())
            logger.debug("Retrieving workflow history for workflow instance: " + wi);
        WorkflowTaskQuery query = new WorkflowTaskQuery();
        query.setActive(null);
        query.setProcessId(wi.id);
        query.setTaskState(WorkflowTaskState.COMPLETED);
        query.setOrderBy(new WorkflowTaskQuery.OrderBy[] { WorkflowTaskQuery.OrderBy.TaskCreated_Desc, WorkflowTaskQuery.OrderBy.TaskActor_Asc });
        List<WorkflowTask> tasks = Repository.getServiceRegistry(context).getWorkflowService().queryTasks(query);
        if (tasks.size() == 0) {
            out.write("<div style='margin-left:18px;margin-top: 6px;'>");
            out.write(bundle.getString(MSG_NO_HISTORY));
            out.write("</div>");
        } else {
            // output surrounding table and style if necessary
            out.write("<table cellspacing='2' cellpadding='1' border='0'");
            if (this.getAttributes().get("style") != null) {
                out.write(" style=\"");
                out.write((String) this.getAttributes().get("style"));
                out.write("\"");
            }
            if (this.getAttributes().get("styleClass") != null) {
                out.write(" class=\"");
                out.write((String) this.getAttributes().get("styleClass"));
                out.write("\"");
            }
            out.write(">");
            // output a header row
            out.write("<tr align=left><th>");
            out.write(bundle.getString(MSG_DESCRIPTION));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_TASK));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_ID));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_CREATED));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_ASSIGNEE));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_COMMENT));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_DATE_COMPLETED));
            out.write("</th><th>");
            out.write(bundle.getString(MSG_OUTCOME));
            out.write("</th></tr>");
            // output a row for each previous completed task
            for (WorkflowTask task : tasks) {
                String id = null;
                Serializable idObject = task.properties.get(WorkflowModel.PROP_TASK_ID);
                if (idObject instanceof Long) {
                    id = ((Long) idObject).toString();
                } else {
                    id = idObject.toString();
                }
                String desc = (String) task.properties.get(WorkflowModel.PROP_DESCRIPTION);
                Date createdDate = (Date) task.properties.get(ContentModel.PROP_CREATED);
                String owner = (String) task.properties.get(ContentModel.PROP_OWNER);
                String comment = (String) task.properties.get(WorkflowModel.PROP_COMMENT);
                Date completedDate = (Date) task.properties.get(WorkflowModel.PROP_COMPLETION_DATE);
                String transition = (String) task.properties.get(WorkflowModel.PROP_OUTCOME);
                String outcome = "";
                if (transition != null) {
                    WorkflowTransition[] transitions = task.definition.node.transitions;
                    for (WorkflowTransition trans : transitions) {
                        if (trans.id.equals(transition)) {
                            outcome = trans.title;
                            break;
                        }
                    }
                }
                if ((outcome == null || outcome.equals("")) && transition != null) {
                    // it's possible in Activiti to have tasks without an outcome set,
                    // in this case default to the transition, if there is one.
                    outcome = transition;
                }
                // ACE-1154
                if (outcome.equals("")) {
                    outcome = I18NUtil.getMessage(DEFAULT_TRANSITION_TITLE);
                }
                out.write("<tr><td>");
                out.write(desc == null ? "" : Utils.encode(desc));
                out.write("</td><td>");
                out.write(Utils.encode(task.title));
                out.write("</td><td>");
                out.write(id);
                out.write("</td><td>");
                out.write(Utils.getDateTimeFormat(context).format(createdDate));
                out.write("</td><td>");
                out.write(owner == null ? "" : owner);
                out.write("</td><td>");
                out.write(comment == null ? "" : Utils.encode(comment));
                out.write("</td><td>");
                out.write(Utils.getDateTimeFormat(context).format(completedDate));
                out.write("</td><td>");
                out.write(outcome);
                out.write("</td></tr>");
            }
            // output the end of the table
            out.write("</table>");
        }
    }
}
Also used : Serializable(java.io.Serializable) ResponseWriter(javax.faces.context.ResponseWriter) WorkflowTransition(org.alfresco.service.cmr.workflow.WorkflowTransition) ResourceBundle(java.util.ResourceBundle) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) WorkflowInstance(org.alfresco.service.cmr.workflow.WorkflowInstance) Date(java.util.Date) WorkflowTaskQuery(org.alfresco.service.cmr.workflow.WorkflowTaskQuery)

Example 54 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIWorkflowSummary method encodeBegin.

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    WorkflowInstance wi = getValue();
    if (wi != null) {
        ResponseWriter out = context.getResponseWriter();
        ResourceBundle bundle = Application.getBundle(context);
        // output surrounding table and style if necessary
        out.write("<table");
        if (this.getAttributes().get("style") != null) {
            out.write(" style=\"");
            out.write((String) this.getAttributes().get("style"));
            out.write("\"");
        }
        if (this.getAttributes().get("styleClass") != null) {
            out.write(" class=\"");
            out.write((String) this.getAttributes().get("styleClass"));
            out.write("\"");
        }
        out.write(">");
        // output the title and description
        out.write("<tr><td>");
        out.write(bundle.getString("title"));
        out.write(":</td><td>");
        out.write(wi.definition.title);
        if (wi.definition.description != null && wi.definition.description.length() > 0) {
            out.write("&nbsp;(");
            out.write(Utils.encode(wi.definition.description));
            out.write(")");
        }
        out.write("</td></tr><tr><td>");
        out.write(bundle.getString("initiated_by"));
        out.write(":</td><td>");
        NodeService nodeService = getNodeService(context);
        if (wi.initiator != null) {
            if (nodeService.exists(wi.initiator)) {
                out.write(Utils.encode(User.getFullName(Repository.getServiceRegistry(context).getNodeService(), wi.initiator)));
            } else {
                out.write("&lt;");
                out.write(bundle.getString("unknown"));
                out.write("&gt;");
            }
        }
        out.write("</td></tr><tr><td>");
        out.write(bundle.getString("started_on"));
        out.write(":</td><td>");
        if (wi.startDate != null) {
            out.write(Utils.getDateFormat(context).format(wi.startDate));
        }
        out.write("</td></tr><tr><td>");
        out.write(bundle.getString("completed_on"));
        out.write(":</td><td>");
        if (wi.endDate != null) {
            out.write(Utils.getDateFormat(context).format(wi.endDate));
        } else {
            out.write("&lt;");
            out.write(bundle.getString("in_progress"));
            out.write("&gt;");
        }
        out.write("</td></tr></table>");
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) NodeService(org.alfresco.service.cmr.repository.NodeService) ResourceBundle(java.util.ResourceBundle) WorkflowInstance(org.alfresco.service.cmr.workflow.WorkflowInstance)

Example 55 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIContentSelector method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    // get the child associations currently on the node and any that have been added
    NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
    if (isDisabled()) {
    // TODO: if the component is disabled just show the current value as text
    } else {
        // start outer table
        out.write("<table border='0' cellspacing='4' cellpadding='0' class='");
        if (this.getAttributes().get("styleClass") != null) {
            out.write((String) this.getAttributes().get("styleClass"));
        } else {
            out.write("selector");
        }
        out.write("'");
        if (this.getAttributes().get("style") != null) {
            out.write(" style='");
            out.write((String) this.getAttributes().get("style"));
            out.write("'");
        }
        out.write(">");
        // show the search field
        out.write("<tr><td colspan='2'><input type='text' maxlength='1024' size='32' name='");
        out.write(getClientId(context) + FIELD_CONTAINS);
        out.write("'/>&nbsp;&nbsp;<input type='submit' value='");
        out.write(Application.getMessage(context, MSG_SEARCH));
        out.write("' onclick=\"");
        out.write(generateFormSubmit(context, ACTION_SEARCH));
        out.write("\"/></td></tr>");
        // show available options i.e. all content in repository
        renderAvailableOptions(context, out, nodeService);
        // close table
        out.write("</table>");
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) NodeService(org.alfresco.service.cmr.repository.NodeService)

Aggregations

ResponseWriter (javax.faces.context.ResponseWriter)88 Map (java.util.Map)16 UIComponent (javax.faces.component.UIComponent)14 FacesContext (javax.faces.context.FacesContext)14 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 ResourceBundle (java.util.ResourceBundle)10 NodeService (org.alfresco.service.cmr.repository.NodeService)10 Iterator (java.util.Iterator)9 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 List (java.util.List)7 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)5 UserTransaction (javax.transaction.UserTransaction)5 UIModeList (org.alfresco.web.ui.common.component.UIModeList)5 Serializable (java.io.Serializable)4 Node (org.alfresco.web.bean.repository.Node)4 QuickSort (org.alfresco.web.data.QuickSort)3 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3