changeset:   42:98622d6214ed
branch:      5.2
user:        Anahide Tchertchian <at@nuxeo.com>
date:        Tue May 05 19:44:15 2009 +0200
summary:     NXP-3499: Fix error when navigating from a page with a read-only chain select

diff --git a/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelect.java b/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelect.java
--- a/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelect.java
+++ b/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelect.java
@@ -45,9 +45,9 @@
  * DOCUMENT ME.
  * <p>
  * Refactor me and it's christmas.
- *
+ * 
  * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a>
- *
+ * 
  */
 public class ChainSelect extends UIInput {
 
@@ -202,6 +202,10 @@
 
     @Override
     public void decode(FacesContext context) {
+        if (getDisplayValueOnly()) {
+            return;
+        }
+
         setValid(true);
         rebuildOptions();
 
@@ -344,9 +348,7 @@
     }
 
     public void setSelections(Selection[] sels) {
-        if (displayValueOnly == null || !displayValueOnly) {
-            selections = sels;
-        }
+        selections = sels;
     }
 
     public Integer getSize() {
@@ -372,11 +374,16 @@
      * reset. We only have to rebuild options for position k+1.
      */
     public void rebuildOptions() {
-        /*
-         * for (int i = 0; i < size; i++) { if (optionList[i] != null) {
-         * continue; } if (i == 0 || (selections.length != 0 &&
-         * selections[0].getColumnValue(i - 1) != null)) { rebuildOptions(i); } }
-         */
+        // for (int i = 0; i < size; i++) {
+        // if (optionList[i] != null) {
+        // continue;
+        // }
+        // if (i == 0
+        // || (selections.length != 0 && selections[0].getColumnValue(i - 1) !=
+        // null)) {
+        // rebuildOptions(i);
+        // }
+        // }
     }
 
     private void rebuildOptions(int index) {
@@ -418,9 +425,8 @@
                 }
             }
 
-            // // XXX : remove this section
+            // XXX : remove this section
             if (child instanceof UIRepeat) {
-                // ((UIRepeat)child).g
                 List<UIComponent> children2 = child.getChildren();
                 for (UIComponent child2 : children2) {
                     if (!(child2 instanceof ChainSelectListboxComponent)) {
@@ -459,7 +465,10 @@
     }
 
     public Boolean getDisplayValueOnly() {
-        return displayValueOnly;
+        if (displayValueOnly != null) {
+            return displayValueOnly;
+        }
+        return false;
     }
 
     public void setDisplayValueOnly(Boolean displayValueOnly) {
@@ -527,7 +536,7 @@
                         rows[i] = String.valueOf(valueList.get(i));
                     }
                 } else {
-                    rows = new String[]{};
+                    rows = new String[] {};
                 }
             } else {
                 rows = new String[] { (String) value };
diff --git a/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelectListboxComponent.java b/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelectListboxComponent.java
--- a/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelectListboxComponent.java
+++ b/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/ChainSelectListboxComponent.java
@@ -399,9 +399,13 @@
     @Override
     public void decode(FacesContext context) {
 
+        ChainSelect chain = getChain();
+        if (chain.getDisplayValueOnly()) {
+            return;
+        }
+        
         index = getIndex();
 
-        ChainSelect chain = getChain();
         chain.setCompAtIndex(index, this);
         List<String> keyList = chain.getSelectionKeyList();
         int size = chain.getSize();
diff --git a/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/SelectOneListboxRenderer.java b/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/SelectOneListboxRenderer.java
--- a/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/SelectOneListboxRenderer.java
+++ b/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/directory/SelectOneListboxRenderer.java
@@ -49,6 +49,10 @@
     public void decode(FacesContext facesContext, UIComponent component) {
         // String compId = component.getClientId(facesContext);
         SelectOneListboxComponent comp = (SelectOneListboxComponent) component;
+        if (comp.getDisplayValueOnly()) {
+            return;
+        }
+       
         String id = comp.getClientId(facesContext);
 
         Map<String, String> requestMap = facesContext.getExternalContext().getRequestParameterMap();

