Programming__WebObjects-Project WONDER-Quickstart

Version 14.1 by smmccraw on 2007/07/08 09:45

Quickstart

Using Project WONDER is surprisingly easy.  There are only a few steps to get up-and-running:

  1. Download and install the Project WONDER frameworks;
  2. Add the ERJars.framework and ERExtensions.framework to your WebObjects project;
  3. Change your Application class to extend er.extensions.ERXApplication instead of WOApplication;
  4. Change your Application.main method to call er.extensions.ERXApplication.main instead of WOApplication.main;
  5. Change your Session class to extend er.extensions.ERXSession instead of WOSession;
  6. Change your DirectAction class to extend er.extensions.ERXDirectAction instead of WODirectAction;
  7. Build.

When using Xcode out of the box, there will be an error upon launching this application (as of Feb 6, 2007):

<b>"No ERXMARKER field in NSMutableArray found."</b>

This means your class path is incorrect. Adjust it so that ERExtensions come before JavaFoundation. To do this, you must change the order of your classpath so that ERExtensions appears above JavaFoundation. In my default classpath, JavaFoundation appears first in the list. If you are using Xcode, follow Jerry Walker's instructions:

  1. Select "Application Server" in your Active Target popdown menu at the top left of your Xcode window.
  2. Type command-option-e or choose the Project->Edit Active Target 'Application Server' menu item. This will open a target editing window.
  3. Select 'Link Binary With Libraries' under 'Build Phases' in the left-hand view.
  4. You can edit the framework load order by dragging framework up or down in the list on the right. Drag the ERExtensions.framework to the top.
  5. Rearrange these frameworks in the editing pane into any order that you desire by dragging and dropping them within the editing pane.
  6. Set your Active Target popdown menu back to the name of your project. <b>THIS IS IMPORTANT.</b>
  7. Clean and rebuild your app and your classpath settings should be rearranged accordingly.

This error only occurs with Xcode and, obviously, this workaround applies to Xcode and not Eclipse. Also, there is also an Xcode project template for an ERXApplication available. (from where?)

If you are using WOLips, you can create a new "Project Wonder Application" which will setup a project with these steps already performed.

That's it!YouarenowusingProjectWONDERandyou'vebegunyourjourneytoeasierWOapplicationdevelopment.

NotesfromDavidTeran

FromDavidTeranDec12004:Pointersforgettingyourheadaroundtheframeworks

"PWconsistsofdifferentframeworks,themostimportantoneisERExtensions,thenforD2WappsadditionallyERDirectToWeb,someifnotallpeopleareusingERCoreBusinessLogic.Theotherframeworksarebuildontopofoneormultiplefromthese.

BUT:_i_would_start_reading_the_class_description_and_then_the_javadoc,itsgeneratedfromthesourcecodewitheclipsewithinasecond(ok,maybe60...)anditsreadinabout1-3hours.

TheniwouldtakealookERXApplication,ERXSession,ERXGenericRecord,ERXEC(veryinteresting!), ERXThreadStorage (very interesting, too), ERExtensions, ... and the various utility classes: ERXEOControlUtilities, ERXEOAccessUtilities, ERXArrayUtilities and so on."

Notes from Chris Meyer

Internationalization and Localization

Practical WebObjects outlines one technique for handling internationalization. It is incompatible with Project WONDER.

To handle internationalization in Project WONDER, delete the takeValuesFromRequest from your Session class (which should now be derived from ERXSession). Likewise, delete the createResponseInContext method from your Application class (which should now be derived from ERXApplication). Then add the following call to your Application constructor:

ERXMessageEncoding.setDefaultEncodingForAllLanguages("UTF8");

Logging

Practical WebObjects outlines one technique for SQL logging. Project WONDER uses an entirely different technique.

In Project WONDER, put this in one of the properties files (I use /WebObjects.properties)

  1. turn off annoying INFO logs
    log4j.logger.er=INFO
    log4j.logger.er.extensions.ERXExtensions=OFF
  1. Enable delegate to emit SQL debugging info. The Logger used is
    log4j.category.er.extensions.ERXAdaptorChannelDelegate.sqlLogging=DEBUG
  2. put this to true if you want to log sql stuff
    er.extensions.ERXAdaptorChannelDelegate.enabled=true
  3. How long a statement must run to cause a log message. Messages with longer than
  4. error also emit a stack-trace
    er.extensions.ERXAdaptorChannelDelegate.trace.milliSeconds.debug=0
    er.extensions.ERXAdaptorChannelDelegate.trace.milliSeconds.info=50
    er.extensions.ERXAdaptorChannelDelegate.trace.milliSeconds.warn=1000
    er.extensions.ERXAdaptorChannelDelegate.trace.milliSeconds.error=5000
  5. MaxLength of the message
    er.extensions.ERXAdaptorChannelDelegate.trace.maxLength = 30000
  6. What entities to watch
    er.extensions.ERXAdaptorChannelDelegate.trace.entityMatchPattern = .

Backtracking

Project WONDER offers a few techniques to deal with backtracking.

My recommended way is to add a method to your WOComponent:


{panel}
   /**
     * Determine whether the user backtracked.
     * @return true or false indicating whether the user backtracked
     */

   public boolean didBacktrack()
    {
     return ((Session)session()).didBacktrack();
    }
{panel}

Then anywhere a form is submitted where backtracking might be a problem, add this code to the action method:

        
{panel}
   if (this.didBacktrack())
    {
     ec.revert();
     // handle and prepare to report errors
     // this.errors.addObject("Unable to process page after back button was pressed.");
     return this.context().page();
    }
{panel}
ERXWORepetition

 also contains some code to deal with backtracking. As of Project WONDER 3.0, the code seems to work inconsistently. When the page is backtracked and the form submitted, values in the form are just passed as null. This tends to cause more problems than it is worth, although your situation may be different. Also, there is an option to throw an exception when the page is backtracked, but this exception doesn't seem to be thrown consistently.

Javadocs

Prebuilt

  • http://webobjects.mdimension.com/wonder/api
  • http://webobjects.mdimension.com/wonder/Wonder-latest-Documentation.tar.gz

Creating javadocs from the Wonder source (not using Eclipse)

If you want to create the javadoc and you haven't got Eclipse going yet:

  1. Get the latest source from the nightly build server.
  2. Once you untar it you'll have a Wonder folder created. 
  3. In the terminal app % cd to the Wonder/Build/build directory
  4. % ant doc
  5. Wait several minutes while some good stuff scrolls by in your terminal window (If ant gives you errors, you may have to set it to use ant 1.4 instead of 1.5 by exporting:  JAVAHOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Home)
  6. Find the new dist/wonder-2.0/Documentation/api/index.html page that has been created in the same directory as the Wonder folder was untarred in
  7. Double click on the index.html page and the javadocs will open in your favourite browser

Creating javadocs from the Wonder source (using Eclipse)

Someone else will have to fill in this section...


Category:WebObjects