Search in sources :

Example 51 with FacesContext

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

the class LoginBean method getTeamLoginWarningHTML.

/**
 * Returns the HTML to display if the system is in TEAM mode
 *
 * @return The HTML to display
 */
public String getTeamLoginWarningHTML() {
    FacesContext context = FacesContext.getCurrentInstance();
    String contextPath = context.getExternalContext().getRequestContextPath();
    StringBuilder html = new StringBuilder();
    try {
        html.append("<tr><td colspan='2'>");
        StringWriter writer = new StringWriter();
        PanelGenerator.generatePanelStart(writer, contextPath, "yellowInner", "#ffffcc");
        html.append(writer.toString());
        html.append("<table cellpadding='0' cellspacing='0' border='0' width='100%'>");
        html.append("<tr><td valign='top' style='padding-top: 2px' width='20'>");
        html.append("<img src='");
        html.append(contextPath);
        html.append("/images/icons/warning.gif' width='16' height='16' /></td>");
        html.append("<td width='180' class='statusErrorText'>");
        html.append(Application.getMessage(context, "team_login_warning"));
        html.append("</td></tr></table>");
        writer = new StringWriter();
        PanelGenerator.generatePanelEnd(writer, contextPath, "yellowInner");
        html.append(writer.toString());
        html.append("</td></tr>");
    } catch (IOException ioe) {
        logger.error(ioe);
    }
    return html.toString();
}
Also used : FacesContext(javax.faces.context.FacesContext) StringWriter(java.io.StringWriter) IOException(java.io.IOException)

Example 52 with FacesContext

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

the class NavigationBean method toolbarLocationChanged.

/**
 * Action to change the toolbar location
 * Currently this will changed the location from Company to the users Home space
 */
public void toolbarLocationChanged(ActionEvent event) {
    FacesContext context = FacesContext.getCurrentInstance();
    try {
        UIModeList locationList = (UIModeList) event.getComponent();
        String location = locationList.getValue().toString();
        processToolbarLocation(location, true);
    } catch (InvalidNodeRefException refErr) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NOHOME), Application.getCurrentUser(context).getHomeSpaceId()), refErr);
    } catch (Exception err) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UIModeList(org.alfresco.web.ui.common.component.UIModeList) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 53 with FacesContext

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

the class NavigationBean method getCompanyHomeNode.

/**
 * @return Node representing the Company Home folder
 */
public Node getCompanyHomeNode() {
    if (this.companyHomeNode == null) {
        FacesContext fc = FacesContext.getCurrentInstance();
        String companyRootId = Application.getCompanyRootId(fc);
        if (companyRootId != null) {
            NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), companyRootId);
            this.companyHomeNode = new Node(companyRootRef);
        }
    }
    return this.companyHomeNode;
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Node(org.alfresco.web.bean.repository.Node)

Example 54 with FacesContext

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

the class NavigationBean method getGuestHomeNode.

/**
 * @return Node representing the Guest Home Space folder
 */
public Node getGuestHomeNode() {
    if (this.guestHomeNode == null) {
        try {
            FacesContext fc = FacesContext.getCurrentInstance();
            String xpath = Application.getRootPath(fc) + "/" + Application.getGuestHomeFolderName(fc);
            List<NodeRef> guestHomeRefs = this.getSearchService().selectNodes(this.getNodeService().getRootNode(Repository.getStoreRef()), xpath, null, this.getNamespaceService(), false);
            if (guestHomeRefs.size() == 1) {
                this.guestHomeNode = new Node(guestHomeRefs.get(0));
            }
        } catch (InvalidNodeRefException err1) {
        // cannot continue if this occurs
        } catch (AccessDeniedException err2) {
        // cannot see node if this occurs
        }
    }
    return this.guestHomeNode;
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 55 with FacesContext

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

the class SidebarBean method getPlugins.

// ------------------------------------------------------------------------------
// Bean Getters and Setters
/**
 * Returns a list of configured plugins
 *
 * @return List of UIListItem's representing the plugins available
 */
public List<UIListItem> getPlugins() {
    if (this.plugins == null) {
        FacesContext context = FacesContext.getCurrentInstance();
        this.plugins = new ArrayList<UIListItem>();
        // create a list entry for each configured plugin
        for (String pluginId : this.sidebarConfig.getPlugins().keySet()) {
            SidebarPluginConfig plugin = this.sidebarConfig.getPlugin(pluginId);
            // resolve the label for the plugin
            String label = plugin.getlabelId();
            if (label != null) {
                label = Application.getMessage(context, label);
            }
            if (label == null) {
                label = plugin.getlabel();
            }
            if (label == null) {
                label = plugin.getId();
            }
            // resolve the description (tooltip for the plugin)
            String tooltip = plugin.getDescriptionId();
            if (tooltip != null) {
                tooltip = Application.getMessage(context, tooltip);
            }
            if (tooltip == null) {
                tooltip = plugin.getDescription();
            }
            UIListItem item = new UIListItem();
            item.setValue(plugin.getId());
            item.setLabel(label);
            if (tooltip != null) {
                item.setTooltip(tooltip);
            }
            this.plugins.add(item);
        }
    }
    return this.plugins;
}
Also used : SidebarPluginConfig(org.alfresco.web.config.SidebarConfigElement.SidebarPluginConfig) FacesContext(javax.faces.context.FacesContext) UIListItem(org.alfresco.web.ui.common.component.UIListItem)

Aggregations

FacesContext (javax.faces.context.FacesContext)361 NodeRef (org.alfresco.service.cmr.repository.NodeRef)61 Node (org.alfresco.web.bean.repository.Node)44 UserTransaction (javax.transaction.UserTransaction)43 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)28 IOException (java.io.IOException)27 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)27 ExternalContext (javax.faces.context.ExternalContext)26 SelectItem (javax.faces.model.SelectItem)26 QName (org.alfresco.service.namespace.QName)25 FacesMessage (javax.faces.application.FacesMessage)24 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 Map (java.util.Map)21 ResourceBundle (java.util.ResourceBundle)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)19 MapNode (org.alfresco.web.bean.repository.MapNode)18 UIViewRoot (javax.faces.component.UIViewRoot)17 HttpServletRequest (javax.servlet.http.HttpServletRequest)16 Serializable (java.io.Serializable)15