-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
There are valid use-cases that may result in the sitemesh filter running twice (or more) in the context of a single request. One simple example of this involves using JSP pages to render HTML e-mail content. A request that dispatches such an e-mail can retrieve the rendered JSP contents as a string by including it (and wrapping the HttpServletResponse appropriately). Thus it can be desirable to have multiple runs of the sitemesh filter, one for the response that is ultimately sent to the client/browser, and one for each e-mail composed in this manner (because using sitemesh to decorate the e-mails would be extremely convenient).
I think there are a couple of simple ways to support this:
- Make 'filterAlreadyAppliedForRequest' protected instead of private. Doing so will allow users to subclass SiteMeshFilter and provide their own implementation that can be made to run more than once per request as desired.
- Instead of using the literal key of "com.opensymphony.sitemesh.APPLIED_ONCE" to flag whether or not the filter has been applied, suffix this key with something like the filter's hashCode or the current timestamp (or random number) at instantiation/init-time. That would allow a user who wants to have the filter applied twice in some scenarios to simply set up two instances of it with different filter-mappings (which can/will overlap in some cases). Neither filter would allow itself to be applied more than once per request, but both would be able to coexist side-by-side without one cancelling out the other.
Metadata
Metadata
Assignees
Labels
No labels