Products and Services
FAQs

Tips and hints for using the CDK for NetObjects Fusion

Now that the CDK for NetObjects Fusion 4.0 has been out for a while, we´ve compiled a list of common questions that we hope you´ll find helpful.

1. I'm getting “Create Brick” errors. What´s going on?
A “Brick” is where information about your component is stored when the user quits out of NetObjects Fusion. Member variables of your component are stored automatically by the Java Virtual Machine when you leave the PageView. The problem is that the Java Virtual machine isn´t magic. It can store your primitive data types, like strings and numbers without a problem, but if you have any objects as member variables, it does not know how to store them. Thus, the infamous “Create Brick” error.
There are a few solutions to this problem:

  1. Don´t have objects as public member variables. Make them local to a method so that they don't get stored.
  2. Mark them as transient, then the Java Virtual Machine won't try to store them.
  3. Have the object implement serializable. If you want the object to get stored, you´ll need to implement serialization for the object.

Follow any of the above suggestions, and your errors will be nothing but a memory.

2. How do I add NetObjects Fusion 4.0 toolbars to my components ported from version 3.0?
Many developers would like to provide a toolbar to their version 3.0 components without having to rewrite them to conform to the NetObjects Fusion 4.0 APIs. Here is how you can add your own custom toolbar without rewriting your component.

  1. Install your version 3.0 .nfx file in the NetObjects Fusion 4.0 components directory and launch NetObjects Fusion. This will cause NetObjects Fusion to convert your .nfx file into a .class file and to create a default toolbar button and an .nfi file.
  2. Quit NetObjects Fusion. NetObjects Fusion 4.0 has now created a directory for your version 4.0-compatible component.
  3. Delete your old .nfx file—we don't want NetObjects Fusion to convert it again!
  4. Copy the new .nfi and .bmp files to your new component directory. If your component was called widget.nfx, for example, the new directory is called widget. In addition, the .nfi file will be called widget.nfi, and the toolbar button graphic will be called widget.bmp.
  5. Edit the .nfi file to reflect the branding you´d like to show on your toolbar.
  6. Edit the .bmp file to create a really cool toolbar button.

3. How do I center my wizard windows?
Although this is a Java issue more than a NetObjects Fusion issue, it’s a common question. You may have noticed that most components that include wizards place the windows in the upper left corner of the page. But you can make your wizards appear neatly in the center of the screen by using the following code, which changes the constructor for your dialog class:

    public MyConfigDlog(Frame parent)

    {

    super(parent);

    Toolkit myToolkit = getToolkit();
    Dimension myDimensions = myToolkit.getScreenSize();
    int screenWidth = myDimensions.width;
    int screenHeight = myDimensions.height;

    int theDlogWidth = 390;
    int theDlogHeight = 300;

    setSize(theDlogWidth, theDlogHeight);
    this.setLocation((screenWidth/2) - (theDlogWidth /2)
    (screenHeight/2) - (theDlogHeight /2));

There are a few tricks to using this method. First, you should always call the dialogs base class, so it can do anything necessary to put up your dialog.

Next, get the screen size of the monitor using the getScreenSize() method of a Java tool kit.

Finally, move the dialog using the setLocation() method. If you subtract half of the width of your dialog from half the screen width, you have the correct horizontal position. Do the same with the heights, and you´re all set!

4. Why do I have to derive my dialog boxes from NFXDialog?
Since most dialog boxes are derived from awt.Dialog, it seems unnecessary to extend NFXDialog. But since Java Virtual Machine runs independently of NetObjects Fusion, anything that occurs in the Java thread is not communicated back to NetObjects Fusion. If you use an awt.Dialog, you may have noticed that NetObjects Fusion doesn't update its window. That´s because it doesn´t get any cycles while the Java Virtual Machine is running.

If you derive your dialog boxes from NFXDialog, or NFXJDialog if you´re using the Swing class library, they´ll care of this problem. They´ll provide NetObjects Fusion with the cycles it needs, and handle all the housekeeping involved with threads.

There is an exception to this rule. If you have a dialog box that brings up a second dialog box, the second one should extend awt.Dialog. The reason is that the original NFXDialog provides the cycles to NetObjects Fusion, so it´s not necessary to do so twice.

5. What is getNFXCodeBase(), and why do I need it?
GetNFXCodeBase() is a method on all the component base classes. It´s very useful, since all components need access to other resources, such as their placeholder images or other support files.

By calling getNFXCodeBase(), NetObjects Fusion will return the path to your component—specifically, to the NetObjects Fusion information (.nfi) file. By putting all your component's assets in one component directory, getNFXCodeBase() will always be able to provide the correct path to your resources.

6. Can I use Java 2?
NetObjects Fusion ships with the Java Runtime Environment 1.1.6. For this reason, your components must also be compatible with Java 1.1.6, and you cannot link against later libraries.

By providing a consistent virtual machine, customers can be certain that the components they purchase will continue to work, regardless of what other versions of Java are on their computers.

7. Can I use Swing in my component development?
Yes, you can use the Java Runtime Environment 1.1.6-compatible version of the Swing class library. However, there are issues you need to be aware of.

First, Swing is slow. A generic Swing dialog box will cause over 400 classes to be compiled. This can delay a dialog box for more than a minute!

Second, you must compile against the JRE 1.1.6 version of the Swing.jar file. To be sure you're compiling against the correct version, you'll probably want to link against the Swing.jar file in the NetObjects Fusion\NetObjects System directory.

8. How do I launch a dialog from my property sheet?
Sometimes the property sheet is inadequate for configuring a PageView component. At times like this it would be useful to bring up a wizard or dialog box to set up the component.

The best way to handle this is to add a “Relaunch Wizard” property to the property sheet. That way, when the user selected or double-clicked the property, the wizard would once again come up.

The first part is creating the property. You simply add this as a “Set” property type in your onInspect() method.

    public void onInspect (CStringArray Names,CStringArray Types)
    {
    Names.Set("Configuration Wizard");
    Types.Set("Set(Open...)");
    }

This adds a “Configuration Wizard” property to your property listener, with one option, “Open....”

In order to sense whether the user has clicked this property, you must add code to your PropertyListener() method.

    public String PropertyListener (String Event, String Value, int Get, int propIndex, IDInspector insp)
    {
    if (Get == 1)
    {
    if (Event.compareTo("Configuration Wizard ") == 0)
    {
    return theGraphicIndex;
    }
    }
    else
    {
    if (Event.compareTo("Configuration Wizard ") == 0)
    {
    java.awt.Frame theFrame = new java.awt.Frame();
    MyWizardDlog theDialog = new MyWizardDlog (theFrame);
    theDialog.show();
    if(theDialog.isOK)
    {
    //Do your stuff
    insp.OnPropertyChanged(-1);
    }
    }
    }
    return "";
    }

Now whenever the user clicks in the “Configuration Wizard” property, your dialog box will reappear!

9. SetHTMLBefore/SetHTMLAfter—Does it go in onDrop() or onPublish()?

NetObjects Fusion creates an IMG tag whenever a component is dropped on a page. The common way developers deal with this inconvenience is by using setHTMLBefore and setHTMLAfter on their DrawObject, and commenting out the IMG tag.

From looking at the sample code, you may have noticed that in some examples this is done in onDrop, and in others its in the onPublish() method. Why isn't it more consistent?

As in most things in software development, it depends on what you´re trying to accomplish. As a general rule, onDrop is used for one-time operations. For instance, you only add the DrawObject to the page once. If what you are doing never requires updating, putting your scripting or comment code in onDrop() is appropriate.

However, what if the information you are adding to the page is dependent on changing information? If you take a look at the hierarchicalNavBar component, you'll notice it uses onPublish(). The reasoning is simple: If you need to update the information right before publish, this is the place to put it. Since a user can add pages to a site at any time, putting information into the page right before publish makes a lot of sense.

Another reason to do scripting at publish time is that it’s a temporary measure. A copy of your draw object is created at publish time, so if you make any changes to it, they´ll disappear as soon as the page is uploaded. This allows you to insert script into the page without worrying if the information is persistent.

 


BuiltWithNOF
© 2004 Website Pros, Inc. All rights reserved. Privacy Policy

 

 

NetObjects Fusion MX