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.
In our testing libraries we use DataObject.setModified(false) to discard changes before closing editor. But it doesn't work with org.netbeans.modules.visualweb.project.jsfloader.JsfJspDataObject. Page remains modified in spite we call this method. Build 200703011900, JDK1.5.0_10.
This is stopper for automated tests for Web Designer. If we are not able to close the file without saving the changes we did during the test we are not able to start the test again.
Passing to the owner.
Is there an available test case or some code that exhibits this problem? Normal usage in the IDE discards changes correctly.
Modify Page1.jsp location and assign the following code to a toolbar button or menu item: String a = "D:\\WebApplication1\\web\\Page1.jsp"; FileObject fo = FileUtil.toFileObject(new File(a)); JsfJspDataObject dob = (JsfJspDataObject)JsfJspDataObject.find(fo); System.out.println("DOB="+dob); dob.setModified(false); Modify the page (add a component from palette) and call the code. Nothing happens and the page is still marked as modified.
The visual designer uses two different DataObjects in the editor (one for the .java and one for the .jsp). In order to discard all the changes, the corresponding JsfJavaDataObject needs to be unmodified as well; use org.netbeans.modules.visualweb.project.jsfloader.Util.findJavaForJsp(FileObject) to find the right java file.
In our testing library we just call DataObject.setModified(false) and we don't need to know what kind of DataObject it is. It works for example for FormDataObject which is also MultiDataObject. So, I hope you can fix it.
The form designer works differently because it only modifies a single editable file (the .form is not accessible from the IDE). In our case, the .jsp and .java files are independently modifiable, so calling JsfJspDataObject.setModified(false) should not unmodify the .java file.
So, there is no real MultiDataObject but two separarate-like DataObjects which know about each other. Then it is hard to implement 'close discard' action some general way. It probably need to be hard-coded for JsfJsp/JsfJavaDataObject. But there is another problem that Java view TopComponent doesn't activate node and TopComponent.getActivatedNodes() returns an empty array. You can test it manually, if you click to editor when Page1 is opened in Java view, the Navigator is empty. If you click Page1.java node in Projects view, the Navigator gets populated. And That's why we can't get DataObject from java editor TopComponent.
The activated node switching for the java tab was fixed last week so it should no longer be an issue.
Closing this, since the visualweb dataloader architecture will not be changed in the near future and a workaround exists.
OK, verifying.