Child pages
  • Click to Open
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

What It Is

C2O allows you to open components in Eclipse directly from the running application in your browser! Click to Open appears in the lower left corner of browser as part of the pages of your running application. Clicking on this component, and then on an object in the browser window, opens the relevant WOComponent in Eclipse. This makes life easier for UI designers and for developers getting familiar with new projects. It also provides some other very slick debugging tools.

Check out the screencast at the mDimension build site!

Click to Open is a browser based extension to WOLips found in Project Wonder. All of the Wonder ERD2W components support this.

Note that click-to-open support is expensive, because it has to dig around your component HTML quite a bit, so you will take a performance hit in development to have it enabled.

What You Need

You either need to be using Project Wonder or you need to get the WOLips framework that is part of Project Wonder. You can download it from mDimension's site. If not using Wonder, untar the frameworks and copy WOLips.framework to where you have the rest of your frameworks (usually /Library or ~/Library).

Getting Set Up

Add the WOLips.framework

Follow the tutorial on adding a framework to add WOLips.framework to your application.

Add Support to Component Base Class

If your components extend Wonder's ERXComponent, you can skip this step. Once again, using Wonder makes your life easier.

If you don't have a custom component base class, you really should. Using com.webobjects.appserver.WOComponent as the super-class for your pages and components is just going to leave you doing the same things over and over.

You will need to add the appendToResponse(WOResponse, WOContext) method to your component base class, or add to it if you already have that method. You should ONLY have clickToOpen execute in your component if you are in development mode.

To include it into your component base class, you can use this sample implementation:

package net.com.foo.bar;

import com.webobjects.appserver.*;
import er.extensions.*;

/**
 * Support for "Click to Open" navigation from the browser to the template in Eclipse.  To enable this,
 * launch with:
 * <pre>
 * -Der.component.clickToOpen=true
 * </pre>
 */
public class ClickToOpenComponent extends com.webobjects.appserver.WOComponent {

    public static final boolean isClickToOpenEnabled = ERXProperties.booleanForKeyWithDefault("er.component.clickToOpen", false);

    public ClickToOpenComponent(WOContext context) {
        super(context);
    }

    public void appendToResponse(WOResponse response, WOContext context) {
        ERXClickToOpenSupport.preProcessResponse(response, context, isClickToOpenEnabled);
        super.appendToResponse(response, context);
        ERXClickToOpenSupport.postProcessResponse(getClass(), response, context, isClickToOpenEnabled);
    }
}

For components that can't sub-class ClickToOpenComponent (directly or indirectly), you can enable Click to Open by adding this method to your component:

public void appendToResponse(WOResponse response, WOContext context)
{
    ERXClickToOpenSupport.preProcessResponse(response, context, ClickToOpenComponent.isClickToOpenEnabled);
    super.appendToResponse(response, context);
    ERXClickToOpenSupport.postProcessResponse(getClass(), response, context, ClickToOpenComponent.isClickToOpenEnabled);
}

Note that when isClickToOpenEnabled is false, the ERXClickToOpenSupport methods are no-ops.

Add Support to Application

If your Application.java class extends Wonder's ERXApplication, you can skip this step too. Otherwise, add a developmentMode() method like this:

private Boolean isDevelopmentMode;
public boolean developmentMode() {
    if (isDevelopmentMode == null) {
    	isDevelopmentMode = new Boolean(ERXProperties.booleanForKey("er.extensions.ERXApplication.developmentMode", false));
    }
    return isDevelopmentMode.booleanValue();
}

Set Application Properties

In your application's Properties file, add this line:

wolips.password=yourpassword

If you need to, you can also change these default values:

wolips.host=localhost
wolips.port=9485

Provide prototype.js

WOLips.framework needs a prototype.js. If you are using Ajax framework, you don't need to do anything, because it will default to use Ajax.framework's prototype.js. However, if you are not, add this to your application's Properties file (as an example, change the values as appropriate):

wolips.prototype.framework=app
wolips.prototype.fileName=prototype.js

Add WOLToolBar to Your Pages

In your page wrapper's HTML template, add

<wo:WOLToolBar/>

and you're done. If you don't have a page wrapper, you will have to add this to every page. Hint: page wrappers make your life easier.

If you are using the old WO template syntax, add this to the .html file:

<webobject name="WOLToolBar" />

And add this to the .wod file:

WOLToolBar: WOLToolBar{
}

Configure WOLips Server

You must be using a recent version of WOLips that supports the WOLips Server. In your WOLips preferences, you must enable the WOLips Server and set the communication
password.

Turning on the WOLips Server requires Eclipse to be restarted.

You can optionally change the port number. If you do change the port number, see wolips.port in the Set Application Properties section above.

Enable Click to Open

And add -Der.component.clickToOpen=true and -Der.extensions.ERXApplication.developmentMode=true to the launch arguments:

Using Click to Open

you can hold cmd
and it will highlight the component
and if you cmd-click
it will popup the stack
and you can pick from the stack
also esc is a shortcut for getting out of click-to-open mode

  • No labels