Tuesday Dec 11, 2007

Add Custom Rake Tasks to NetBeans 6 Ruby IDE

As part of a demo, I wanted to deploy a Ruby on Rails application into a Rails Virtual Appliance using Capistrano. A Rails Virtual Appliance is a Virtual Machine that contains a complete stack of software from the Operating System up to Ruby on Rails itself. If you are using NetBeans 6 as your IDE, you can create a file such as $PROJECT/lib/tasks/demo.rake containing something like the following:

# Rake task to deploy to a production server for virtual appliance demo
# 2007-12-10eeg

# File that contains IP address of virtual appliance. If this file cannot
# be read, then the user will be prompted for the information.
TARGET_IP_FILE = '/ApplianceShare/ipfile.txt'

namespace :demo do
  desc 'Print the target IP address'
  task :print_target_ip do
    puts "Target host IP: #{get_target_host}"
  end

  desc 'Show the coolstack page'
  task :show_coolstack do
    sh "open http://#{get_target_host}/"
  end

  desc 'Show the main depot web application page'
  task :show_app do
    sh "open http://#{get_target_host}:8000/store/"
  end

  desc 'Deploy to production'
  task :deploy do
    target_host = get_target_host
    sh "cap -S target=#{target_host} deploy:setup"
    sh "cap -S target=#{target_host} deploy:cold"
  end

  desc 'Deploy and run the application'
  task :run => [:deploy, :show_app]
end

def get_target_host
  if File.readable?(TARGET_IP_FILE)
    f = File.new(TARGET_IP_FILE)
    line = f.readline
    host_ip = line.chomp
  else
    print "Target host: "
    line = $stdin.gets
    host_ip = line.chomp
  end
  host_ip
end

### Local Variables:
### mode: ruby
### End:

Note that the rake task uses sh to call Capistrano via the cap command to deploy the app into the production machine which in this case is a Virtual Appliance. Then, within NetBeans, you can invoke the context menu on the project node in the Projects Window and select "Run Rake Task" and navigate to the task you want to invoke. See this blog entry or wiki page for more information on NetBeans and Rake.

Friday May 04, 2007

Sample Ajax App with JMaki Yahoo AutoComplete Widget

In my last post, I talked about getting jMaki components to work in NetBeans from a component developer perspective. However, most IDE users are interested in how to build their own domain-specific app. I've created a demo script that uses a Yahoo YUI autocomplete widget to look words up in a dictionary. You can try it yourself because all the instructions are there, including all necessary downloads such as the latest NetBeans 6 M9 preview release. Alternatively if you have access to the JavaOne pavilion, you can ask for a demo at the NetBeans Visual Web booth. Tell 'em I sent you. :-). As I understand it, a pavilion pass is easier to get, though I don't know the details on how to get one.

Below is a screenshot of the app in the IDE.

Please note that the Yahoo component library is a work in progress and may not be product quality. However, it does show some of what is possible given enough resources.

JMaki Support for NetBeans Visual Web Pages

A project I've been spending much of my time on recently is support for NetBeans Visual Web development on the jMaki project. This means creating components, or rather wrapper components, for the jMaki components. The jMaki project is a JavaScript framework that itself wraps other JavaScript components (i.e. widgets) and it also provides some of its own native components. Craig McClanahan started this sub-project of JMaki by creating JSF wrappers for widgets for the Yahoo yui TreeView and Tabbed View components. I added three others: Menu, AutoComplete, and Slider. You can download a prototype complib file.

Why would you want to wrap existing JavaScript components? Creating good JavaScript and Ajax components is hard, so why not leverage the work of others? I mostly worked on Yahoo yui widgets and many of them are well-designed and tested in the real world. After all, they're deployed on yahoo pages and other sites as well. Plus, there is an active user community and the code is open-sourced.

So why use an additional jMaki JavaScript wrapper instead of just creating JSF wrappers for the yui components? Yahoo yui is just one example of a nice JavaScript widget library. The same argument applies to other widget libraries too like Dojo and Scriptaculous. By using jMaki, it is possible to mix widgets from different underlying widget libraries and get them to work together.

Here are some screenshots of an older prototype which I haven't had time to update, but it still gives a good idea of how the widgets look in the IDE.

The next screenshot shows the same (older) prototype web application but deployed on a server and viewed in a browser. In this image, I hovered the mouse over "Goto" which caused a sub-menu of two web sites to slide out. Then, I moved the mouse over the "java.sun.com" sub-menu item, but the mouse does not show in the screenshot. Activating the item will go to that URL. This behavior was specified at design-time in the IDE.

So what did I learn from this work? Visual web component development is possible but it isn't the simplest task. Re-using an existing JavaScript widget does save a significant chunk of work, but there is still additional work with wrapping the widget with JSF and possibly jMaki, along with the accompanying debugging work. Making the components product quality would require a commitment of engineering resources -- though, less than if you were to also have to create the JavaScript widgets themselves from scratch.

If you're interested in learning more about the jMaki project and tools support and you will be in the neighborhood of San Francisco around the week of Monday, May 7, 2007 (ISO 2007-05-07), some of the key players will be speaking at JavaOne and CommunityOne. Even if you can't make it to JavaOne because of the cost, this year there is a free CommunityOne event that you can register for. For example, I did a search for Craig McClanahan and came up with this list of talks. You can also search for Greg Murray for jMaki talks and Ludo Champenois for other tools related talks.

Sample complib Files for NetBeans Visual Web Development

One feature of the original Creator IDE that has been carried over and improved into the current NetBeans 6 Visual Web IDE are complib files. Complib files provide web app developers access to third-party components that are not pre-packaged with the IDE itself. I've created a complib files wiki page with links to some complib files that I know about.

Thursday Apr 12, 2007

Unexpected Behavior: Visual Component Does Not Appear on Page

A component developer described the following problem to me:

I have developed the custom component in netbeans. There are no errors, I am able to build the complib successfully. But the problem is, when I drag and drop the component, I am not able to see that in design page or JSP page but I am able to see the component in outline window, Java source and properties…etc.

This caused me to add a troubleshooting section to a page that badly needs updating. The pertinent information is repeated here.

If you try to add a new visual component from the palette to a page in the IDE and expect something to appear on the page and instead only see the component in the Outline view, then this often means that the associated custom BeanInfo class of the component cannot be instantiated. In reality, a default BeanInfo class is created internally by introspection, but the default is not very useful. One way to check this is to write a unit test that instantiates the BeanInfo classes of your components.

Wednesday Apr 04, 2007

Updating the Built-in Java EE 5 Components in Visual Web Pack

NetBeans Visual Web Pack (VWP) has several sets of built-in components. One of these is a built-in version of Project Woodstock components designed to be used with Java EE 5 containers. The Project Woodstock components have now been open-sourced on java.net and it's possible to modify the components and update the built-in VWP Woodstock components. See this link for more information. I think the procedure is more difficult than it has to be so improvements in this area are welcome. I'd encourage anyone interested in this to join Project Woodstock.

Tuesday Mar 13, 2007

Speeding Up Visual Web Component Development

If you're a component developer who doesn't mind working on the bleeding edge and are writing new components for NetBeans Visual Web Projects (WVP), this entry is for you. Writing components for VWP using the tried and true method of building and creating a complib file and then importing it into the IDE produces a long painful edit-deploy-test cycle. I've been there because I am also currently working on adding VWP support for jMaki components. See the NetBeans RFE on this very problem.

I've created a first pass implementation to fix this problem on the NetBeans 6 trunk. Unfortunately, it has some file locking issues on Windows that I haven't figured out, but by restarting the IDE, it should still be somewhat usable. It's also on the bleeding edge so be prepared for some other possible unknown IDE instability, but having used it myself for a week or so leads me to think that it is an improvement. The basic idea is that the component library will exist in one or more NetBeans Library projects. Your test webapp will exist in a separate NetBeans Web project. The test webapp NetBeans Web project will depend upon the component library NetBeans Library project to provide it with the classes it needs for the components. In effect, component libraries are implemented as standalone projects that are shared instead of embedded within a Web project. For more information on component libraries see the main component library page I maintain.

To use this new feature, you first need to run a current version (around 2007-03-02 or later) of the NetBeans 6 trunk. Next, create at least one NetBeans Library project that contains your component library. The project should have an ant target to build a "complib" file and the current implementation assumes it will produce an expanded directory structure at "$(my-project-dir)/build/complib/".

The next step is to create a test webapp NetBeans Web project. As I understand it, in NetBeans 6, there will no longer be a separate "Visual Web" project. Instead there will be a single "Web" project with a "Visual JSF" framework that you can add to it so be sure to select the "Web Project" in the New Projects Wizard and ignore the "Visual Web Project" if such an entry still exists. Proceed to add the "Visual JSF" framework. The following UI is temporary. Open "index.jsp" and select the "Design" view. Select Tools->Shared Component Libraries. Use this dialog to manage any shared libraries that are being used by the currently active project. The dialog recognizes open component library projects that are in the format described above. It also allows you to see which shared libraries the currently active project depends on and also to refresh the palette.

A typical development cycle goes like this:

  • Add a component from the palette to the test webapp.
  • Test the component at design-time and runtime.
  • See something is wrong.
  • Fix the problem in the component library project.
  • Rebuild the component library project.
  • If needed, refresh the palette from the Shared Component Libraries dialog.
  • Retest by building the test webapp.

Note: as I mentioned before, on Windows there are file locking issues that I haven't resolved, but by restarting the IDE or maybe even only closing and re-opening projects and the deployment server, it should still be somewhat usable. I'd appreciate any feedback so please let me know if this is useful to you.

Monday Mar 12, 2007

Component Library Information Update

A developer sent me some email recently asking about how to develop and package custom components for IDEs like NetBeans 5.5 Visual Web Pack (VWP). So I updated some information such as the main component library page that I maintain. However, what this developer wanted was information on writing the components themselves. This is a more difficult task and so there is a separate page I maintain on that topic. Unfortunately, it is not current. But now that VWP has been open sourced, current development is happening on the NetBeans nbusers and nbdev mailing lists. I know there are other people working on this area so I would like to encourage developers to post their questions there, but feel free to contact me if you need specific information from me.

Many months (or was it a year!) ago, I wrote a prototype popup calendar component, that may be of use as a sample. It has been incorporated into the java.net blueprints project. Look under the "bpcatalog/ui" subtree for runtime and design-time sources in the "com.sun.j2ee.blueprints.ui.popupcalendar" package. For example, there is a "PopupCalendarComponent" class and a "PopupCalendarComponentBeanInfo" class. This prototype component uses hand-coded files and illustrates the artifacts that are needed to create the additional meta-data needed for a component. Much of the hand coding is boiler-plate code, however, and keeping the code in sync can be error prone. So another approach is to use a code generator. The newly open sourced Project Woodstock components take this approach. It uses Java 5 Annotations and an annotation processor to generate boiler-plate code.

Sunday Dec 17, 2006

Sun Java Forums Login Improvements

One of the most useful features of Sun's web site are the forums. However, you have to first be logged in before posting. Unfortunately, the current login page does not allow browsers to remember the password for you so you must re-type it each time. Since I use Firefox as my browser, I wrote a Greasemonkey user script to fix the login page. Greasemonkey is a pretty cool extension. Quoting from the GreaseMonkey page, "Greasemonkey is a Firefox extension which lets you to add bits of DHTML to any web page to change its behavior". To use the script, if you don't have it installed, go to the Greasemonkey page and install it. Then click on rememberSdnPassword.user.js which will open a dialog box. Press the "Install" button to install the user script. The next time you visit the SDN login page, you should be able to enter your username and password and have Firefox remember it. Then, the next time you log in, you can just press the "Login" button. By the way, I tried to make the user script set the focus to the "Login" button, but it did not work for some reason.

The problem with the SDN login page is that there is a form with three password input fields which breaks the remembered password feature of browsers. I believe it's an unintentional bug in the page and should not be too hard to fix by the webmaster. My Greasemonkey script is a workaround that changes two of the password fields into disabled text input fields instead so that there is only a single password input field in the form.

I beleive there are further usability improvements that could be made. For example, other popular sites on the web like Amazon and Gmail are easier to use in that they often do not require users to repeatedly login. I realize there are security implications, but I think users should be able to choose between more security versus more convenience. I often see sites with a "Remember Me" checkbox option so that the user can login once and have a persistent cookie stored on their browser so they can remain logged in.

Monday Dec 11, 2006

Installing NetBeans 5.5 Visual Web Pack Redux

Today I looked into the VWP installation process from a customer viewpoint. VWP is short for "NetBeans 5.5 Visual Web Pack" and is the latest incarnation of the project I've been working on for the past three years. I found some verbose but complete instructions, but I wanted to provide a simpler set of steps and provide a recommended configuration. (All of the following downloads are free, as in without cost.)

  • First, if you have VWP TP installed, uninstall it.
  • If you do not yet have a JDK (Java Development Kit) installed, download and install one from this page. Among the several download buttons on that page, select the one that is for the JDK. It should be the first one listed.
  • Next we will install NetBeans 5.5 and a Java EE 5 app server. If you do not yet have NetBeans 5.5 installed, download and install the NetBeans 5.5 and Sun App Server bundle. VWP supports Java EE 5 which has features that make applications easier to develop. The bundle includes Sun App Server 9.0 UR1, a Java EE 5 conforming server, and it also includes a database which many VWP apps use. However if you already have NetBeans 5.5 installed, download and install just Sun App Server 9.0 UR1 or later. Select the "Java EE 5 SDK Now" button at the very top of the page above the tabs. After installing the app server, manually add it to NetBeans. Go to the "Runtime" window over the "Servers" node and select "Add Server" from the context menu, then follow the instructions.
  • Finally, download and install the Visual Web Pack.

I have tried to minimize the downloads and installs required to produce a recommended configuration of VWP similar to a Creator all-in-one type download. I'm sure that some of the links above may change. Please post comments on this entry and I will try to keep this information current. If you have problems with the installation process, you can look at the full instructions and post questions to the nbusers mailing list. For those that have used Creator before, the VWP installation process is currently more complex. There is not a single all-in-one bundle. As I understand it, there is an effort underway to make this easier. Until then, I hope this information is useful.

Wednesday Dec 06, 2006

NetBeans 5.5 Visual Web Pack is Here!

It's official, the final release of Visual Web Pack (VWP) was released earlier today. You can download it from the NetBeans Visual Web Pack page. You need to first download NetBeans 5.5 in order to use VWP.

What happened to Creator? Customers have been asking for Creator-like functionality in an all-in-one IDE. Visual Web Pack attempts to meet that need. The last release of Creator was Creator 2, then came NetBeans VWP TP (Technology Preview), and now this English release of VWP. A multi-lingual release will soon follow. VWP has many improvements over Creator 2, but there are some Creator 2 features that are not yet part of VWP because of some technical problems that resulted from having to be binary compatible with NetBeans 5.5. Overall, I believe that VWP is a significant improvement. As I understand it, the future direction will be to continue down this path and improve the NetBeans IDE with Creator-like features.

Tuesday Dec 05, 2006

Webinar of Upcoming Release of Netbeans Visual Web Pack

I just saw a good webinar on NetBeans Visual Web Pack. You may need to look at the main news page for a link. Currently, there is a Technology Preview (TP) version that you can download, but a product quality version -- we call it FCS for First Customer Ship -- with some improvements will be out soon. In particular, there are significant improvements in the user interface (UI) for third-party component libraries that should make them easier to use. Craig demoed some of it in the webinar. There has been a change from TP and previous versions of Creator in the UI for component libraries. First, you must import a "complib" file to make a component library known to the IDE. Then, you must separately add them to a project to make it available to a project and appear on the palette. Feel free to let me know what you think.

Tuesday Sep 12, 2006

New Complib Wiki Page

I've just created a new java.net wiki page and revamped much of the existing information on complibs. See this link. Complibs are component libraries used by IDEs such as Creator to add extension components to the IDE. Currently, there is an AJAX complib available for Creator but the current version has some bugs. I've created an updated version which you can download from a previous blog entry. Feel free to let me know what you think.

Friday Sep 01, 2006

Unofficial Complib with Prototype Popup Calendar

Note: this entry has been updated to fix errors since it was originally posted.

I've had requests from users for an updated version of my popup calendar prototype. The latest version is checked into the bpcatalog/ui repository on java.net. I just built a new unofficial complib from it which you can download here. I created this complib with version 0.1.1 so if you have a project that used a previous version of AJAX complib (0.1), you must remove the old complib from the project and then add a new component from the new complib into your project. For more information, see this link.

Thursday Aug 31, 2006

Feeling Better

I know it's been a while since I've written a new entry. I went on vacation to Montreal and then when I got back I somehow managed to get the flu. It's unusual to get the flu this time of year, but I was sick in bed for 6 days and then later I found that I also had pneumonia. I was pretty miserable, but I'm feeling much better now. It's relative though, because I still have a bad cough and I'm not at 100%.

Still, it feels good to be back again. During the week I've been implementing some features for our next release. I also hope to get the popup calendar prototype to work again and work on the documentation for writing components too. My build is done so I'll write later.

About

edwingo

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today