Search in sources :

Example 16 with ResponseWriter

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

the class UINodeWorkflowInfo method encodeBegin.

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    // get the node to display the information for
    Node node = getValue();
    if (node != null) {
        // get the services we need
        NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
        DictionaryService ddService = Repository.getServiceRegistry(context).getDictionaryService();
        WorkflowService workflowService = Repository.getServiceRegistry(context).getWorkflowService();
        ResponseWriter out = context.getResponseWriter();
        ResourceBundle bundle = Application.getBundle(context);
        // render simple workflow info
        renderSimpleWorkflowInfo(context, node, nodeService, ddService, out, bundle);
        // render advanced workflow info
        renderAdvancedWorkflowInfo(context, node, nodeService, ddService, workflowService, out, bundle);
    }
}
Also used : DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) ResponseWriter(javax.faces.context.ResponseWriter) Node(org.alfresco.web.bean.repository.Node) NodeService(org.alfresco.service.cmr.repository.NodeService) ResourceBundle(java.util.ResourceBundle)

Example 17 with ResponseWriter

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

the class UISearchCustomProperties method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    if (getChildCount() == 0) {
        createComponentsFromConfig(context);
    }
    // encode the components in a 3 column table
    out.write("<table cellspacing=2 cellpadding=2 border=0");
    outputAttribute(out, getAttributes().get("styleClass"), "class");
    outputAttribute(out, getAttributes().get("style"), "style");
    out.write('>');
    List<UIComponent> children = getChildren();
    int colCounter = 0;
    for (int i = 0; i < children.size(); i++) {
        UIComponent component = children.get(i);
        if (component instanceof UIPanel) {
            out.write("<tr><td colspan=3>");
            Utils.encodeRecursive(context, component);
            out.write("</td></tr>");
            colCounter += 3;
        } else {
            if ((colCounter % 3) == 0) {
                out.write("<tr>");
            }
            out.write("<td>");
            Utils.encodeRecursive(context, component);
            out.write("</td>");
            if ((colCounter % 3) == 2) {
                out.write("</tr>");
            }
            colCounter++;
        }
    }
    out.write("</table>");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) Constraint(org.alfresco.service.cmr.dictionary.Constraint) ListOfValuesConstraint(org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint)

Example 18 with ResponseWriter

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

the class UISidebar method encodeBegin.

@SuppressWarnings("unchecked")
@Override
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    ResponseWriter out = context.getResponseWriter();
    out.write("<div id='sidebar' class='sidebar'>");
    // render the start of the header panel
    String cxPath = context.getExternalContext().getRequestContextPath();
    out.write("<table cellspacing='0' cellpadding='0' style='background-color: #ffffff;' width='100%'>" + "<tr valign='top'><td width='20%'><table cellspacing='0' cellpadding='0' width='100%'>" + "<tr><td style='width: 5px; background-image: url(");
    out.write(cxPath);
    out.write("/images/parts/sidebar_top_grey_begin.gif)' valign='top'>" + "<img src=\"");
    out.write(cxPath);
    out.write("/images/parts/sidebar_grey_01.gif\" width='5' height='5' alt=''></td>" + "<td style='height: 24px; background-image: url(");
    out.write(cxPath);
    out.write("/images/parts/sidebar_top_grey_bg.gif)'>");
    // generate the required child components if not present
    if (this.getChildCount() == 1) {
        // create the mode list component
        UIModeList modeList = (UIModeList) context.getApplication().createComponent("org.alfresco.faces.ModeList");
        modeList.setId("sidebarPluginList");
        modeList.setValue(this.getActivePlugin());
        modeList.setIconColumnWidth(2);
        modeList.setMenu(true);
        modeList.setMenuImage("/images/icons/menu.gif");
        modeList.getAttributes().put("itemSpacing", 4);
        modeList.getAttributes().put("styleClass", "moreActionsMenu");
        modeList.getAttributes().put("selectedStyleClass", "statusListHighlight");
        MethodBinding listener = context.getApplication().createMethodBinding("#{SidebarBean.pluginChanged}", new Class[] { ActionEvent.class });
        modeList.setActionListener(listener);
        // create the child list items component
        UIListItems items = (UIListItems) context.getApplication().createComponent("org.alfresco.faces.ListItems");
        ValueBinding binding = context.getApplication().createValueBinding("#{SidebarBean.plugins}");
        items.setValueBinding("value", binding);
        // add the list items to the mode list component
        modeList.getChildren().add(items);
        // create the actions component
        UIActions actions = (UIActions) context.getApplication().createComponent("org.alfresco.faces.Actions");
        actions.setId("sidebarActions");
        actions.setShowLink(false);
        setupActionGroupId(context, actions);
        // add components to the sidebar
        this.getChildren().add(0, modeList);
        this.getChildren().add(1, actions);
    } else {
        // update the child UIActions component with the correct
        // action group id and clear it's current children
        UIActions actions = (UIActions) this.getChildren().get(1);
        actions.reset();
        setupActionGroupId(context, actions);
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ValueBinding(javax.faces.el.ValueBinding) UIListItems(org.alfresco.web.ui.common.component.UIListItems) UIModeList(org.alfresco.web.ui.common.component.UIModeList) MethodBinding(javax.faces.el.MethodBinding)

Example 19 with ResponseWriter

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

the class UISimpleSearch method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    ResourceBundle bundle = (ResourceBundle) Application.getBundle(context);
    // script for dynamic simple search menu drop-down options
    out.write("<script type='text/javascript'>");
    out.write("function _noenter(event) {" + "if (event && event.keyCode == 13) {" + "   _searchSubmit();return false; }" + "else {" + "   return true; } }");
    out.write("function _searchSubmit() {");
    out.write(Utils.generateFormSubmit(context, this, Utils.getActionHiddenFieldName(context, this), getClientId(context)));
    out.write("}");
    out.write("</script>");
    // outer table containing search drop-down icon, text box and search Go image button
    out.write("<table cellspacing='4' cellpadding='0'>");
    out.write("<tr><td style='padding-top:2px'>");
    String searchImage = Utils.buildImageTag(context, "/images/icons/search_icon.gif", 15, 15, bundle.getString(MSG_GO), "_searchSubmit();");
    out.write(Utils.buildImageTag(context, "/images/icons/search_controls.gif", 27, 13, bundle.getString(MSG_OPTIONS), "javascript:_toggleMenu(event, 'alfsearch_menu');"));
    // dynamic DIV area containing search options
    out.write("<br><div id='alfsearch_menu' style='position:absolute;display:none'>");
    out.write("<table border='0' class='moreActionsMenu' cellspacing='4' cellpadding='0'>");
    // output each option - setting the current one to CHECKED
    String optionFieldName = getClientId(context) + NamingContainer.SEPARATOR_CHAR + OPTION_PARAM;
    String radioOption = "<tr><td class='userInputForm' style='white-space:nowrap;'><input type='radio' name='" + optionFieldName + "'";
    out.write(radioOption);
    out.write(" value='0'");
    int searchMode = getSearchMode();
    if (searchMode == 0)
        out.write(" checked='checked'");
    out.write("/>" + bundle.getString(MSG_ALL_ITEMS) + "</td></tr>");
    out.write(radioOption);
    out.write(" value='1'");
    if (searchMode == 1)
        out.write(" checked='checked'");
    out.write("/>" + bundle.getString(MSG_FILE_NAMES_CONTENTS) + "</td></tr>");
    out.write(radioOption);
    out.write(" value='2'");
    if (searchMode == 2)
        out.write(" checked='checked'");
    out.write("/>" + bundle.getString(MSG_FILE_NAMES_ONLY) + "</td></tr>");
    out.write(radioOption);
    out.write(" value='3'");
    if (searchMode == 3)
        out.write(" checked='checked'");
    out.write("/>" + bundle.getString(MSG_SPACE_NAMES_ONLY) + "</td></tr>");
    // row with table containing advanced search link and Search Go button
    out.write("<tr><td><table width='100%'><tr><td>");
    // generate a link that will cause an action event to navigate to the advanced search screen
    out.write("<a class='small' href='#' onclick=\"");
    out.write(Utils.generateFormSubmit(context, this, Utils.getActionHiddenFieldName(context, this), ADVSEARCH_PARAM));
    out.write("\">");
    out.write(bundle.getString(MSG_ADVANCED_SEARCH));
    out.write("</a>");
    out.write("</td><td align='right'>");
    out.write(searchImage);
    out.write("</td></tr></table></td></tr>");
    out.write("</table></div>");
    // input text box
    out.write("</td><td>");
    out.write("<input name='");
    out.write(getClientId(context));
    // TODO: style and class from component properties!
    out.write("' onkeypress=\"return _noenter(event)\"");
    out.write(" type='text' maxlength='1024' style='width:130px;padding-top:3px;font-size:10px' value=\"");
    // output previous search text stored in this component!
    out.write(Utils.replace(getLastSearch(), "\"", "&quot;"));
    out.write("\">");
    // search Go image button
    out.write("</td><td>");
    out.write(searchImage);
    // end outer table
    out.write("</td></tr></table>");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ResourceBundle(java.util.ResourceBundle)

Example 20 with ResponseWriter

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

the class UIUserGroupPicker method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    ResourceBundle bundle = Application.getBundle(context);
    String clientId = getClientId(context);
    // start outer table
    out.write("<table width=100% border=0 cellspacing=0 cellpadding=0 class='userGroupPickerList'>");
    // get the data that represents the users/groups to display
    List<Map> userGroups = (List<Map>) getValue();
    if (userGroups != null) {
        for (Map authority : userGroups) {
            String authorityId = (String) authority.get("id");
            out.write("<tr><td width=100%><table width=100% border=0 cellspacing=3 cellpadding=0><tr>");
            // walk parent hierarchy to calculate width of this cell
            int width = 16;
            Map parent = (Map) authority.get("parent");
            while (parent != null) {
                width += 16;
                parent = (Map) parent.get("parent");
            }
            out.write("<td width=");
            out.write(Integer.toString(width));
            out.write(" align=right>");
            // output expanded/collapsed icon if authority is a group
            boolean expanded = false;
            boolean isGroup = (Boolean) authority.get("isGroup");
            if (isGroup) {
                // either output the expanded or collapsed selectable widget
                expanded = (Boolean) authority.get("expanded");
                String image = expanded ? WebResources.IMAGE_EXPANDED : WebResources.IMAGE_COLLAPSED;
                out.write(Utils.buildImageTag(context, image, 11, 11, "", generateFormSubmit(context, ACTION_EXPANDCOLLAPSE, authorityId)));
            }
            out.write("</td><td width=16>");
            // output selected checkbox if not expanded and not a duplicate
            boolean duplicate = (Boolean) authority.get("duplicate");
            if (duplicate == false && (isGroup == false || expanded == false)) {
                boolean selected = (Boolean) authority.get("selected");
                out.write("<input type='checkbox' value='' name='");
                out.write(clientId + NamingContainer.SEPARATOR_CHAR + SELECTED_AUTHORITY);
                out.write("' onclick=\"");
                out.write(generateFormSubmit(context, ACTION_SELECT, authorityId));
                out.write('"');
                if (selected) {
                    out.write(" CHECKED");
                }
                out.write('>');
            }
            out.write("</td><td width=16>");
            // output icon
            out.write(Utils.buildImageTag(context, (String) authority.get("icon"), 16, 16, ""));
            out.write("</td><td>");
            // output textual information
            if (duplicate) {
                out.write("<span style='color:#93a8b2'>");
            }
            out.write(Utils.encode((String) authority.get("fullName")));
            out.write(" (");
            out.write((String) authority.get("roles"));
            out.write(")");
            if (duplicate) {
                out.write("</span>");
            }
            out.write("</td>");
            out.write("</tr></table></td></tr>");
        }
    }
    out.write("</table>");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ResourceBundle(java.util.ResourceBundle) List(java.util.List) Map(java.util.Map)

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