Click to Open

Version 37.1 by chuckhill on 2008/03/12 14:32

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("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

5) In your page wrapper, add a <wo:WOLToolBar/> component, and you're good to go.  Look in the lower
left hand corner of the browser window for the link.

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, set the port number and the communication
password.  Turning on the WOLips Server requires a restart of WOLips.

WOLipsServerPreferences.png

Enable Click to Open

And add this to the launch arguments:
DdevelopmentMode=true

EnableClickToOpen.png

Using Click to Open

ClickToOpenLink.png

ClickToOpenExpanded.png

ClickToOpenInAction.png

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