This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 98558

Summary: wrong set selection component's default value code generated when
Product: obsolete Reporter: Sherry Zhou <sherryzhou>
Component: visualwebAssignee: Dongmei Cao <dongmeic>
Status: VERIFIED FIXED    
Severity: blocker    
Priority: P1    
Version: 6.x   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description Sherry Zhou 2007-03-21 19:39:19 UTC
M8

1. Add a listbox or other selection components
2. Right click at listbox and select Configure default options
3. Check selected items and choose item 2 as selected
-- Check Page1.java

  private void _init() throws Exception
{checkboxGroup1DefaultOptions.setOptions(new
com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("item1",
                                                                               
                                "Item 1"),
                                                new
com.sun.webui.jsf.model.Option("item2",
                                                                               
   "Item 2"),
                                                new
com.sun.webui.jsf.model.Option("item3",
                                                                               
   "Item 3")});
checkboxGroup1DefaultOptions.setSelectedValue((ERROR)  ? (ERROR)  ? (ERROR)  ?
(ERROR)
                                                                             :
(ERROR)
                                                                  : (ERROR)
                                                       : (ERROR));

    }
Comment 1 Sherry Zhou 2007-03-21 22:56:57 UTC
The generated code has compilation error. When remove these code and deploy the
project,  it shows nothing at browser. It happens on J2EE 4 and Java EE 5 project.
Comment 2 _ deva 2007-03-22 22:44:15 UTC
This bug occurs only in case of J2EE1.5 project. Upon debugging I found that 
OptionListCustomizer in case of J2EE1.5 project provides "???" to persist in 
java source which is incorrect

According to Dongmei this bug cannot be fixed in M8 because they have to 
update woodstock components which is lots of changes. Therefore downgrading 
the bug to P2
Comment 3 Lark Fitzgerald 2007-03-28 14:33:49 UTC
Reset this to a P1.  Did not assign it the to Stopper upbrella bug so it can 
be ignored for M8
Comment 4 Dongmei Cao 2007-04-12 05:40:49 UTC
Fixed checked in woodstock repository

User: dcao    
Date: 2007-04-12 04:21:59+0000
Log:
 Fix for issue http://www.netbeans.org/issues/show_bug.cgi?id=98558: implemented
 public String getJavaInitializationString()

File Changes:

Directory:
/woodstock/webui/src/designtime/com/sun/webui/jsf/component/propertyeditors/
=======================================================================================

File [changed]: SelectedValuesPropertyEditor.java
Url:
https://woodstock.dev.java.net/source/browse/woodstock/webui/src/designtime/com/sun/webui/jsf/component/propertyeditors/SelectedValuesPropertyEditor.java?r1=1.2&r2=1.3
Delta lines:  +19 -0
--------------------
--- SelectedValuesPropertyEditor.java	2007-02-28 22:47:39+0000	1.2
+++ SelectedValuesPropertyEditor.java	2007-04-12 04:21:57+0000	1.3
@@ -25,6 +25,7 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import com.sun.rave.propertyeditors.util.JavaInitializer;
 
 
 /**
@@ -42,6 +43,24 @@
         // Read-only
     }
 
+    public String getJavaInitializationString() {
+        StringBuffer buffer = new StringBuffer();
+        Object value = this.getValue();
+        if (value instanceof Object[]) {
+            buffer.append("new Object[] {");
+            Object[] values = (Object[]) value;
+            for (int i = 0; i < values.length; i++) {
+                if (i > 0)
+                    buffer.append(", ");
+               
buffer.append(JavaInitializer.toJavaInitializationString(values[i]));
+            }
+            buffer.append("}");
+        } else {
+            buffer.append(JavaInitializer.toJavaInitializationString(value));
+        }
+        return buffer.toString();
+    }
+
     public String getAsText() {
         Object value = this.getValue();
         if (value == null)
Comment 5 Sherry Zhou 2007-04-30 21:57:02 UTC
verified in netbeans M9 070430