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:
Kevin Roast
2007-12-06 13:48:20 +00:00
parent b0a57b4d5c
commit 8266382b1c
22 changed files with 198 additions and 42 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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<String, String> 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

View File

@@ -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<String, String> params = null;
}

View File

@@ -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)
{