Author: xlawrence
Date: Tue Aug 15 10:52:43 2006
New Revision: 14895

URL: https://svndev.jahia.net/websvn/listing.php?sc=1&rev=14895&repname=jahia
Log:
Resolve issues JAHIA-1243 -> 1245
reactivate navigation in adequate engines

Modified:
    trunk/core/src/java/org/jahia/data/fields/FieldsEditHelperAbstract.java
    trunk/core/src/java/org/jahia/engines/addcontainer/AddContainer_Engine.java
    trunk/core/src/java/org/jahia/engines/lock/LockEngine.java
    
trunk/core/src/java/org/jahia/engines/updatecontainer/UpdateContainer_Engine.java
    trunk/core/src/java/org/jahia/services/containers/ContainerFactory.java
    trunk/core/src/webapp/jsp/jahia/engines/addcontainer/addcontainer.jsp
    trunk/core/src/webapp/jsp/jahia/engines/buttons.jsp
    trunk/core/src/webapp/jsp/jahia/engines/css/styles.css
    trunk/core/src/webapp/jsp/jahia/engines/engine.jsp
    trunk/core/src/webapp/jsp/jahia/engines/lock/lock.jsp
    trunk/core/src/webapp/jsp/jahia/engines/menuBar.jsp
    trunk/core/src/webapp/jsp/jahia/engines/navigation.jsp
    trunk/core/src/webapp/jsp/jahia/javascript/jahia.js

Modified: 
trunk/core/src/java/org/jahia/data/fields/FieldsEditHelperAbstract.java
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/data/fields/FieldsEditHelperAbstract.java&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/data/fields/FieldsEditHelperAbstract.java 
(original)
+++ trunk/core/src/java/org/jahia/data/fields/FieldsEditHelperAbstract.java Tue 
Aug 15 10:52:43 2006
@@ -227,7 +227,7 @@
                 logger.debug ("Update container field " +
                         theField.getDefinition ().getName () + "...");
                 engineMap.put (engineName+"."+"theField", theField);
-                engineMap.put (engineName+"."+"isSelectedField", new Boolean 
(false));
+                engineMap.put (engineName+"."+"isSelectedField", 
Boolean.FALSE);
 
                 boolean doUpdate = false;
                 HashMap ctnListFieldAcls = this.getCtnListFieldAcls();
@@ -242,7 +242,7 @@
                     doUpdate = true;
                 }
                 jParams.setSubstituteEntryLoadRequest 
(elh.getPreviousEntryLoadRequest());
-                engineMap.put("fieldsEditCallingEngineName",engineName); // 
@todo : make as Constant
+                engineMap.put("fieldsEditCallingEngineName",engineName); // 
todo : make as Constant
                 if (doUpdate &&
                         !EngineToolBox.getInstance().processFieldTypes 
(theField, theContainer, engineName, jParams, mode, engineMap)) {
 

Modified: 
trunk/core/src/java/org/jahia/engines/addcontainer/AddContainer_Engine.java
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/engines/addcontainer/AddContainer_Engine.java&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/engines/addcontainer/AddContainer_Engine.java 
(original)
+++ trunk/core/src/java/org/jahia/engines/addcontainer/AddContainer_Engine.java 
Tue Aug 15 10:52:43 2006
@@ -730,6 +730,7 @@
             // #endif
             // flag for subEngine: means that is a call from  AddContainer, 
reset the flag
             jParams.getSessionState().setAttribute("AddContainer", "false");
+            
jParams.getSessionState().removeAttribute("showNavigationInLockEngine");
         }
         return null;
 

Modified: trunk/core/src/java/org/jahia/engines/lock/LockEngine.java
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/engines/lock/LockEngine.java&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/engines/lock/LockEngine.java (original)
+++ trunk/core/src/java/org/jahia/engines/lock/LockEngine.java Tue Aug 15 
10:52:43 2006
@@ -226,6 +226,7 @@
                     }  
                     lockRegistry.acquire(lockKey, user, user.getUserKey(),
                                          
jParams.getSessionState().getMaxInactiveInterval());
+                    
jParams.getSessionState().removeAttribute("showNavigationInLockEngine");
                 }
             }
 

Modified: 
trunk/core/src/java/org/jahia/engines/updatecontainer/UpdateContainer_Engine.java
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/engines/updatecontainer/UpdateContainer_Engine.java&rev=14895&repname=jahia
==============================================================================
--- 
trunk/core/src/java/org/jahia/engines/updatecontainer/UpdateContainer_Engine.java
 (original)
+++ 
trunk/core/src/java/org/jahia/engines/updatecontainer/UpdateContainer_Engine.java
 Tue Aug 15 10:52:43 2006
@@ -152,8 +152,17 @@
             throws JahiaException,
             JahiaUpdateLockException,
             JahiaForbiddenAccessException {
+        jParams.getSessionState().setAttribute("showNavigationInLockEngine", 
"true");
+        return handleActions(jParams, jData, null, null);
+    }
+
+    protected EngineValidationHelper handleActions(final ProcessingContext 
jParams,
+                                                   final JahiaData jData,
+                                                   final String cid,
+                                                   final String screen)
+            throws JahiaException, JahiaUpdateLockException, 
JahiaForbiddenAccessException {
         // initalizes the hashmap
-        final HashMap engineMap = initEngineMap(jParams);
+        final HashMap engineMap = initEngineMap(jParams, cid, screen);
 
         // get the screen
         final String theScreen = (String) engineMap.get("screen");
@@ -225,6 +234,33 @@
                 } else {
                     // Prerequisites are NOT completed ! Damned ! Redirect the 
JSP
                     // output to lock informations.
+
+                    if (theScreen.equals("apply")) {
+                        final String navigation = 
jParams.getParameter("navigation");
+                        if (navigation != null && navigation.length() > 0) {
+                            final String newCID;
+                            if ("first".equals(navigation)) {
+                                newCID = jParams.getParameter("first");
+                            } else if ("previous".equals(navigation)) {
+                                newCID = jParams.getParameter("previous");
+                            } else if ("next".equals(navigation)) {
+                                newCID = jParams.getParameter("next");
+                            } else if ("last".equals(navigation)) {
+                                newCID = jParams.getParameter("last");
+                            } else {
+                                throw new IllegalArgumentException("Validation 
param is unknow: " + navigation);
+                            }
+                            final String newEngineURL = 
jParams.composeEngineUrl(ENGINE_NAME, "?cid=" + newCID);
+                            engineMap.put(ENGINE_URL_PARAM, newEngineURL);
+
+                            final SessionState theSession = 
jParams.getSessionState();
+                            theSession.setAttribute("Navigation", 
"Navigation");
+
+                            logger.debug("reloading engineMap and 
handleActions for navigation");
+                            handleActions(jParams, jData, newCID, "edit");
+                            return null;
+                        }
+                    }
                     lockEngine.redirect(jParams, engineMap, lockKey);
                     return evh; // we must abort before the second 
displayScreen
                 }
@@ -257,6 +293,8 @@
                     final LockService lockRegistry = 
servicesRegistry.getLockService();
                     lockRegistry.release(lockKey, user, user.getUserKey());
                 }
+                final SessionState theSession = jParams.getSessionState();
+                theSession.setAttribute("Navigation", "Navigation");
             }
         }
 
@@ -728,6 +766,7 @@
             // #endif
             // flag for subEngine: means that is a call from  updateContainer, 
reset the flag
             jParams.getSessionState().setAttribute("UpdateContainer", "false");
+            
jParams.getSessionState().removeAttribute("showNavigationInLockEngine");
 
         }
         return null;
@@ -739,7 +778,7 @@
      * @param jParams a ProcessingContext object (with request and response)
      * @return a HashMap object containing all the basic values needed by an 
engine
      */
-    private HashMap initEngineMap(final ProcessingContext jParams)
+    private HashMap initEngineMap(final ProcessingContext jParams, final 
String forcedCid, final String screen)
             throws JahiaException,
             JahiaSessionExpirationException {
 
@@ -750,10 +789,23 @@
         int lastFieldId = 0;
 
         // flag for subEngine: means that is a call from  updateContainer
-        jParams.getSessionState().setAttribute("UpdateContainer", "true");
+        final SessionState theSession = jParams.getSessionState();
+        theSession.setAttribute("UpdateContainer", "true");
+        final boolean isNavigation = theSession.getAttribute("Navigation") != 
null;
 
-        String theScreen = jParams.getParameter("screen");
-        String ctnidStr = jParams.getParameter("cid");
+        String theScreen;
+        if (screen != null && screen.length() > 0) {
+            theScreen = screen;
+        } else {
+            theScreen = jParams.getParameter("screen");
+        }
+
+        final String ctnidStr;
+        if (forcedCid != null && forcedCid.length() > 0) {
+            ctnidStr = forcedCid;
+        } else {
+            ctnidStr = jParams.getParameter("cid");
+        }
         int ctnid;
 
         try {
@@ -767,15 +819,13 @@
         }
 
         // gets session values
-        //HttpSession theSession = jParams.getRequest().getSession( true );
-        final SessionState theSession = jParams.getSessionState();
         HashMap engineMap = (HashMap) 
theSession.getAttribute("jahia_session_engineMap");
         boolean prevScreenIsApply = false;
 
-        if (engineMap != null && theScreen != null) {
+        if (isNavigation || (engineMap != null && theScreen != null)) {
             Boolean prevScreenIsApplyBool = (Boolean) 
engineMap.get("prevScreenIsApply");
             prevScreenIsApply = (prevScreenIsApplyBool != null && 
prevScreenIsApplyBool.booleanValue());
-            if (prevScreenIsApply) {
+            if (prevScreenIsApply || isNavigation) {
                 elh = (EngineLanguageHelper) engineMap
                         .get(JahiaEngine.ENGINE_LANGUAGE_HELPER);
                 if (elh != null) {
@@ -792,13 +842,12 @@
 
         JahiaContentContainerFacade jahiaContentContainerFacade;
         final ContentContainer container = 
ContentContainer.getContainer(ctnid);
-        if (theScreen != null) {
+        if (theScreen != null && !isNavigation) {
 
-            logger.debug("The Screen is not null, load it from session");
+            logger.debug("The Screen is not null, load it from session: " + 
theScreen);
 
             // if no, load the container value from the session
-            engineMap = (HashMap) theSession.getAttribute(
-                    "jahia_session_engineMap");
+            engineMap = (HashMap) 
theSession.getAttribute("jahia_session_engineMap");
 
             
///////////////////////////////////////////////////////////////////////////////////////
             // FIXME -Fulco-
@@ -840,7 +889,7 @@
             }
 
         } else {
-            logger.debug("the Screen is null load from storage");
+            logger.debug("the Screen is null load from storage, Navigation: " 
+ isNavigation);
 
             // init engine map
             engineMap = new HashMap();
@@ -849,7 +898,7 @@
             org.jahia.engines.shared.Page_Field.resetPageBeanSession(jParams);
 
             // init the JahiaContentFieldFacade
-            ArrayList localeList = 
jParams.getSite().getLanguageSettingsAsLocales(false);
+            final ArrayList localeList = 
jParams.getSite().getLanguageSettingsAsLocales(false);
 
             jahiaContentContainerFacade
                     = new 
JahiaContentContainerFacade(container.getJahiaContainer(jParams, 
jParams.getEntryLoadRequest()),
@@ -860,7 +909,7 @@
                     true, true, false);
 
             
engineMap.put("UpdateContainer_Engine.JahiaContentContainerFacade", 
jahiaContentContainerFacade);
-
+            theSession.removeAttribute("Navigation");
         }
 
         if (theScreen == null || theScreen.equals(EMPTY_STRING)) {
@@ -904,8 +953,9 @@
             try {
                 int fieldId = 
Integer.parseInt(jParams.getParameter("lastfid"));
                 feh.setLastFieldId(fieldId);
-            } catch (NumberFormatException e) {
-                logger.debug(e, e);
+            } catch (final NumberFormatException e) {
+                logger.debug(e);
+                logger.debug("NumberFormatException: Parameter lastfid cannot 
be converted to int... Not setting lastFiledID in the Helper");
             }
         }
         // remember the updated fields ( Apply Change to all lang options )

Modified: 
trunk/core/src/java/org/jahia/services/containers/ContainerFactory.java
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/containers/ContainerFactory.java&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/services/containers/ContainerFactory.java 
(original)
+++ trunk/core/src/java/org/jahia/services/containers/ContainerFactory.java Tue 
Aug 15 10:52:43 2006
@@ -734,6 +734,7 @@
         if (theContainerList == null) {
             return null;
         }
+        final Vector res = new Vector(ctnids.size());
 
         // start check for correct rights.
         if (jParams != null) { // no jParams, can't check for rights
@@ -789,6 +790,9 @@
                             if (acl != null &&
                                     acl.getPermission(currentUser, 
JahiaBaseACL.READ_RIGHTS)) {
                                 if (! v.contains(ctnID)) v.add(ctnID);
+                                if (acl.getPermission(currentUser, 
JahiaBaseACL.WRITE_RIGHTS)) {
+                                    if (! res.contains(ctnID) && 
ctnID.intValue() != -1) res.add(ctnID);
+                                }
                             }
                         }
                     } catch (Throwable t) {
@@ -804,12 +808,11 @@
 
         final Vector v = new Vector();
         final Map loadedContainers = new HashMap();
-        JahiaContainer thisContainer = null;
         final JahiaContainersService jahiaContainersService = 
ServicesRegistry.getInstance().getJahiaContainersService();
         for (int i = 0; i < ctnids.size(); i++) {
             int ctnid = ((Integer) ctnids.elementAt(i)).intValue();
             try {
-                thisContainer = jahiaContainersService.loadContainer(ctnid, 
loadFlag, jParams, loadVersion,
+                final JahiaContainer thisContainer = 
jahiaContainersService.loadContainer(ctnid, loadFlag, jParams, loadVersion,
                         cachedFieldsInContainer,
                         cachedContainerListsFromContainers,
                         cachedContainerListsFromContainers);
@@ -848,7 +851,7 @@
         for (int i = startPos; i < endPos; i++) {
             int ctnid = ((Integer) ctnids.elementAt(i)).intValue();
             try {
-                thisContainer = (JahiaContainer) loadedContainers.get(new 
Integer(ctnid));
+                JahiaContainer thisContainer = (JahiaContainer) 
loadedContainers.get(new Integer(ctnid));
                 if (thisContainer == null) {
                     // should not
                     thisContainer = 
jahiaContainersService.loadContainer(ctnid, loadFlag, jParams, loadVersion,
@@ -869,6 +872,6 @@
         if (theContainerList != null) {
             theContainerList.setIsContainersLoaded(true);
         }
-        return ctnids;
+        return res;
     }
 }

Modified: trunk/core/src/webapp/jsp/jahia/engines/addcontainer/addcontainer.jsp
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/addcontainer/addcontainer.jsp&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/addcontainer/addcontainer.jsp 
(original)
+++ trunk/core/src/webapp/jsp/jahia/engines/addcontainer/addcontainer.jsp Tue 
Aug 15 10:52:43 2006
@@ -65,6 +65,10 @@
 <jsp:include page="../buttons.jsp" flush="true" />
 <!-- End Buttons -->
 
+<!-- Navigation -->
+<jsp:include page="../navigation.jsp" flush="true" />
+<!-- End Navigation -->
+
 <!-- Menubar -->
 <jsp:include page="../menuBar.jsp" flush="true" />
 <!-- End Menubar -->

Modified: trunk/core/src/webapp/jsp/jahia/engines/buttons.jsp
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/buttons.jsp&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/buttons.jsp (original)
+++ trunk/core/src/webapp/jsp/jahia/engines/buttons.jsp Tue Aug 15 10:52:43 2006
@@ -59,16 +59,6 @@
     <% } %>
     <% } %>
 
-    <% if (!"logs".equals(theScreen) && "addcontainer".equals(engineName)) { %>
-    <div class="button" id="saveButtonAdd">
-        <a href="javascript:sendFormSaveAndAddNew();"
-           title="<jahia:engineResourceBundle 
resourceName="org.jahia.altApplyAndAddContainer.label"/>"
-           onclick="javascript:setWaitingCursor(1);">
-            <jahia:engineResourceBundle 
resourceName="org.jahia.button.saveAddNew"/>
-        </a>
-    </div>
-    <% } %>
-
     <% if (showButtons) { %>
     <% if (!"logs".equals(theScreen) && !"workflow".equals(engineName) && 
!"deletecontainer".equals(engineName) &&
             !"".equals(noApply)) { %>

Modified: trunk/core/src/webapp/jsp/jahia/engines/css/styles.css
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/css/styles.css&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/css/styles.css (original)
+++ trunk/core/src/webapp/jsp/jahia/engines/css/styles.css Tue Aug 15 10:52:43 
2006
@@ -39,12 +39,10 @@
 }
 
 #navigationBar {
-    /* display: block;
-       clear: both;
+    display: block;
+         clear: both;
     float: right;
     height: 40px;
-    */
-    display:none;
 }
 
 #navigationBar img {

Modified: trunk/core/src/webapp/jsp/jahia/engines/engine.jsp
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/engine.jsp&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/engine.jsp (original)
+++ trunk/core/src/webapp/jsp/jahia/engines/engine.jsp Tue Aug 15 10:52:43 2006
@@ -278,7 +278,7 @@
                 sendFormCancel();
                 //alert ("sendFormCancel" + "-" + last + "-" + src);
             }
-            CloseJahiaWindow(false);
+            CloseJahiaWindow("yes");
         }
     }
 

Modified: trunk/core/src/webapp/jsp/jahia/engines/lock/lock.jsp
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/lock/lock.jsp&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/lock/lock.jsp (original)
+++ trunk/core/src/webapp/jsp/jahia/engines/lock/lock.jsp Tue Aug 15 10:52:43 
2006
@@ -23,6 +23,9 @@
 <%@ page import="java.util.HashMap" %>
 <%@ page import="java.util.List" %>
 <%@ page import="java.util.Map"%>
+<%@ page import="org.jahia.engines.JahiaEngine"%>
+<%@ page import="org.jahia.engines.addcontainer.AddContainer_Engine"%>
+<%@ page import="org.jahia.engines.updatecontainer.UpdateContainer_Engine"%>
 
 <%@ taglib uri="JahiaLib" prefix="jahia" %>
 <jsp:useBean id="jspSource" class="java.lang.String" scope="request"/>
@@ -35,11 +38,8 @@
 <%
     final HashMap engineMap = (HashMap) 
request.getAttribute("org.jahia.engines.EngineHashMap");
     final ParamBean jParams = (ParamBean) 
request.getAttribute("org.jahia.params.ParamBean");
-    final String engineUrl = (String) engineMap.get("engineUrl");
-    final String URLSep = (engineUrl.indexOf("?") == -1) ? "?" : "&";
-    final String theScreen = (String) engineMap.get("screen");
     final boolean showEditMenu = false;
-               request.setAttribute("showEditMenu", new 
Boolean(showEditMenu));            
+               request.setAttribute("showEditMenu", 
Boolean.valueOf(showEditMenu));
 
     final LockPrerequisitesResult lockPrerequisitesResult =
             (LockPrerequisitesResult) engineMap.get("lockPrerequisitesResult");
@@ -58,6 +58,12 @@
 <jsp:include page="../buttons.jsp" flush="true" />
 <!-- End Buttons -->
 
+<% if (session.getAttribute("showNavigationInLockEngine") != null) { %>
+<!-- Navigation -->
+<jsp:include page="../navigation.jsp" flush="true"/>
+<!-- End Navigation -->
+<% } %>
+
 <!-- Menubar -->
 <jsp:include page="../menuBar.jsp" flush="true" />
 <!-- End Menubar -->
@@ -183,21 +189,6 @@
     </span>
     <% } %>
 </p>
-
-<div class="fill">
-    <div class="toright">
-        <div class="button">
-            <a href="javascript:handleActionChange('display')">
-                <jahia:engineResourceBundle 
resourceName="org.jahia.engines.lock.refresh.label"/>
-            </a>
-        </div>
-
-        <div class="button">
-            <a 
href="javascript:document.mainForm.showDetails.value=<%=!lockPrerequisitesResult.shouldShowDetails()%>;handleActionChange('display')">
-                <jahia:engineResourceBundle 
resourceName="org.jahia.engines.lock.showHideDetails.label"/>
-            </a>
-        </div>
-    </div>
-</div>
+<p>&nbsp;</p>
 
 <% } %>
\ No newline at end of file

Modified: trunk/core/src/webapp/jsp/jahia/engines/menuBar.jsp
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/menuBar.jsp&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/menuBar.jsp (original)
+++ trunk/core/src/webapp/jsp/jahia/engines/menuBar.jsp Tue Aug 15 10:52:43 2006
@@ -33,9 +33,12 @@
 
 %>
 <div id="menubar">
-    <% if (jspSource.equals("lock") || jspSource.equals("delete_container") ||
-            jspSource.equals("filemanager_error")) { %>
+    <% if (jspSource.equals("delete_container") || 
jspSource.equals("filemanager_error")) { %>
     &nbsp;
+    <% } else if (jspSource.equals("lock")) { %>
+    <ul id="tabs">
+        <li><span class="current"><jahia:engineResourceBundle 
resourceName="org.jahia.engines.lock.container.label"/></span></li>
+    </ul>
     <% } else { %>
     <ul id="tabs">
         <li>

Modified: trunk/core/src/webapp/jsp/jahia/engines/navigation.jsp
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/navigation.jsp&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/navigation.jsp (original)
+++ trunk/core/src/webapp/jsp/jahia/engines/navigation.jsp Tue Aug 15 10:52:43 
2006
@@ -9,6 +9,7 @@
 <%@ page import="org.jahia.registries.ServicesRegistry"%>
 <%@ page import="org.jahia.data.fields.LoadFlags"%>
 <%@ taglib uri="JahiaLib" prefix="jahia" %>
+<jsp:useBean id="jspSource" class="java.lang.String" scope="request"/>
 
 <%!
 //    private static final org.apache.log4j.Logger logger = 
org.apache.log4j.Logger.
@@ -60,33 +61,40 @@
     final JahiaData jData = (JahiaData) 
request.getAttribute("org.jahia.data.JahiaData");
     final JahiaContainer theEditedContainer = (JahiaContainer) 
engineMap.get("theContainer");
     final int listID = theEditedContainer.getListID();
-    final Vector ctnIds = (Vector) 
session.getAttribute("getSorteredAndFilteredCtnIds" + listID);
-    final boolean enableForAdd = ctnIds != null && ctnIds.size() > 0;
-    final boolean enableForUpdate = ctnIds != null && ctnIds.size() > 1;
+    Vector ctnIds = (Vector) 
session.getAttribute("getSorteredAndFilteredCtnIds" + listID);
+    if (ctnIds == null) {
+        ctnIds = new Vector();
+        session.setAttribute("getSorteredAndFilteredCtnIds" + listID, ctnIds);
+    }
+    final boolean enableForAdd = ctnIds.size() > 0;
+    final boolean enableForUpdate = ctnIds.size() > 1;
     final boolean enableNext = enableForAdd && theEditedContainer.getID() != 
((Integer) ctnIds.get(ctnIds.size() - 1)).intValue();
     final boolean enablePrevious = enableForAdd && theEditedContainer.getID() 
!= ((Integer) ctnIds.get(0)).intValue();
     final boolean isAddContainer = 
engineMap.get(JahiaEngine.ENGINE_NAME_PARAM).equals(AddContainer_Engine.ENGINE_NAME);
     final boolean enableNavigation = isAddContainer ? enableForAdd : 
enableForUpdate;
+    final boolean isLocked = jspSource.equals("lock");
 %>
 
 <script type="text/javascript">
     function navigate(goTo) {
+        document.mainForm.navigation.value = goTo;
     <% if (isAddContainer && enablePrevious) {
+        session.setAttribute("Navigation", "Navigation");
         final JahiaContainer cont = 
ServicesRegistry.getInstance().getJahiaContainersService().
             loadContainer(((Integer)ctnIds.get(0)).intValue(), LoadFlags.ALL, 
jData.getProcessingContext());
         final JahiaContainer cont2 = 
ServicesRegistry.getInstance().getJahiaContainersService().
             loadContainer(((Integer)ctnIds.get(ctnIds.size() - 1)).intValue(), 
LoadFlags.ALL, jData.getProcessingContext());
     %>
+        sendFormSaveAndAddNew();
         if (goTo == "first") {
-            <%=jData.gui().html().drawUpdateContainerLauncher(cont)%>;
+            document.location.href = 
"<%=jData.gui().drawUpdateContainerUrl(cont)%>";
         } else {
-            <%=jData.gui().html().drawUpdateContainerLauncher(cont2)%>;
+            document.location.href = 
"<%=jData.gui().drawUpdateContainerUrl(cont2)%>";
         }
-        CloseJahiaWindow("yes");
     <% } else { %>
-        document.mainForm.navigation.value = goTo;
         sendFormApply();
     <% } %>
+        submittedCount++;
     }
 </script>
 
@@ -139,7 +147,7 @@
         <% if (isAddContainer) { %>
         <a href="javascript:sendFormSaveAndAddNew();" 
onclick="javascript:setWaitingCursor(1);">
         <% } else { %>
-        <a 
href="javascript:sendFormApply();<%=jData.gui().html().drawAddContainerLauncher((JahiaContainerList)session.getAttribute("getSorteredAndFilteredCtnIdsList"
 + listID))%>;CloseJahiaWindow('yes');">
+        <a 
href="javascript:<%if(!isLocked){%>sendFormApply();<%}%>submittedCount++;document.location.href='<%=jData.gui().drawAddContainerUrl((JahiaContainerList)session.getAttribute("getSorteredAndFilteredCtnIdsList"
 + listID))%>';">
         <% } %>
             <img alt='<jahia:engineResourceBundle 
resourceName="org.jahia.engines.addcontainer.AddContainer.label"/>'
                  title='<jahia:engineResourceBundle 
resourceName="org.jahia.engines.addcontainer.AddContainer.label"/>'
@@ -211,7 +219,7 @@
         <% if (isAddContainer) { %>
         <a href="javascript:sendFormSaveAndAddNew();" 
onclick="javascript:setWaitingCursor(1);">
         <% } else { %>
-        <a 
href="javascript:sendFormApply();<%=jData.gui().html().drawAddContainerLauncher((JahiaContainerList)session.getAttribute("getSorteredAndFilteredCtnIdsList"
 + listID))%>;CloseJahiaWindow('yes');">
+        <a 
href="javascript:<%if(!isLocked){%>sendFormApply();submittedCount++;<%}%>document.location.href='<%=jData.gui().drawAddContainerUrl((JahiaContainerList)session.getAttribute("getSorteredAndFilteredCtnIdsList"
 + listID))%>';">
         <% } %>
             <img alt='<jahia:engineResourceBundle 
resourceName="org.jahia.engines.addcontainer.AddContainer.label"/>'
                  title='<jahia:engineResourceBundle 
resourceName="org.jahia.engines.addcontainer.AddContainer.label"/>'

Modified: trunk/core/src/webapp/jsp/jahia/javascript/jahia.js
URL: 
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/javascript/jahia.js&rev=14895&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/javascript/jahia.js (original)
+++ trunk/core/src/webapp/jsp/jahia/javascript/jahia.js Tue Aug 15 10:52:43 2006
@@ -149,74 +149,61 @@
     if (CloseJahiaWindow.arguments.length > 1) {
         params = CloseJahiaWindow.arguments[1];
     }
-
-    var theMainWindow;
-    if (window.opener && window.opener.opener) {
-        theMainWindow = window.opener.opener;
-    } else {
-        theMainWindow = window.opener;
+    var oldUrl = window.opener.location.href;
+    var pos = oldUrl.indexOf("&engine_params");
+    if (pos != -1) {
+        oldUrl = oldUrl.substring(0, pos);
     }
 
-    if (theMainWindow) {
-        var oldUrl = theMainWindow.location.href;
-        var pos = oldUrl.indexOf("&engine_params");
-        if (pos != -1) {
-            oldUrl = oldUrl.substring(0, pos);
-        }
+    var pos2 = oldUrl.indexOf("#");
+    var anchorVal = oldUrl.substring(pos2, oldUrl.length);
 
-        var pos2 = oldUrl.indexOf("#");
-        var anchorVal = oldUrl.substring(pos2, oldUrl.length);
+    if (pos2 != -1) {
+        oldUrl = oldUrl.substring(0, pos2);
+    }
+
+    var newUrl = "";
 
+    if (oldUrl.indexOf("?") != -1) {
+        newUrl = oldUrl;
         if (pos2 != -1) {
-            oldUrl = oldUrl.substring(0, pos2);
+            newUrl = newUrl + anchorVal;
         }
-
-        var newUrl = "";
-
-        if (oldUrl.indexOf("?") != -1) {
-            newUrl = oldUrl;
-            if (pos2 != -1) {
-                newUrl = newUrl + anchorVal;
-            }
-        } else {
-            newUrl = oldUrl;
-            if (pos2 != -1) {
-                newUrl = newUrl + anchorVal;
-            }
+    } else {
+        newUrl = oldUrl;
+        if (pos2 != -1) {
+            newUrl = newUrl + anchorVal;
         }
-        if (params != "") {
-            newUrl += params;
-            if (pos2 != -1) {
-                newUrl = newUrl + anchorVal;
-            }
+    }
+    if (params != "") {
+        newUrl += params;
+        if (pos2 != -1) {
+            newUrl = newUrl + anchorVal;
         }
     }
 
     //alert( "Refreshing window with url :\n" + newUrl +"\n params: "+params+ 
"refreshOpener = "+refreshOpener);
     try {
-        if (window.opener && window.opener.opener) {
-            theMainWindow = window.opener.opener;
-        }
         if (params.indexOf("submit") != -1) {
             if (refreshOpener.indexOf("yes") != -1) {
-                if (theMainWindow != null) {
-                    theMainWindow.document.forms[0].submit();
+                if (window.opener != null) {
+                    window.opener.document.forms[0].submit();
                 }
             } else {
-                theMainWindow.refreshMonitor();
+                window.opener.refreshMonitor();
             }
-            window.close();
-            delete window;
-            myEngineWin = null;
         } else {
             if (refreshOpener.indexOf("yes") != -1) {
-                theMainWindow.location.href = newUrl;
+                window.opener.location.href = newUrl;
             } else {
-                theMainWindow.refreshMonitor();
+                window.opener.refreshMonitor();
             }
-            oldLoc = theMainWindow.location;
+            oldLoc = window.opener.location;
             WaitForRefresh();
         }
+        window.close();
+        delete window;
+        myEngineWin = null;
     } catch (ex) {
         myEngineWin = null;
         window.close();
@@ -227,21 +214,18 @@
 
 // saveAndAddNew
 function saveAndAddNew(url, refreshOpener) {
-    if (window.opener) {
-        var engineWin = window.opener.myEngineWin;
-        window.opener.myEngineWin = null;
-
-        //if ( refreshOpener == "yes" ){
-        //window.opener.location.href = 
defineMatrixParam(window.opener.location.href);
-        //}
-        oldLoc = window.opener.location;
-        while (window.opener.location != null
-                && (oldLoc != window.opener.location)) {
-            setTimeout("", 1000);
-        }
-        window.opener.myEngineWin = engineWin;
-    }
+    var engineWin = window.opener.myEngineWin;
+    window.opener.myEngineWin = null;
     window.location.href = url;
+    //if ( refreshOpener == "yes" ){
+    //window.opener.location.href = 
defineMatrixParam(window.opener.location.href);
+    //}
+    oldLoc = window.opener.location;
+    while (window.opener.location != null
+            && (oldLoc != window.opener.location)) {
+        setTimeout("", 1000);
+    }
+    window.opener.myEngineWin = engineWin;
 }
 
 

Reply via email to