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 109426 - There is no error checking for adding framework
Summary: There is no error checking for adding framework
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-11 21:23 UTC by _ potingwu
Modified: 2008-07-14 10:01 UTC (History)
3 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 _ potingwu 2007-07-11 21:23:59 UTC
When creating a new web project, under Frameworks wizard, if there is error (e.g., wrong Servlet URL Mapping for
JavaServer Faces framework), then the panel shows an error mesg and disable the Finish button. This is good!

But if users want to add framework by using the Project Properties window, with the same error, the panel does not show
the error mesg, the OK button is still enabled, and the users can continue to add the framework but got error later!
Comment 1 _ potingwu 2007-07-11 21:26:11 UTC
BTW, I think this is a P2 bug because after the error, the framework is not working properly and difficult to fix sometimes.
Comment 2 Tomas Mysik 2007-08-01 14:09:25 UTC
Fixed.

Checking in src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.form;
/cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.form,v  <--  
CustomizerFrameworks.form
new revision: 1.6; previous revision: 1.5
done
Checking in src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java;
/cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v  <--  
CustomizerFrameworks.java
new revision: 1.11; previous revision: 1.10
done
Checking in src/org/netbeans/modules/web/project/ui/customizer/WebCompositePanelProvider.java;
/cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/WebCompositePanelProvider.java,v  <--  
WebCompositePanelProvider.java
new revision: 1.2; previous revision: 1.1
done
Comment 3 _ potingwu 2007-09-11 20:18:17 UTC
Thanks for this fix! There are still 3 issues happened when adding the Visual Web framework.

1. Since Visual Web sometimes cannot be added before users adding some plugin, the panel should check the 'isValid'
method even before users type/change the settings. The patch/fix is simply add the checking when initializing
FrameworkConfigurationPanelListener as follows:

===================================================================
RCS file: /cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v
retrieving revision 1.12
diff -u -r1.12 CustomizerFrameworks.java
@@ -262,6 +262,8 @@
             wizardDescriptor.putProperty("j2eeLevel", j2eeVersion);
             wizardDescriptor.putProperty("serverInstanceID", serverInstanceID);
             frameworkConfigurationPanel.readSettings(wizardDescriptor);
+
+            stateChanged(new ChangeEvent(this));
         }
 
         public void stateChanged(ChangeEvent e) {


2. Looks like the error mesg cannot handle the HTML tags! Since the New Project wizard can handle the HTML tags, I think
the Project Properties should do the same. Otherwise, I see some tags like <html> inside the error mesg area.

3. When creating a new project, the framework can get the project info from the wizardDescriptor.getProperty("projdir")
and do some checking for isValid method. But from the Project Properties, this property is missing! Could you please add
this property (or even the 'Project' object) so that the framework can use it for checking. Thanks!
Comment 4 Tomas Mysik 2007-09-17 13:33:32 UTC
> 1. Since Visual Web sometimes cannot be added before users adding some
> plugin, the panel should check the 'isValid' method even before users
> type/change the settings. The patch/fix is simply add the checking when
> initializing FrameworkConfigurationPanelListener as follows:
>
> ===================================================================
> RCS file:
> /cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/Customi
>zerFrameworks.java,v retrieving revision 1.12
> diff -u -r1.12 CustomizerFrameworks.java
> @@ -262,6 +262,8 @@
>              wizardDescriptor.putProperty("j2eeLevel", j2eeVersion);
>              wizardDescriptor.putProperty("serverInstanceID",
> serverInstanceID);
> frameworkConfigurationPanel.readSettings(wizardDescriptor); +
> +            stateChanged(new ChangeEvent(this));
>          }
>
>          public void stateChanged(ChangeEvent e) {
>

Done as suggested.
Checking in src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java;
/cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v  <--  
CustomizerFrameworks.java
new revision: 1.13; previous revision: 1.12
done

>
> 2. Looks like the error mesg cannot handle the HTML tags! Since the New
> Project wizard can handle the HTML tags, I think the Project Properties
> should do the same. Otherwise, I see some tags like <html> inside the error
> mesg area.
>
This has to be done in Project UI API module, not in the Web module - so file an issue against that module please.

> 3. When creating a new project, the framework can get the project info from
> the wizardDescriptor.getProperty("projdir") and do some checking for
> isValid method. But from the Project Properties, this property is missing!
> Could you please add this property (or even the 'Project' object) so that
> the framework can use it for checking. Thanks!

I've discussed this with Petr Pisl and you should not rely on such information. It's not API so it can change any time 
and we cannot ensure that this information will always be available. Any other comments Petr?
Comment 5 _ potingwu 2007-09-17 17:46:40 UTC
Thanks for the integration! I have also filed a bug against project UI.

Should web project gives some way (even a private way that visualweb can use as I requested before; like "projdir") to
pass the underneath project to the framework? I think it's very needed functionality for the framework use to check
whether the project is suitable to add the framework or not. Thanks!
Comment 6 _ potingwu 2007-09-17 17:55:05 UTC
BTW, I think the web project also does the similar in:
    RCS file: /cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v
    @@ -262,6 +262,8 @@
             wizardDescriptor.putProperty("j2eeLevel", j2eeVersion);
             wizardDescriptor.putProperty("serverInstanceID", serverInstanceID);

passing j2eeLevel and serverInstanceID for checking the JSF libraries, I think 'Project' is also very needed here for
framework to validate the extend condition.
Comment 7 _ potingwu 2007-09-21 18:24:42 UTC
> we cannot ensure that this information will always be available

Could you please add the following line in,
         RCS file: /cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v
         @@ -73,6 +73,7 @@
             Properties properties = controller.getProperties();
             properties.setProperty("j2eeLevel", j2eeVersion); // NOI18N
             properties.setProperty("serverInstanceID", serverInstanceID); // NOI18N
    +        properties.setProperty("project", project); // NOI18N

I think the Project object is pretty available here. Visual Web has several issues for checking the condition whether to
allow adding the framework or not by using the Project object. I believe the other framework will also need this for
validating. Looks like it's also pretty safe to passing this property. If this object is not available (I can't think of
any corner case has this situation), passing null is still OK because the framework should check the availability easily.

Thanks!
Comment 8 Tomas Mysik 2007-09-24 14:54:54 UTC
Property added, please verify.

Checking in src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java;
/cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v  <--  
CustomizerFrameworks.java
new revision: 1.15; previous revision: 1.14
done
Comment 9 Andrei Badea 2007-09-24 16:20:32 UTC
I'm sorry, but I disagree with the last commit so I am reverting it. When extending a web module you should not even
need to know which project it is in. What information do you exactly need from the project? Can't you obtain it from the
WebModule? The reason I'm asking is that there is probably some API missing from WebModule. I want to know which API
exactly.

Checking in src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java;
/cvs/web/project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerFrameworks.java,v  <-- 
CustomizerFrameworks.java
new revision: 1.16; previous revision: 1.15
done
Comment 10 Tomas Mysik 2007-09-24 16:25:58 UTC
After the discussion reassigning to Andrei.
Comment 11 _ potingwu 2007-09-24 19:34:42 UTC
Visual Web needs to check,
1. whether the target project has valid Source Folder or not, it can't add its page bean file (Java file) to it if the
target project does not have valid Source Folder. It needs "Sources src = ProjectUtils.getSources(Project);" and
"SourceGroup[] grp = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);" ...
2. it needs to check the Source Level of the target project. When the target project's source level is 1.4, then it
needs to check whether the IDE has some needed libraries available. Otherwise, it will need to ask the users to get the
Visual Web kit.

The point is, framework is usually need to check several conditions for method valid() to see whether the target project
is ready to add this framework or not. (currently the checking for many other frameworks are just been ignored! One
reason is they can't do this check without more info like the Project object.) The NetBeans web JSF framework needs 2
properties "j2eeLevel" and "serverInstanceID" and the web project adds them here. That's not fair to other framework :-)
The web project should not add some selected individual properties just because some framework need them. It should also
include the Project object for the framework.

I really don't see any risk here by passing the Project object. I don't think any framework can break the whole
structure here just because they can at least read/use the Project.
Comment 12 Andrei Badea 2007-09-25 09:52:12 UTC
For #1: is WebModule.getJavaSources() enough for you? If not, why? (I know the method is deprecated. That's because 1)
it is not currently called by NetBeans code 2) it needs to return something better than FileObject. But you can safely
call it.)

For #2: use SourceLevelQuery on the FileObject returned by #1.

Generally, the frameworks should know nothing about projects. They should only work with WebModule's. The project might
still be added to ExtenderController's properties, but only as the last resort.

Regarding the j2eeLevel and serverInstanceId, you're right. There's some missing API there. But passing the project is
no solution to that (note, for example, that there is no project available when the WebModuleExtender is invoked from
the New Project wizard).
Comment 13 _ potingwu 2007-09-25 17:14:37 UTC
I'm confused here! I don't see there is any way to get the WebModule from these classes. Visual Web somehow forked the
following 2 classes from web/jsf but getting WebModule looks like not straightforward. Could you please give me some
hints here? Thanks!

  org.netbeans.modules.web.jsf.wizards.JSFConfigurationPanel extends WebModuleExtender
  org.netbeans.modules.web.jsf.wizards.JSFConfigurationPanelVisual extends javax.swing.JPanel
Comment 14 Andrei Badea 2007-09-25 18:35:37 UTC
JSFFrameworkProvider.createWebModuleExtender() gets the web module, you can then pass it to JSFConfigurationPanel as
another parameter to its constructor (i.e., along with the ExtenderController). Don't forget to read the Javadoc of
WebFrameworkProvider.createWebModuleExtender().
Comment 15 _ potingwu 2007-09-25 20:22:11 UTC
OK! Thanks! I got the idea.
Comment 16 josin 2008-07-14 10:01:42 UTC
Not reproducible, changing status to verified.

Product Version: NetBeans IDE Dev (Build 200807101204)
Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b11
System: Linux version 2.6.24-19-generic running on i386; UTF-8; en_US (nb)
Userdir: /home/josin/.netbeans/dev