[MAGNOLIA-250] showPreview() is broken Created: 17/Dec/04  Updated: 20/Feb/15  Resolved: 25/Apr/05

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 2.0 Final
Fix Version/s: 2.1 Final

Type: Bug Priority: Major
Reporter: Andreas Weder Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

any


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Resource.showPreview(HttpServletRequest) is looking for a request parameter "preview" in order to determine, if a request is showing a preview of a page. As a result, a call to the method always returns "false".

The method should check for "mgnlPreview" instead, and not just check for its existence, but also its value. The check must be something like:

(request.getSession().getAttribute("mgnlPreview") != null) &&
(request.getSession().getAttribute("mgnlPreview").equalsIgnoreCase("true"))

I have set this to major since I consider it an important method for building controllers.



 Comments   
Comment by Andreas Weder [ 25/Apr/05 ]

This following patch fixes the problem for the 2.02 branch:

Index: C:/Projects/Magnolia_2_02_Branch/src/main/info/magnolia/cms/util/Resource.java
===================================================================
— C:/Projects/Magnolia_2_02_Branch/src/main/info/magnolia/cms/util/Resource.java (revision 548)
+++ C:/Projects/Magnolia_2_02_Branch/src/main/info/magnolia/cms/util/Resource.java (working copy)
@@ -240,7 +240,7 @@

  • @return boolean , true if preview is enabled
    */
    public static boolean showPreview(HttpServletRequest req) { - return (req.getParameter("preview") != null); + return Boolean.valueOf((String) req.getSession().getAttribute("mgnlPreview")).booleanValue(); }
Comment by Fabrizio Giustina [ 25/Apr/05 ]

fixed in svn both for trunk and the 2.02 branch, thanks

Generated at Mon Feb 12 03:15:34 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.