mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed Tree in portals
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4920 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -93,15 +93,12 @@ public final class FacesHelper
|
||||
*/
|
||||
private static FacesContext getFacesContextImpl(Object request, Object response, Object context)
|
||||
{
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
if (facesContext != null) return facesContext;
|
||||
|
||||
FacesContextFactory contextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
|
||||
LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
|
||||
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
|
||||
|
||||
// Doesn't set this instance as the current instance of FacesContext.getCurrentInstance
|
||||
facesContext = contextFactory.getFacesContext(context, request, response, lifecycle);
|
||||
FacesContext facesContext = contextFactory.getFacesContext(context, request, response, lifecycle);
|
||||
|
||||
// Set using our inner class
|
||||
InnerFacesContext.setFacesContextAsCurrent(facesContext);
|
||||
|
@@ -16,12 +16,16 @@
|
||||
*/
|
||||
package org.alfresco.web.app.servlet.ajax;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
@@ -75,14 +79,10 @@ public class InvokeCommand extends BaseAjaxCommand
|
||||
final HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
|
||||
|
||||
UserTransaction tx = null;
|
||||
ResponseWriter writer = null;
|
||||
try
|
||||
{
|
||||
final VariableResolver vr = facesContext.getApplication().getVariableResolver();
|
||||
|
||||
final int indexOfDot = expression.indexOf('.');
|
||||
final String variableName = expression.substring(0, indexOfDot);
|
||||
final String methodName = expression.substring(indexOfDot + 1);
|
||||
@@ -92,7 +92,38 @@ public class InvokeCommand extends BaseAjaxCommand
|
||||
" on variable " + variableName +
|
||||
" with method " + methodName);
|
||||
|
||||
final Object bean = vr.resolveVariable(facesContext, variableName);
|
||||
// retrieve the managed bean, this is really weak but if the
|
||||
// request comes from a portal server the bean we need to get
|
||||
// is in the session with a prefix chosen by the portal vendor,
|
||||
// to cover this scenario we have to go through the names of
|
||||
// all the objects in the session to find the bean we want.
|
||||
Object bean = null;
|
||||
Enumeration enumNames = request.getSession().getAttributeNames();
|
||||
while (enumNames.hasMoreElements())
|
||||
{
|
||||
String name = (String)enumNames.nextElement();
|
||||
if (name.endsWith(variableName))
|
||||
{
|
||||
bean = request.getSession().getAttribute(name);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Found bean " + bean + " in the session");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we didn't find the bean it may be a request scope bean, in which
|
||||
// case go through the variable resolver to create it.
|
||||
if (bean == null)
|
||||
{
|
||||
VariableResolver vr = facesContext.getApplication().getVariableResolver();
|
||||
bean = vr.resolveVariable(facesContext, variableName);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created bean " + bean + " via the variable resolver");
|
||||
}
|
||||
|
||||
final Method method = bean.getClass().getMethod(methodName);
|
||||
|
||||
final String responseMimetype =
|
||||
@@ -103,6 +134,7 @@ public class InvokeCommand extends BaseAjaxCommand
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("invoking method " + method +
|
||||
" with repsonse mimetype " + responseMimetype);
|
||||
|
||||
writer = this.setupResponseWriter(responseMimetype,
|
||||
response,
|
||||
facesContext);
|
||||
|
@@ -58,7 +58,6 @@ import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NoTransformerException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
import org.alfresco.web.app.servlet.ExternalAccessServlet;
|
||||
@@ -1305,6 +1304,12 @@ public final class Utils
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/scripts/ajax/common.js\"> </script>\n");
|
||||
|
||||
// set the context path
|
||||
out.write("<script type=\"text/javascript\">\n");
|
||||
out.write("setContextPath('");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("');\n</script>\n");
|
||||
|
||||
// add marker to request
|
||||
context.getExternalContext().getRequestMap().put(DOJO_SCRIPTS_WRITTEN, Boolean.TRUE);
|
||||
}
|
||||
@@ -1353,6 +1358,12 @@ public final class Utils
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/scripts/ajax/common.js\"> </script>\n");
|
||||
|
||||
// set the context path
|
||||
out.write("<script type=\"text/javascript\">\n");
|
||||
out.write("setContextPath('");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("');\n</script>\n");
|
||||
|
||||
// add marker to request
|
||||
context.getExternalContext().getRequestMap().put(YAHOO_SCRIPTS_WRITTEN, Boolean.TRUE);
|
||||
}
|
||||
|
@@ -32,6 +32,15 @@ function handleErrorYahoo(msg)
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context path to use, useful for portals where
|
||||
* the URL can be different from the app's context path.
|
||||
*/
|
||||
function setContextPath(contextPath)
|
||||
{
|
||||
_alfContextPath = contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and returns the context path for the current page
|
||||
*/
|
||||
|
Reference in New Issue
Block a user