mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
REST command to launch User Profile page for a Person. Fix to nav image alignment on details pages.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7562 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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.
|
||||
* <p>
|
||||
* 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<String, Object> 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user