response.sendRedirect(request.getContextPath() + "/page/user/" + URLEncoder.encode(userid) + "/dashboard");
en gros vous auriez :response.sendRedirect(request.getContextPath() + "/page/mapage");
<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>mapage</title>
<title-id>page.mapage.title</title-id>
<description>mapage</description>
<description-id>page.mapage.description</description-id>
<template-instance>mapage</template-instance>
<authentication>user</authentication>
</page>
<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
<template-type>org/alfresco/montemplate</template-type>
</template-instance>
var connector = remote.connect("alfresco");
result = connector.get("/test/test/" + user.name);
if (result.status == 200) {
var data = eval('(' + result + ')');
model.site = data ;
}
<script language="javascript" type="text/javascript">
<!–
window.location.replace(${url.context}/page/site/${sitered.shortName}/documentlibrary);
–>
</script>
<p>
Le site de redirection est ${url.context}/page/site/${sitered.shortName}/documentlibrary
</p>
Caused by: org.springframework.extensions.webscripts.WebScriptException: 07310000 Failed to process template fr/intuitiv/module/fds/custom-login.ftl
at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:160)
at org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:328)
… 36 more
Caused by: freemarker.core.InvalidReferenceException: Expression sitered.shortName is undefined on line 6, column 52 in fr/intuitiv/module/fds/custom-login.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.Environment.process(Environment.java:188)
at freemarker.template.Template.process(Template.java:237)
at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
… 37 more
var result = remote.call("org/alfresco/components/customlogin/custom-login");
//var data = eval('(' + result + ')');
model.sitered = result ;
function redirectToSite()
{
var s = new XML(config.script);
model = null;
model.maxItems = parseInt(s.maxitems, 10);
var result, preferences = {};
// Request the current user's preferences
var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "/sites?size=100");
model.sites = [];
if (result.status == 200)
{
// Create javascript objects from the server response
model.sites = eval('(' + result + ')');
}
model.numSites = model.sites.length;
model.sitered = sites[0];
//status.redirect = true;
//status.code = 301;
//status.location = url.context + "/page/user/" + encodeURI(userid) + "/profile";
}
redirectToSite();
var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "/sites?size=100");
model.sites = [];
if (result.status == 200) {
model.sites = eval('(' + result + ')');
model.numSites = model.sites.length;
model.sitered = model.sites[0];
}
<script language="javascript" type="text/javascript">
<!–
window.location.replace(${url.context}/page/site/${sitered.shortName}/documentlibrary);
–>
</script>
remote.call("org/alfresco/components/customlogin/custom-login");
mais j'ai pas l'impression que ça marche, et puis pourquoi faire un "remote call" alors que le webscript est local à l'application (dans le share.war et pas alfresco.war)…function main()
{
// Get the user name of the person to get
var userName = url.templateArgs.userid;
// Get the person who has that user name
var person = people.getPerson(userName);
if (person === null)
{
// Return 404 - Not Found
status.setCode(status.STATUS_NOT_FOUND, "Person " + userName + " does not exist");
return;
}
// Get the list of sites
var sites = siteService.listUserSites(userName);
var sizeString = args["size"];
if (sizeString != null)
{
var size = parseInt(sizeString);
if (size < sites.length)
{
// Only return the first n sites based on the passed page size
var pagedSites = new Array(size);
for (var index = 0; index < size; index++)
{
pagedSites[index] = sites[index];
}
sites = pagedSites;
}
}
model.sites = sites;
}
main();
function redirectToSite() {
var result = null;
var sites = [];
var site = null;
var userName = args["username"];
// Get the person who has that user name
var person = people.getPerson(userName);
result = siteService.listUserSites(userName);
model.sitered = null;
if (result.length > 0)
model.sitered = result[0];
}
redirectToSite();
var connector = remote.connect("alfresco");
var result = connector.get("/fr/intuitiv/module/fds/customlogin/custom-login?username=" + user.name);
var data = eval('(' + result + ')');
model.sitered = data ;
<#import "/org/alfresco/repository/site/site.lib.ftl" as siteLib/>
[
<@siteLib.siteJSON site=sitered/>
]
<script language="javascript" type="text/javascript">
<!–
window.location.replace(${url.context}/page/site/${sitered.shortName}/documentlibrary);
–>
</script>
<p>
Le site de redirection est ${url.context}/page/site/${sitered.shortName}/documentlibrary
</p>
18:43:18,113 ERROR [freemarker.runtime]
Expected hash. sitered evaluated instead to freemarker.template.SimpleSequence on line 6, column 52 in org/alfresco/custom-login.ftl.
The problematic instruction:
———-
==> ${sitered.shortName} [on line 6, column 50 in org/alfresco/custom-login.ftl]
———-
Java backtrace for programmers:
———-
freemarker.template.TemplateException: Expected hash. sitered evaluated instead to freemarker.template.SimpleSequence on line 6, column 52 in org/alfresco/custom-login.ftl.
at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.Environment.process(Environment.java:188)
at freemarker.template.Template.process(Template.java:237)
at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
at org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:328)
at org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:79)
at org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:582)
at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.calculateComponentDependencies(TemplateInstanceRenderer.java:68)
at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:116)
at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
at org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:70)
at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
at org.springframework.extensions.surf.render.RenderService.startPageRenderer(RenderService.java:664)
at org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:641)
at org.springframework.extensions.surf.render.PresentationUtil.renderPage(PresentationUtil.java:95)
at org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:349)
at org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:290)
at org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:136)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
18:43:18,114 ERROR [surf.render.RenderService] Unable to process template: custom-login
18:43:18,114 ERROR [extensions.surf.FrameworkUtil] An exception occurred while rendering a page: user/newuser/dashboard
18:43:18,115 ERROR [extensions.surf.FrameworkUtil] org.springframework.extensions.surf.exception.RendererExecutionException: WebTemplateProcessor failed to process template uri: org/alfresco/custom-login
at org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:360)
at org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:79)
at org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:582)
at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.calculateComponentDependencies(TemplateInstanceRenderer.java:68)
at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:116)
at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
at org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:70)
at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
at org.springframework.extensions.surf.render.RenderService.startPageRenderer(RenderService.java:664)
at org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:641)
at org.springframework.extensions.surf.render.PresentationUtil.renderPage(PresentationUtil.java:95)
at org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:349)
at org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:290)
at org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:136)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.extensions.webscripts.WebScriptException: 07310001 Failed to process template org/alfresco/custom-login.ftl
at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:160)
at org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:328)
… 36 more
Caused by: freemarker.template.TemplateException: Expected hash. sitered evaluated instead to freemarker.template.SimpleSequence on line 6, column 52 in org/alfresco/custom-login.ftl.
at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.Environment.process(Environment.java:188)
at freemarker.template.Template.process(Template.java:237)
at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
… 37 more
<#import "/org/alfresco/repository/site/site.lib.ftl" as siteLib/>
<@siteLib.siteJSON site=sitered/>
2. soit vous laissez les crochets (si éventuellement vous voulez retourner plusieurs sites) mais il faut alors modifier votre fichier JavaScript relié à votre template coté Share pour qu'il récupère le premier élément du tableau :var data = eval('(' + result + ')');
model.sitered = data[0];
window.location.replace("${url.context}/page/site/${sitered.shortName}/documentlibrary");
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.