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 93884

Summary: AJAX components can be added only for one project
Product: obsolete Reporter: bugbridge <bugbridge>
Component: visualwebAssignee: Peter Zavadsky <pzavadsky>
Severity: blocker CC: alexeybutenko, edwingo
Priority: P2 Keywords: RELNOTE
Version: 5.x   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description bugbridge 2007-02-01 22:31:26 UTC
Original status: 6-Fix Understood; Suggested Status: NEW

Original Target Release: shortfin_dev; Suggested Target Milestone : 5.5

These items should be added to the Keywords: RELNOTE

Original submitter: alexeybutenko

Pack RC1

 - Create project
 - Create second project
 - Add BluePrints AJAX Components library to the first project.
AJAX components doesn't appeared in Palette, it will appear only after adding
components library
to second project

Component import issue; assigning to Edwin.

Evaluation (Entry 2):
The bug is in designer code so I am reassigning this to PeterZ. The workaround
is to "Refresh Palette" from the palette category context menu.

Here is my analysis: This is a palette refresh problem. Each JsfForm seems to
have its own PaletteController. The PaletteController also has a PaletteFilter.
Whenever a new JsfForm is created, a new PaletteController and PaletteFilter is
created and a singleton ComplibListener is set to the last PaletteController
that was created. First this happens for project #1 then project #2. When the
user switches back to project #1, the Listener is still set to PaletteController
#2. So when a complib is added to project #1, the Listener notifies
PaletteController #2 instead of #1.

In that method, PaletteController.refresh() is called on the wrong

Evaluation (Entry 3):
Correct, the mistake is that the listener is singleton and notifies only last
palette congtoller used. Preparing fix.

Evaluation (Entry 4):
See suggested fix for the diff. It makes the bridge (renamed more
appropriatelly) to keep refs to all palette controllers and refresh them based
on changes in the comp lib.

The workaround is to "Refresh Palette" from the palette category context menu.

Suggested Fix:
Diff of suggested fix:

Index: xxx/designer/jsf/src/com/sun/rave/designer/jsf/
RCS file:
retrieving revision 1.1
diff -u -r1.1
--- designer/jsf/src/com/sun/rave/designer/jsf/   
13 Oct 2006 20:56:06 -0000      1.1
+++ designer/jsf/src/com/sun/rave/designer/jsf/   
28 Nov 2006 18:12:56 -0000
@@ -17,7 +17,8 @@
 import java.awt.event.ActionEvent;
-import java.lang.ref.WeakReference;
+import java.util.HashSet;
+import java.util.Set;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import org.netbeans.api.project.Project;
@@ -34,6 +35,7 @@
 import org.openide.nodes.Node;
 import org.openide.util.Lookup;
 import org.openide.util.NbBundle;
+import org.openide.util.WeakSet;

  * Factory for creating JSF <code>PaletteController</code>.
@@ -90,8 +92,8 @@
                     new JsfPaletteActions(paletteDirectory),
complibPaletteFilter, null);

             // XXX #6466711 Listening to changes of complib to refresh the palette.
-            JsfComplibListener.getDefault().install();
-            JsfComplibListener.getDefault().setPaletteController(controller);
+            JsfComplibListenerBridge.getDefault().install();
+            JsfComplibListenerBridge.getDefault().addPaletteController(controller);

             return controller;
         } catch (IOException ex) {
@@ -107,14 +109,14 @@

-    private static class JsfComplibListener implements ComplibListener {
-        private static JsfComplibListener INSTANCE = new JsfComplibListener();
+    private static class JsfComplibListenerBridge implements ComplibListener {
+        private static JsfComplibListenerBridge INSTANCE = new

-        private WeakReference<PaletteController> paletteControllerWRef = new
+        private final Set<PaletteController> paletteControllers = new

         private boolean installed;

-        public static JsfComplibListener getDefault() {
+        public static JsfComplibListenerBridge getDefault() {
             return INSTANCE;

@@ -139,18 +141,19 @@
             installed = false;

-        public void setPaletteController(PaletteController paletteController) {
-            paletteControllerWRef = new
+        public void addPaletteController(PaletteController paletteController) {
+            paletteControllers.add(paletteController);

         public void paletteChanged(ComplibEvent evt) {
-            PaletteController paletteController = paletteControllerWRef.get();
-            if (paletteController == null) {
-                return;
+            Set<PaletteController> controllers = new HashSet(paletteControllers);
+            for (PaletteController controller : controllers) {
+                if (controller != null) {
+                    controller.refresh();
+                }
-            paletteController.refresh();
-    } // End of JsfComplibListener
+    } // End of JsfComplibListenerBridge.

     // XXX Moved from designer/DesignerPaletteActions.
Comment 1 Peter Zavadsky 2007-02-20 21:51:51 UTC
This was fixed already.
Comment 2 Lark Fitzgerald 2007-04-27 22:56:05 UTC
verified using 6.0 04270000