Use of RequestDispatcherForwardAction in a Site Pre-Controller
Options
Can anyone confirm that the RequestDispatcherForwardAction when used in a site pre-controller will allow a forward to a static piece of content only?
When I put in a .page file (or an alias URL) to be forwarded to, I'm getting a 404. If I put in a static image it works perfectly.
Interestingly, the site pre-controller appears to be firing AFTER validating the .page file. For example if you go to http://server:1776/site/invalidpage.page throws a 404 before initiating the site pre-controller class.method. I would think that the controller would fire before anything is processed for the site.
When I put in a .page file (or an alias URL) to be forwarded to, I'm getting a 404. If I put in a static image it works perfectly.
Interestingly, the site pre-controller appears to be firing AFTER validating the .page file. For example if you go to http://server:1776/site/invalidpage.page throws a 404 before initiating the site pre-controller class.method. I would think that the controller would fire before anything is processed for the site.
0
Comments
-
Forward to a page should work, what does your code look like?
I don't have a way to test right now but I think the code is something like this:
I agree with you on the behavior of site controllers, they only get invoked when you hit a valid page.
new URLRedirectForwardAction(context, context.getPageLink(page));0 -
I just trimmed down our pre-controller to redirect all LiveSite pages to what is stored in the controller's parameter 'redirectTo'.
(Please note I give this code, which I believe works, as an example for others to get their feet wet. This pre-controller does not work in preview mode because of it's over simplicity and brute force approach.)
[PHP]
package com.company.livesite.precontrollers;
import com.interwoven.livesite.common.web.ForwardAction;
import com.interwoven.livesite.runtime.RequestContext;
import com.interwoven.livesite.common.web.forward.target.ContextRelativeTarget;
import com.interwoven.livesite.common.web.RequestDispatcherForwardAction;
public class SitePreControllers {
public ForwardAction redirect(RequestContext context) {
String redirectUrl = context.getParameterString("redirectTo");
ContextRelativeTarget crt = new ContextRelativeTarget(redirectUrl);
ForwardAction faction = new RequestDispatcherForwardAction(crt);
return faction;
}
}
[/PHP]
If I put /images/smiley_face.gif as the redirectTo parameter, I get the smiley face.
If I put /site/abc.page as the redirectTo parameter, I get a 404 - /site/abc.page not found (yes it's there and does work without the controller in place.) Adding the context.getPageLink(...) doesn't help the situation.
So back to my original statement - it appears that pre-controllers can not 'ForwardAction' using a RequestDispatcherForwardAction object to a different .page page. It works just fine to static content (.pdf, images, .html...) but not to dynamic pages. Does anyone know differently?
Also I disagree - if the .page file is not found I would like to pre-controller to be called, maybe the pre-controller can 'fix the issue'. An added bonus would be to add something to the context indicating the validity of the page being requested.0 -
A precontroller on your error page could be configured to do this.Also I disagree - if the .page file is not found I would like to pre-controller to be called, maybe the pre-controller can 'fix the issue'. An added bonus would be to add something to the context indicating the validity of the page being requested. 0 -
Maybe try having your precontroller method return a ContextRedirectForwardAction with fullRedirect=false. That triggers a RequestDispatcher.forward(request, response), which *should* internally come back in as any other request and trigger all layers of the code.0
-
-
Gah! Sorry. My experience getting LS to do crazy things is dated (LS3.1).
/ I've got nothin you couldn't figure out on your own then0 -
@Denise, any luck of using RequestDispatcherForwardAction in pre-controllers for .pages/friendly URLS?
0
Categories
- All Categories
- 109 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 122 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
TeamSite Developer Resources
If you are interested in gaining full access to the content, you can register for a My Support account here.
- Docker Automation
- LiveSite Content Services (LSCS) REST API
- Single Page Application (SPA) Modules
- TeamSite Add-ons
If you are interested in gaining full access to the content, you can register for a My Support account here.