AEM 6.1 Preview mode | Community
Skip to main content
prabodh
Level 2
March 31, 2016
Solved

AEM 6.1 Preview mode

  • March 31, 2016
  • 7 replies
  • 3877 views

Hi All,

Preview mode doesn't function properly on clicking the preview option, but working fine if we refresh the page. Could anyone help me to resolve this issue ? Is it a known bug ?

Thanks in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

Hi

Please have a look at this article, this seems like your problem too.

Link:- http://blogs.adobe.com/dmcmahon/2012/03/12/cq5-preview-mode-in-sidekick-does-not-refresh-automatically/

//preview mode in sidekick does not refresh automatically

The solution is simply to force a page refresh automatically when switching to preview mode.

  1. Open /libs/wcm/core/components/init/init.jsp
  2. Add the previewReload property as follows and save the changes:
    CQ.WCM.launchSidekick("<%= currentPage.getPath() %>", { propsDialog: "<%= dlgPath == null ? "" : dlgPath %>", locked: <%= currentPage.isLocked() %>,previewReload: "true"});
  3. Now CQ is setup to refresh automatically when switching to preview mode.

Workaround :- https://helpx.adobe.com/experience-manager/kb/LinkToPreviewMode.html

 

Please check the browser console errors and error.log to better debug this problem.

Thanks and Regards

Kautuk Sahni

7 replies

edubey
Level 10
March 31, 2016

Have you changed anything in init.jsp file?

Which AEM version you are using?

Lokesh_Shivalingaiah
Level 10
March 31, 2016

see if there is any JS error when you change to preview mode

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
April 1, 2016

Hi

Please have a look at this article, this seems like your problem too.

Link:- http://blogs.adobe.com/dmcmahon/2012/03/12/cq5-preview-mode-in-sidekick-does-not-refresh-automatically/

//preview mode in sidekick does not refresh automatically

The solution is simply to force a page refresh automatically when switching to preview mode.

  1. Open /libs/wcm/core/components/init/init.jsp
  2. Add the previewReload property as follows and save the changes:
    CQ.WCM.launchSidekick("<%= currentPage.getPath() %>", { propsDialog: "<%= dlgPath == null ? "" : dlgPath %>", locked: <%= currentPage.isLocked() %>,previewReload: "true"});
  3. Now CQ is setup to refresh automatically when switching to preview mode.

Workaround :- https://helpx.adobe.com/experience-manager/kb/LinkToPreviewMode.html

 

Please check the browser console errors and error.log to better debug this problem.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
prabodh
prabodhAuthor
Level 2
April 5, 2016

Hi Kautuk,

I have tried adding previewReload:"true", but didn't work, the sidekick disappeared post adding it. Also, couldn't find any js errors on the browser console. Please let me know if there is any other way.

Regards,

Prabodh

prabodh
prabodhAuthor
Level 2
April 5, 2016

No, I haven't changed anything in init.jsp. Using AEM 6.1.

edubey
Level 10
April 5, 2016

Are you seeing this with all projects?

Can you share init.jsp u are using?

prabodh
prabodhAuthor
Level 2
April 5, 2016

We have only one project, but also seeing the same behavior in Geometrix project.

init.jsp:

<%@page session="false"%><%--
  Copyright 1997-2010 Day Management AG
  Barfuesserplatz 6, 4001 Basel, Switzerland
  All Rights Reserved.

  This software is the confidential and proprietary information of
  Day Management AG, ("Confidential Information"). You shall not
  disclose such Confidential Information and shall use it only in
  accordance with the terms of the license agreement you entered into
  with Day.

  ==============================================================================

  Default init script.

  Draws the WCM initialization code. This is usually called by the head.jsp
  of the page. If the WCM is disabled, no output is written.

  ==============================================================================

--%><%@include file="/libs/foundation/global.jsp" %><%
%><%@page import="com.day.cq.wcm.api.AuthoringUIMode,
                  com.day.cq.wcm.api.WCMMode" %><%
%><%

    if (WCMMode.fromRequest(request) != WCMMode.DISABLED) {
        String dlgPath = null;
        if (editContext != null && editContext.getComponent() != null) {
            dlgPath = editContext.getComponent().getDialogPath();
        }
        AuthoringUIMode authoringUIMode = AuthoringUIMode.fromRequest(slingRequest);
        if (authoringUIMode != null && authoringUIMode != AuthoringUIMode.CLASSIC) {
            %><cq:includeClientLib categories="cq.authoring.page" /><%
        } else {
            %><cq:includeClientLib categories="cq.wcm.edit" />
            <script type="text/javascript">
                (function() {

                    var cfg = <%
                            try {
                                sling.getService(com.day.cq.wcm.undo.UndoConfigService.class)
                                        .writeClientConfig(out);
                            } catch (Exception e) {
                                // ignore
                            }
                        %>;
                    <%-- explicitly set page path, as under some circumstances, CQ.WCM.getPagePath() --%>
                    <%-- may yield unwanted results at this point                                    --%>
                    cfg.pagePath = "<%= xssAPI.encodeForJSString(currentPage.getPath()) %>";

                    if (CQClientLibraryManager.channelCB() != "touch") {
                        var isEditMode = <%= WCMMode.fromRequest(request) == WCMMode.EDIT ? "true" : "false" %>;
                        if (!isEditMode) {
                            cfg.enabled = false;
                        }
                        CQ.undo.UndoManager.initialize(cfg);
                        CQ.Ext.onReady(function() {
                            CQ.undo.UndoManager.detectCachedPage(<%= System.currentTimeMillis() %>);
                        });
                    }
                })();

                CQ.WCM.launchSidekick("<%= xssAPI.encodeForJSString(currentPage.getPath()) %>", {
                    propsDialog: "<%= dlgPath == null ? "" : xssAPI.encodeForJSString(dlgPath) %>",
                    locked: <%= currentPage.isLocked() %>

                });
            </script>
            <%
        }
    }
%>