diff --git a/source/java/org/alfresco/web/app/servlet/FacesHelper.java b/source/java/org/alfresco/web/app/servlet/FacesHelper.java index a22d97a15c..9c43e05f74 100644 --- a/source/java/org/alfresco/web/app/servlet/FacesHelper.java +++ b/source/java/org/alfresco/web/app/servlet/FacesHelper.java @@ -74,7 +74,22 @@ public final class FacesHelper */ public static FacesContext getFacesContext(ServletRequest request, ServletResponse response, ServletContext context) { - return getFacesContextImpl(request, response, context); + return getFacesContextImpl(request, response, context, null); + } + + /** + * Return a valid FacesContext for the specific context, request and response. + * The FacesContext can be constructor for Servlet use. + * + * @param context ServletContext + * @param request ServletRequest + * @param response ServletReponse + * + * @return FacesContext + */ + public static FacesContext getFacesContext(ServletRequest request, ServletResponse response, ServletContext context, String viewRoot) + { + return getFacesContextImpl(request, response, context, viewRoot); } /** @@ -89,7 +104,7 @@ public final class FacesHelper */ public static FacesContext getFacesContext(PortletRequest request, PortletResponse response, PortletContext context) { - return getFacesContextImpl(request, response, context); + return getFacesContextImpl(request, response, context, null); } /** @@ -102,7 +117,7 @@ public final class FacesHelper * * @return FacesContext */ - private static FacesContext getFacesContextImpl(Object request, Object response, Object context) + private static FacesContext getFacesContextImpl(Object request, Object response, Object context, String viewRoot) { FacesContextFactory contextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); @@ -115,7 +130,11 @@ public final class FacesHelper InnerFacesContext.setFacesContextAsCurrent(facesContext); // set a new viewRoot, otherwise context.getViewRoot returns null - UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, "/jsp/close.jsp"); + if (viewRoot == null) + { + viewRoot = "/jsp/close.jsp"; + } + UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, viewRoot); facesContext.setViewRoot(view); return facesContext; diff --git a/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java b/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java index 5221175645..d11da9de90 100644 --- a/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java +++ b/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java @@ -66,6 +66,7 @@ public class UIActionCommandProcessor implements ExtCommandProcessor CommandFactory.getInstance().registerCommand("editwebcontent", EditWebContentCommand.class); CommandFactory.getInstance().registerCommand("managetask", ManageTaskDialogCommand.class); CommandFactory.getInstance().registerCommand("editcontentprops", EditContentPropertiesCommand.class); + CommandFactory.getInstance().registerCommand("userprofile", UserProfileDialogCommand.class); } diff --git a/source/java/org/alfresco/web/app/servlet/command/UserProfileDialogCommand.java b/source/java/org/alfresco/web/app/servlet/command/UserProfileDialogCommand.java new file mode 100644 index 0000000000..f79114d764 --- /dev/null +++ b/source/java/org/alfresco/web/app/servlet/command/UserProfileDialogCommand.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.web.app.servlet.command; + +import java.util.Map; + +import javax.faces.application.NavigationHandler; +import javax.faces.context.FacesContext; +import javax.servlet.ServletContext; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.util.ParameterCheck; +import org.alfresco.web.app.servlet.BaseServlet; +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.bean.users.UsersDialog; + +/** + * Command to execute the User Profile dialog via url. + *

+ * Arguments: id = of the Person to display the User Profile for. + * + * @author Kevin Roast + */ +public class UserProfileDialogCommand extends BaseUIActionCommand +{ + public static final String PROP_PERSONID = "id"; + + private static final String[] PROPERTIES = new String[] { + PROP_SERVLETCONTEXT, PROP_REQUEST, PROP_RESPONSE, PROP_PERSONID}; + + /** + * @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map) + */ + public Object execute(ServiceRegistry serviceRegistry, Map properties) + { + ServletContext sc = (ServletContext)properties.get(PROP_SERVLETCONTEXT); + ServletRequest req = (ServletRequest)properties.get(PROP_REQUEST); + ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE); + FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/browse/browse.jsp"); + UsersDialog dialog = (UsersDialog)FacesHelper.getManagedBean(fc, UsersDialog.BEAN_NAME); + + // setup dialog context from url args in properties map + String personId = (String)properties.get(PROP_PERSONID); + ParameterCheck.mandatoryString(PROP_PERSONID, personId); + + dialog.setupUserAction(personId); + + NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler(); + navigationHandler.handleNavigation(fc, null, "dialog:userProfile"); + String viewId = fc.getViewRoot().getViewId(); + try + { + sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res); + } + catch (Exception e) + { + throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e); + } + + return null; + } + + /** + * @see org.alfresco.web.app.servlet.command.Command#getPropertyNames() + */ + public String[] getPropertyNames() + { + return PROPERTIES; + } +} diff --git a/source/java/org/alfresco/web/bean/users/UsersDialog.java b/source/java/org/alfresco/web/bean/users/UsersDialog.java index 885ba1523d..91ccd2df1b 100644 --- a/source/java/org/alfresco/web/bean/users/UsersDialog.java +++ b/source/java/org/alfresco/web/bean/users/UsersDialog.java @@ -64,6 +64,8 @@ import org.apache.commons.logging.LogFactory; public class UsersDialog extends BaseDialogBean implements IContextListener { private static Log logger = LogFactory.getLog(UsersDialog.class); + + public static String BEAN_NAME = "UsersDialog"; public static final String ERROR_PASSWORD_MATCH = "error_password_match"; private static final String ERROR_DELETE = "error_delete_user"; @@ -157,16 +159,26 @@ public class UsersDialog extends BaseDialogBean implements IContextListener { UIActionLink link = (UIActionLink) event.getComponent(); Map params = link.getParameterMap(); - String id = params.get("id"); - if (id != null && id.length() != 0) + setupUserAction(params.get("id")); + } + + /** + * Called in preparation for actions that need to setup a Person context on + * the Users bean before an action page is called. + * + * @param personId + */ + public void setupUserAction(String personId) + { + if (personId != null && personId.length() != 0) { if (logger.isDebugEnabled()) - logger.debug("Setup for action, setting current Person to: " + id); + logger.debug("Setup for action, setting current Person to: " + personId); try { // create the node ref, then our node representation - NodeRef ref = new NodeRef(Repository.getStoreRef(), id); + NodeRef ref = new NodeRef(Repository.getStoreRef(), personId); Node node = new Node(ref); // remember the Person node @@ -179,7 +191,7 @@ public class UsersDialog extends BaseDialogBean implements IContextListener catch (InvalidNodeRefException refErr) { Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext - .getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id })); + .getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { personId })); } } else diff --git a/source/java/org/alfresco/web/ui/common/component/UIActionLink.java b/source/java/org/alfresco/web/ui/common/component/UIActionLink.java index 47e12a1d2d..1cf431b64d 100644 --- a/source/java/org/alfresco/web/ui/common/component/UIActionLink.java +++ b/source/java/org/alfresco/web/ui/common/component/UIActionLink.java @@ -73,6 +73,7 @@ public class UIActionLink extends UICommand this.href = (String)values[4]; this.tooltip = (String)values[5]; this.target = (String)values[6]; + this.verticalAlign = (String)values[7]; } /** @@ -89,7 +90,8 @@ public class UIActionLink extends UICommand this.showLink, this.href, this.tooltip, - this.target + this.target, + this.verticalAlign }; } @@ -276,6 +278,28 @@ public class UIActionLink extends UICommand this.target = target; } + /** + * @return the verticalAlign + */ + public String getVerticalAlign() + { + ValueBinding vb = getValueBinding("verticalAlign"); + if (vb != null) + { + this.verticalAlign = (String)vb.getValue(getFacesContext()); + } + + return this.verticalAlign; + } + + /** + * @param verticalAlign the verticalAlign to set + */ + public void setVerticalAlign(String verticalAlign) + { + this.verticalAlign = verticalAlign; + } + /** * Returns the onclick handler * @@ -327,6 +351,9 @@ public class UIActionLink extends UICommand /** the onclick handler */ private String onclick = null; + /** the vertical alignment value */ + private String verticalAlign = null; + /** Transient map of currently set param name/values pairs */ private Map params = null; } diff --git a/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java index 007ad1056b..d34f5ee8c5 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java @@ -142,7 +142,9 @@ public class ActionLinkRenderer extends BaseRenderer renderActionLinkAnchor(context, out, link); } - out.write(Utils.buildImageTag(context, image, (String)link.getValue(), "-4px")); + String verticalAlign = link.getVerticalAlign(); + out.write(Utils.buildImageTag( + context, image, (String)link.getValue(), verticalAlign == null ? "-4px" : verticalAlign)); if (link.getShowLink() == false) { diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 85f1a468e1..f8217cdd3a 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -551,7 +551,7 @@ - The bean that holds state for the Groups Management screens. + The bean that holds state for the User Management screens. UsersDialog org.alfresco.web.bean.users.UsersDialog diff --git a/source/web/jsp/dialog/container.jsp b/source/web/jsp/dialog/container.jsp index ed6ba6df77..b4ea534d50 100644 --- a/source/web/jsp/dialog/container.jsp +++ b/source/web/jsp/dialog/container.jsp @@ -146,12 +146,12 @@ <%-- Navigation --%> - - diff --git a/source/web/jsp/dialog/document-details.jsp b/source/web/jsp/dialog/document-details.jsp index 8461e13936..27214acd71 100644 --- a/source/web/jsp/dialog/document-details.jsp +++ b/source/web/jsp/dialog/document-details.jsp @@ -104,11 +104,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/dialog/filelink-details.jsp b/source/web/jsp/dialog/filelink-details.jsp index b758db2580..006c1f7fa5 100644 --- a/source/web/jsp/dialog/filelink-details.jsp +++ b/source/web/jsp/dialog/filelink-details.jsp @@ -88,11 +88,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/dialog/preview-file.jsp b/source/web/jsp/dialog/preview-file.jsp index ac00b4c48b..984237222f 100644 --- a/source/web/jsp/dialog/preview-file.jsp +++ b/source/web/jsp/dialog/preview-file.jsp @@ -96,11 +96,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/dialog/preview-space.jsp b/source/web/jsp/dialog/preview-space.jsp index 11ee22a947..2c70437960 100644 --- a/source/web/jsp/dialog/preview-space.jsp +++ b/source/web/jsp/dialog/preview-space.jsp @@ -96,11 +96,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/dialog/space-details.jsp b/source/web/jsp/dialog/space-details.jsp index 923116559a..b61c4f1316 100644 --- a/source/web/jsp/dialog/space-details.jsp +++ b/source/web/jsp/dialog/space-details.jsp @@ -92,11 +92,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/dialog/spacelink-details.jsp b/source/web/jsp/dialog/spacelink-details.jsp index 56d8e0246b..17a48e55b8 100644 --- a/source/web/jsp/dialog/spacelink-details.jsp +++ b/source/web/jsp/dialog/spacelink-details.jsp @@ -84,11 +84,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/dialog/versioned-details.jsp b/source/web/jsp/dialog/versioned-details.jsp index 641463e507..9aedd903cc 100644 --- a/source/web/jsp/dialog/versioned-details.jsp +++ b/source/web/jsp/dialog/versioned-details.jsp @@ -96,9 +96,9 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/forums/forum-details.jsp b/source/web/jsp/forums/forum-details.jsp index 350182c085..4f1257db1e 100644 --- a/source/web/jsp/forums/forum-details.jsp +++ b/source/web/jsp/forums/forum-details.jsp @@ -84,11 +84,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/forums/forums-details.jsp b/source/web/jsp/forums/forums-details.jsp index 8e915df926..f628885fd8 100644 --- a/source/web/jsp/forums/forums-details.jsp +++ b/source/web/jsp/forums/forums-details.jsp @@ -84,11 +84,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/forums/topic-details.jsp b/source/web/jsp/forums/topic-details.jsp index 131bbd044a..0c91c57114 100644 --- a/source/web/jsp/forums/topic-details.jsp +++ b/source/web/jsp/forums/topic-details.jsp @@ -85,11 +85,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/projects/project-details.jsp b/source/web/jsp/projects/project-details.jsp index 25e5b3d441..fb35e1b359 100644 --- a/source/web/jsp/projects/project-details.jsp +++ b/source/web/jsp/projects/project-details.jsp @@ -83,11 +83,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/wcm/file-details.jsp b/source/web/jsp/wcm/file-details.jsp index 14c36d26cc..6be657819d 100644 --- a/source/web/jsp/wcm/file-details.jsp +++ b/source/web/jsp/wcm/file-details.jsp @@ -86,11 +86,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/wcm/folder-details.jsp b/source/web/jsp/wcm/folder-details.jsp index db41da6366..118d434cf3 100644 --- a/source/web/jsp/wcm/folder-details.jsp +++ b/source/web/jsp/wcm/folder-details.jsp @@ -85,11 +85,11 @@ <%-- Navigation --%> - + - + diff --git a/source/web/jsp/wcm/website-details.jsp b/source/web/jsp/wcm/website-details.jsp index 64e73916e8..53641e6576 100644 --- a/source/web/jsp/wcm/website-details.jsp +++ b/source/web/jsp/wcm/website-details.jsp @@ -83,11 +83,11 @@ <%-- Navigation --%> - + - +