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 107914 - Generated javascript of dropdown component in 5.5 Project is not migrated properly in NB6
Summary: Generated javascript of dropdown component in 5.5 Project is not migrated pro...
Status: RESOLVED WONTFIX
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Matthew Bohm
URL:
Keywords: RELNOTE
Depends on:
Blocks:
 
Reported: 2007-06-23 02:50 UTC by Yousuf Haider
Modified: 2007-10-29 23:32 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yousuf Haider 2007-06-23 02:50:54 UTC
NB Build: 200706220000
JDK6

Steps To reproduce:
1. Create EE5 VW Project in NB5.5

2. Drag a drop down list to the page and set it to Auto-Submit. At this point the onChange Property of the component
will have the following javascript code: 

webuijsf.suntheme.common.timeoutSubmitForm(this.form, 'dropDown1'); 

3. Now import this project in NB6. 
  - First,  Right click on the dropDown list and see that the AutoSubmit property is no longer set.
  - Clean and build project and run the project. Auto Submit will not work.
  - Now right click on the dropDown and set it to AutoSubmit. At this point the javascript in onChange property of the 
    component becomes this:

webuijsf.suntheme.common.timeoutSubmitForm(this.form, 'dropDown1'); 
webui.suntheme.common.timeoutSubmitForm(this.form, 'dropDown1'); 

A new javascript snippet is appended to the original code. This will not work either. 


Remove the first entry (i.e. the one starting with webuijsf) and then deploy. Now the auto submit will work.


Apparently the javascript code that is generated by NB5.5 is slightly different from the one generated by NB6 and 5.5.1
because the themes were updated.

As a consequence of this, project migration will fail for projects created in 5.5 that contain our generated javascript
code.

I think Project migration should  refactor all occurrences of 'webuijsf' to 'webui' when project is opened to resolve
this issue.


Also see issue filed here: http://www.netbeans.org/issues/show_bug.cgi?id=93775
and similar problem  that a user experienced on nabble :
http://www.nabble.com/VWP-auto-submit-dropdown-list-tf3800499.html#a10752734
Comment 1 Matthew Bohm 2007-06-25 21:49:32 UTC
This is really about project migration. I do not consider this a P1, so downgrading.
Comment 2 Yousuf Haider 2007-06-25 22:34:43 UTC
This issue will effect all components that can be set to Auto-submit such as the listbox, checkbox group, radio button
group, calendar, textField etc. 

Comment 3 Matthew Bohm 2007-07-03 05:03:39 UTC
wjprakash informs me that we are not modifying project source, so he recommends we fix the toggling behavior to remove
appropriate javascript that uses the old namespacing as well as the new. Below is the proposed fix. This means the user
can toggle auto submit off and then on to ensure that correct javascript is used.

Index: src/designtime/com/sun/webui/jsf/component/customizers/AutoSubmitOnChangeAction.java
===================================================================
RCS file: /cvs/woodstock/webui/src/designtime/com/sun/webui/jsf/component/customizers/AutoSubmitOnChangeAction.java,v
retrieving revision 1.2
diff -u -r1.2 AutoSubmitOnChangeAction.java
--- src/designtime/com/sun/webui/jsf/component/customizers/AutoSubmitOnChangeAction.java	5 Mar 2007 18:59:51 -0000	1.2
+++ src/designtime/com/sun/webui/jsf/component/customizers/AutoSubmitOnChangeAction.java	3 Jul 2007 03:52:37 -0000
@@ -50,7 +50,7 @@
 public class AutoSubmitOnChangeAction extends BasicDisplayAction implements
         CheckedDisplayAction {
     
-    private static Pattern submitPattern;
+    private static Pattern submitPattern, legacyPattern;
     
     private static Pattern getSubmitPattern() {
         if (submitPattern == null) {
@@ -60,6 +60,14 @@
         return submitPattern;
     }
     
+    private static Pattern getLegacyPattern() {
+        if (legacyPattern == null) {
+            legacyPattern = Pattern.compile(
+                   
"webuijsf\\.\\w+\\.common\\.timeoutSubmitForm\\s*\\(\\s*this\\s*\\.\\s*form\\s*,\\s*'\\S+'\\s*\\)\\s*;?"); //NOI18N
+        }
+        return legacyPattern;
+    }
+    
     protected DesignBean bean;
     
     public AutoSubmitOnChangeAction(DesignBean bean) {
@@ -78,12 +86,22 @@
     
     public boolean isAutoSubmit() {
         DesignProperty property = getSubmitProperty();
-        if (property == null)
+        if (property == null) {
             return false;
+        }
         String value = (String) property.getValue();
-        if(value == null)
+        if(value == null) {
             return false;
-        return getSubmitPattern().matcher(value).find();
+        }
+        boolean valueMatchesSubmitPattern = getSubmitPattern().matcher(value).find();
+        if (valueMatchesSubmitPattern) {
+            return true;
+        }
+        else {
+            // no match against submit pattern.
+            // return true if matches legacy pattern, false otherwise.
+            return getLegacyPattern().matcher(value).find();
+        }
     }
     
     public Result toggleAutoSubmit() {
@@ -97,7 +115,10 @@
         } else {
             if (isAutoSubmit()) {
                 // If property value contains the onSubmit script, remove it
-                property.setValue(getSubmitPattern().matcher(value).replaceFirst("")); //NOI18N
+                String newValue = getSubmitPattern().matcher(value).replaceFirst(""); //NOI18N
+                // also remove the legacy pattern
+                newValue = getLegacyPattern().matcher(newValue).replaceFirst(""); //NOI18N
+                property.setValue(newValue);
             } else {
                 // Otherwise, append the onSubmit script
                 property.setValue(getSubmitScript(value));
Comment 4 Matthew Bohm 2007-07-09 20:55:15 UTC
I have integrated the fix.
Comment 5 Yousuf Haider 2007-08-08 18:44:58 UTC
The current fix requires that the user toggle Auto-Submit for all components that were set to auto-submit in NB5.5. 

For large projects that contain many pages with components set to auto-submit, migration becomes an extremely cumbersome
process instead of a seamless experience because the user will have to manually toggle auto-submit on and off for each
component.

Comment 6 Matthew Bohm 2007-08-09 19:54:39 UTC
This was the technical decision we made given the circumstances. I have to mark this wontfix.