Visual MainWin Crosses the .NET-Java Divide - ' Creating Web Applications ' (
Page 2 of 2 )
Creating Web Applications
For most developers, the main event is the Web application. Visual MainWin comes with four excellent demonstration applications, and you can download a fifth from their Web site. The
best way to use the four standard examples, I found, is to open their entry in the help file and use the help file to guide you to getting things set up. The instructions worked well and soon I was running the application with only a little effort.
ADVERTISEMENT
When creating my own application, I started out with the Tomcat server that comes with Visual MainWin.
When you create a project, you won't see much difference in the code you write; the code is amazingly close to what you'd write for any ASP.NET application. What is different is the way you add references. A .NET application lets you choose from a variety of local references, including COM and .NET components as well as the global references found in the GAC using the Project | Add Reference command.
When you work with Visual MainWin, you choose from local references: those local to the project, Web references (using Web services is precisely the same as working with .NET applications), Java references, and Enterprise Java Bean (EJB) references. To add a new assembly to your application, such as System.Drawing, you choose the Add Java Reference command. Note that this same dialog box gives you access to Java-specific features that you might need to include within the project; however, you don't have access to COM objects. This feature makes sense, because you're creating a Java application. Developers will need to adjust to this difference.
Unfortunately, you can't use the EJB reference option when working with the supplied Tomcat server; you need a third party product, such as WebSphere. This isn't a limitation with Visual
MainWin. It's simply a function of the application server.
Adding controls to a form is precisely the same as the process for a .NET application. The IDE defaults to the grid layout. Make any changes to the page layout using the Designer Defaults tab of the application Property Pages dialog box (accessed using the Project | Application Properties command) as you normally would when you want to use the flow layout.
The control all appear to work as normal, but I did run across an oddity. When creating accessible Web pages — those that work well with aids such as screen readers — you need to define the AssociatedControlID property for any labels you add to the form. When you attempt to compile the application, the compiler states that the property is invalid. This particular problem could be an issue for developers who work on government projects, since many governments, including the US Government, have passed laws requiring the inclusion of accessibility features on Web sites. According to the company, Visual Mainwin currently supports section 508 compliance through the Infragistics NetAdvantage ASP.NET web controls, and will support ASP.NET Web form controls with section 508 compliance in the next maintenance release.
I didn't find any other properties missing during my tests, but your mileage may vary. In all other ways, my test applications worked as expected.
The configured application servers located in the Options dialog box (select Tools | Options to view it, and then select the Visual MainWin folder) are hard coded. When you configure a new application server for the Java application, all of the settings are set in stone. One of these settings is the projects directory. Consultants who work for a number of customers will find themselves setting up a new server configuration every time they want to
change projects since you can have only one entry per application server. One method around this problem is to create hierarchies of subfolders to hold the data, but this isn't the best way to do things because you still have everything running on one drive. Admittedly, given the way that Visual MainWin currently configures IIS to act as an intermediary, it would be very hard to make this setting easy to change. Interestingly, you can change the username, password, and debug port values.
I tried several performance tests and found the results inconclusive. Visual MainWin appears to produce code that's slightly slower than you can get by hand-coding the project, in
many cases, but the effects aren't very noticeable when coupled with expected display times. Yes, you can create console applications that definitely show a small performance loss, but my
testing indicates that users probably won't notice the difference. The performance likely varies by system and will depend on the amount of resource you have to supply to the application — more memory is better. (Isn't it always?)
Working with WebSphere
If you plan to use EJB in your applications, you must have an application server such as WebSphere. During the review, I tried a system that just had Tomcat installed and a second system with both the Tomcat and WebSphere installed. Both scenarios worked great. Of course, adding WebSphere to your server does increase the complexity another level, so there's always a chance that you'll run into problems.
When working with something other than the Tomcat application server, you must register the server with Visual MainWin. Otherwise, it won't recognize the servereven if you do get the
port number right. The error message is vague; it tells you that you have to register the server, but not what registration means or how to do it. To perform this task, you need to choose the Tools | Options command to display the Options dialog box. You'll find the new Visual MainWin folder shown in Figure 2. This figure shows Visual MainWin configured with both Tomcat (port 8080) and the WebSphere (port 9080).
Figure 2: Make sure you register any application server you want to use.
The WebSphere projects worked every bit as well as those on Tomcat, but seemed to take a lot longer to configure and start. Debugging was also a lot slower. The code itself ran about the same speed and that's what counts most when you think about it.
The big event for WebSphere is working with EJB. To create an EJB reference, you need to locate the appropriate JAR file. I used the BasicCalculatorEJB.JAR file located in the \Program Files\WebSphere\AppServer\samples\lib\TechnologySamples folder.
Right click the References folder and choose Add EJB Reference from the context menu. You'll need to add the JAR name to the Java Archive field and then click Fetch From Server.
Figure 3 shows a completed addition. Click OK and you'll see the reference added to the project. The amazing thing is that you're using EJB inside Visual Studio .NET and it looks just like a standard .NET class. For this test, I created a basic four-function calculator, and it worked great.
Bottom Line
I wish I could have spent more time telling you about this product, but it could require a book to do the job completely. For all its complexity and the odd things you need to consider when working with it, I feel that Visual MainWin works exceptionally well. Although not everything is perfect, I can honestly say that this is a great tool for mixed developer environments and for consultants who want to expand the kinds of applications they offer to clients.
The important issues to consider are getting a good initial configuration and learning to use the new tools you need to manage both .NET and Java applications. Considering you get all of this functionality without learning a new language, you really can save considerable time and resources by using it.
John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 65 books and over 300 articles to date. The topics range from networking to artificial intelligence and from database management to heads down programming. His most recent book is FrontPage for Dummies (Wiley, ISBN: 0764575318). His technical editing skills have helped over 35 authors refine the content of their manuscripts. You can reach John on the Internet at JMueller@mwt.net and his Web site at: http://www.mwt.net/~jmueller/.