Wednesday, February 10, 2010

This Three Months in Wonder

EOF
An H2PlugIn has been added to Wonder to support the H2 Database Engine (http://www.h2database.com)

Components
The ERReCaptcha component was added to ERCaptcha.framework -- this adds support for http://recaptcha.net in a way that is API-compatible with ERXSimpleSpamCheck.

ERAkismet has been added to ERCatpcha.framework. ERAkismet adds support for the Akismet spam identification service that is API-compatible with ERXSimpleSpamCheck.

ERPOFCChart has been added to the ERPlot framework. This component adds a simple wrapper around the OpenFlashCharts2 flash charting tool.

ERRest
ERRest now supports JSR-311-style annotations if you prefer that approach:

Application.java:
routeController.addRoutes(Person.ENTITY_NAME, PersonController.class);

PersonController.java:
@GET @Path("/person/{person:Person}")
public WOActionResults view(@PathParm("person") Person person) {
...
}

Migrations
Basic migrations will run against MemoryAdaptor now (or .. appear to), which helps when running test cases.

Examples
BugTracker app can now run with MemoryAdaptor, which requires zero setup. This should make it much easier to fire up the example app to see what Wonder can do. To run with memory adaptor, you can launch from eclipse with the VM Arguments "-Xmx512M -Duser.name=Memory".

The new ERComponentTour example app shows some components with some example uses.

Tools
RuleModeler now supports adding documentation to rules.

ERD2WGraphVizPage in ERD2W can spit out a graphviz file that represents your EOModel.

JavaRebel is now JRebel, so WOJavaRebel is now WOJRebel (and updated to the latest-and-greatest). Q's done a bunch of work on this and now supports EOModel reloading. He says JRebel is much faster in the new versions, too. I hate myself for not using this. In fact, I'm going to hook this up right after I finish writing all this up.

ERProfiling is a cool new framework for profiling your WO apps in a way that actually understands WO. For more information, read more here.

Adaptors
Anjo started work on an Apache Mina-based WOAdaptor (http://mina.apache.org/). I believe this is still experimental.

D2W
Ravi pushed up a new look into Wonder -- "ERDivaliteLook" as well as the ERDivaliteExample example app to show it off.

"It's intended as a transitionary point to migrate WO/D2W apps to Diva look.
As such it's:

1. HTML4 table-less markup.
2. CSS and Selenium tests are interchangeable with a full Diva look app.
3. No Ajax.
4. WO 5.3+ compatible."

Documentation
Ray has been doing all kinds of great work making the documentation for Wonder more accessible and useful. This has included adding a new doclet for showing components along with their component bindings (see here) as well as a doclet for showing the available d2wkeys for D2W components (here)

Testing
Ray has also done a lot of work on the test cases and getting them to run properly from ant. You can also run all the test cases from within Eclipse in the JUnit runner.

ERMovies now has Selenium test scripts.

ERSelenium now has support for taking screenshots in the standalone runner.

Removals
The SproutCore framework and example app have been removed. It was an interesting experiment, but ultimately would have been too labor-intensive to keep it maintained alongside the official SproutCore framework.

Thursday, November 5, 2009

What's Old in Wonder

It's been a long time since the last What's New in Wonder -- almost 8 months. We've been busy, quietly making your life cooler :) There's actually been quite a bit of activity in Wonder, including contributions from lots of people outside the regulars. We've had a lot of Jiras filed (many with patches! thank you).

Thanks to everyone who contributed bugs, patches, tests, and features over the 8 months -- Anjo, Chuck, Quinton, Timo, Lachlan, Henrique, Ravi, Denis, Ray, Ramsey, Kieran, Travis(es), Michael, and anyone else I might be forgetting.

The synopsis below doesn't do justice to any of the items listed -- I encourage you to read the docs on each of them for more information, but it should at least give you a starting point for finding more information. As always, my own stuff is disproportionately weighted in the synopses :)

New Components


  • ERXSwitchComponent - patched in, hides the component name
  • ERXResponseComponent - lets you wrap a WOActionResults in a WOComponent implementation
  • ERXBooleanSelector - Yes/No/Blank picker
  • ERXClippy - wrapper around the Clippy flash clipboard access layer
  • ERXPodcastRssPage

Ajax

  • Bunch of enhancements to AjaxModalDialog
  • iBox updated to 2.2
  • AjaxModalContainer tweaked to support dynamic resizing
  • Updated to Prototype 1.6.1 and Scriptaculous 1.8.3
  • New experimental support for returning components from Ajax action methods (when used with replaceID binding)
  • New experimental push/keep-alive support

D2W

  • New D2W page/component metrics
  • Cleanup on the 47 different boolean picker components
  • ERDEditableList brought over from Diva

EOF

  • bunch of new tools for tracking down editing context lock problems
  • support for tracking locks on ERXDatabaseContext
  • bunch of tweaks and fixes and new bugs but then more new fixes for autolocking (in particular, support for sharing an autolocked ec across threads)
  • support for bind variables with FrontBase
  • migration fixes for SQLServer and Derby
  • automatic batch faulting - basically Wonder watching your back about prefetching, preventing scenarios where you would have gotten a million individual fetches before
  • ERXPrefixQualifierTraversal - walks a qualifier and prepends a keypath to every key of the qualifier

ERRest

  • supports non-EO's using EOClassDescriptions (via a new BeanInfoClassDescription)
  • supports non-model relationships on EO's (via a new class description factory that can handle EOEntityCD's and BeanInfoCD's for the same class)
  • format delegates for remapping commons keys (like id and type)
  • ERXKeyFilter now has a security delegate for implementation fancier rules
  • ERXRestFetchSpecification - makes it really easy to fetch based on query params with security filters
  • ERXFilteredQualifierTraversal - provides support for filtering a qualifier with an ERXKeyFilter (so people can't fetch on salary > x if they're not allowed to see salary)
  • support for deferring the generation of rest responses, so you can pass requests between controllers (this provides support for having compound controllers, like what would be needed for a Gianduia fetching controller)
  • easier support for generating html responses with rest controllers
  • ERXRouteLink - generate links to route controllers

SnapshotExplorer

  • new framework for exploring the snapshots that are currently loaded into memory in your application

Diva Look Framework

  • ERDivaLook/ERPrototaculous/ERDivaLookExample frameworks are a new D2W look focused on XHTML div content styled with css rather than the older table-based looks. Additionally it has its own Ajax framework (not to be confused with Wonder's existing Ajax.framework) based on WO 5.4's ajax request handler.

ERMovies/ERMoviesLogic

  • Movies example moved into Wonder

ERChronic

  • Patched to match trunk of chronic

ERAttachment

  • Support for resizing attachments on upload
  • SipsImageProcessor - uses sips commandline tool to thumbnail (not as fast as ImageIO JNI imp, but less to build)

WOJavaRebel

  • huge performance improvements
  • support for model reloading
  • updated to new JavaRebel version

ERPDFGeneration

  • ERPDFGeneration provides both a utility class and a wrapper component for generating
    PDF documents from XHTML markup. Two PDF generation engines are currently supported,
    FlyingSaucer (xhtmlrenderer) [1] and Useful Java Application Components (UJAC) [2],
    however additional parser based engines like FOP could be added fairly easily.

Validity

  • i guess it runs now? it got a bunch of build-related fixes at least

ERMemoryAdaptor

  • all cleaned up and shiny
  • split into memory store and entity store, which can be a basis for other custom adaptors
  • support for flattened attributes

WOPayPal

  • Sandbox support

Testing

  • build scripts now support running test cases
  • bunch of test cases added

Misc

  • ERXSignalHandler - "multicast" signal handler
  • ERXProperties/Configuration cleaned up dramatically
  • ERXComponentUtilities.inheritTemplateFrom - make one component inherit the template of another component
  • ERIUIExample made fancier

Build Server

  • Moved entire to Hudson - http://webobjects.mdimension.com/hudson
  • Rebuilds immediately on commit
  • All applications and examples are built fully embedded (= easy to download and run now)

Sunday, April 19, 2009

Need More Rest

Note: This is all brand new and to be considered experimental right now, but I thought I'd give you guys a heads-up:

ERXRest can do a lot of various things, but I was never happy with the API and the complexity of the interfaces you have to implement to use it. Anjo did some work with ERD2REST, which is cool, but I still have a bunch of cases where I just want something like what Rails offers -- a very easy way to map annotated URLs onto (direct) action methods. When you just want to quickly make a json interface to your app (especially CRUD interfaces), but with support for additional custom actions (which ERXRest doesn't address), the rails approach makes a lot of sense ... So here are some new API's to try to make that easier:

in your Application constructor:


ERXRouteRequestHandler routeRequestHandler = new ERXRouteRequestHandler();
routeRequestHandler.addDefaultRoutes(Reminder.ENTITY_NAME);
routeRequestHandler.addDefaultRoutes(Person.ENTITY_NAME);
ERXRouteRequestHandler.register(routeRequestHandler);

(you can also add custom routes -- i.e. "/people/{person:Person}/company/{company:Company}/{something:String}" -- but the one above defines all the default routes that rails supports ... check out the javadoc for ERXRestRequestHandler for more info).

then you can make a controller class:

public class PeopleController extends ERXRouteController {
public PeopleController(WORequest request) {
super(request);
}

public Person person() {
Person person = (Person) objects().objectForKey("person");
return person;
}

public ERXKeyFilter personFilter() {
ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
filter.include(Person.PREFERENCE_GROUPS).includeAttributes();
return filter;
}

public WOActionResults createAction() throws Exception {
ERXKeyFilter personFilter = personFilter();
personFilter.include(Person.COMPANY);
Person person = (Person) create(Person.ENTITY_NAME, personFilter);
editingContext().saveChanges();
return response(personFilter(), person);
}

public WOActionResults updateAction() throws Exception {
Person person = person();
update(person, personFilter());
editingContext().saveChanges();
return response(personFilter(), person);
}

public WOActionResults showAction() {
Person person = person();
return response(personFilter(), person);
}

public WOActionResults indexAction() throws Exception {
NSArray people = Person.fetchPersons(editingContext(), null, Person.LAST_NAME.asc().then(Person.FIRST_NAME.asc()));
return response(personFilter(), editingContext(), Person.ENTITY_NAME, people);
}
}

This is basically a DirectAction class, but it has a bunch of tools to make it easy to do the rest creates, updates, and lookups ... there is no security by default (just like rails), so you have to enforce security however makes sense, but it handles xml, json, and plist requests and for the cases where you're just doing relatively straightforward things, this is way easier than the other ERXRest stuff, though you trade off some optimized fetching and automatic security filtering that ERXRest does in exchange for the simplicity.

The determination of what to include/exclude both in rendering and in parsing is done with ERXKeyFilters, which allow hierarchical definitions of include/exclude filters for keypaths (so you say things like: start with an "include all attributes" base, but exclude "password", then include the "tasks" relationship, but don't show any attributes for that (so you just get task ids)). The code for that would be:


ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
filter.exclude(Person.PASSWORD);
filter.include(Person.TASKS);


As an example of actually hitting the API, btw:

curl -X PUT -d '{ lastName="SchragTestAlso"; preferenceGroups=( {id=1000012; name="SomeName2"; } ); }' http://vdoop.local:51915/cgi-bin/WebObjects/MDTask.woa/ra/person/1000008.plist

this updates the person with id 1000008 with plist format, sets the last name to "SchragTestAlso", and replaces their preference groups with a single existing preference group id 1000012 and also updates the name of that group to be "SomeName2".

curl -X PUT -d '{ lastName:"SchragTestAlso"; preferenceGroups:[ {id:1000012; name:"SomeName2"; } ]; }' http://vdoop.local:51915/cgi-bin/WebObjects/MDTask.woa/ra/person/1000008.json

is the same thing in JSON, and

curl -X PUT -d '<Person><lastName>SchragTestAlso</lastName><preferenceGroups><PreferenceGroup id="1000012"><name>SomeName2</name></PreferenceGroup></preferenceGroups></Person>' http://vdoop.local:51915/cgi-bin/WebObjects/MDTask.woa/ra/person/1000008.xml

is the same thing in XML ... notice that just by changing the extension it automagically does request and response filtering for you with the right parser/writer.

Saturday, March 21, 2009

The "I Have A Day Job" Edition

ERRest
support for plist and json responses

support for simple qualifiers and sort orderings in query params

lots of API's for programmatically generating responses

ERDirectToRest
initial pass at a D2W version of the ERRest framework

ERPlot
Updated to latest JFreeChart

EOF
ERXExistsQualifier - creates a query clause based on the SQL exists keyword and a subquery

Support for custom prototype overrides in ERXModelGroup.

ERXEnterpriseObjectCache substantially overhauled to .. well .. not break.

Examples
TickTockMan - example app that performs various time-related tasks. Hopefully, this can become a resource for people trying to understand the use of time, time intervals, time zones and associated objects in WebObjects applications.

Über - Wonder testing app designed for automated testing against new versions of WebObjects.

Ajax
Ajax scripts are compressed during the build process.

AjaxUtils.updateDomElement - appends JavaScript code to the given AjaxResponse that updates the content of the DOM Element with the given ID to the specified value. Useful if you want to update multiple small regions on a page with a single request, e.g. when an AjaxObserveField triggers an action.

AjaxModalDialog - LOTS of enhancements. Check the javadoc for better converage.

ERAttachment
ERImageProcessors - Support for image processing with several variants (Java2D, ImageMagick, and JNI-based CoreImage/ImageIO). This will ultimately be used to support automatic thumbnailing.

Maven
BUILD.txt updated with latest maven build instructions

Misc
Utilities/WOInstall - source of WOInstaller.jar

ERXValueUtilities and related ERXProperties methods were rewritten to be much more consistent and more forward compatible with future version of WO + actually has test cases

WOJavaRebel
Updated for JavaRebel 2.0

ERChronic
Updated to match (roughly) Ruby Chronic's 0.3.0 version

JavaMonitor
refactored the confirm pages to use just one page

added 'stop all' for selected instances

added 'delete all' for selected instances

more directactions controls

/admin/ action added (will allow for rest-like urls) returning JSON compatible output on info

added bounce action

Components
ERXLanguageMenu - generic picker for selecting your current language

... and a gazillion bug fixes

Sunday, December 14, 2008

This Week in Wonder

Ajax
AjaxModalDialogOpener lets you separate the opening of a modal dialog from the dialog itself.

Updated to Scriptaculous 1.8.2

AjaxSortOrder is an ajax version of ERXSortOrder.

Components
Support for quicktime attachments in ERAttachment.

ERXSimpleSpamCheck is an implementation of Hugi's simple spam blocker, which will cause forms to fail validation unless a particular block of javascript has been executed by the client.

EOF
Wonder Migrations can now be used without using ERXEC.

New, better, implementation of SQL parsing (for executing SQL scripts).

Migrations now support SQLServer (well, more than they did).

New Frameworks
WOJavaRebel framework provides support for easily running WO apps with JavaRebel for modifying classes on-the-fly without restarting.

Utilities
New warnings when you are possibly misusing ERXThreadStorage.

ERXEOControlUtilities. validateUniquenessOf provides a utility method for validating unique EO attribute values.

Application
You can now set a low memory threshold separate from a memory starvation threshold, and both now fire notifications that you can respond to.

Support for making ERXResourceManager generate complete resource URLs by setting context. _setGenerateCompleteResourceURLs.

Simple resource rewriting -- Set er.extensions.ERXResponseRewriter.resource.frameworkName.filePath = newFrameworkName.newFilePath

Support for forcing the removal of instance numbers from context urls via the er.extensions.ERXWOContext.forceRemoveApplicationNumber property. You should only use this if you know what you're doing, as this can't always be used in WO.

Support for SSL with DirectConnect. Here's the pertinent docs from Properties:
#########################################################################
# SSL DirectConnect
#########################################################################
## You should probably not enable any of these settings in a normal Apache webserver deployment,
## in particular the ssl port property, as this is used by ERX to generate https URLs, which must
## match your Apache config.
##
## To enable SSL support with DirectConnect, you must do the following:
##
## * In your Resources folder, run "keytool -genkey -alias WebObjects -keyalg RSA -keystore adaptorssl.key". Select a
## password for your keystore (i.e. "changeit"), and set the "your first name and last name" field to match the hostname
## that you will be running your directconnect app off of.
## * In your Resources folder, create an executable script (it MUST BE EXECUTABLE) named "adaptorsslpassphrase" with the
## contents:
## echo changeit
## where you should replace "changeit" for whatever password you selected in the previous step.
## * Set the following property to true
#er.extensions.ERXApplication.ssl.enabled=true

## (optional) To specify an SSL host name other than what is returned from a call to
## application.host(), you can override it below
#er.extensions.ERXApplication.ssl.host=localhost

## (optional) To select an SSL port other than 443, uncomment the following. If you are already running Apache with SSL,
## you probably want to set this. If the port number is 0, the SSL port will be automatically assigned (using the same
## mechanism that WO uses to set the regular port)
#er.extensions.ERXApplication.ssl.port=0

OGNL
New click-to-debug feature. When ognl.debugSupport=true, the WOLips Toolbar has a new Click to Debug option that will turn on binding debug information for any component that you click on. This is really useful if you're trying to track down a rogue binding.

Friday, November 21, 2008

These 49 Days in Wonder

General
All Project Wonder projects were switched to the WOLips Nightly's new hotness build path system. This means that to checkout the Wonder source now requires that you use a WOLips Nightly build, though these are pretty likely to turn into stable pretty soon.

We cleared a lot of the backlog of patches in Jira ... Sorry it took us so long.

Ajax
Ajax framework was updated to Prototype 1.6.0.3

AjaxSocialNetwork and AjaxSocialNetworkLink provides support for submitting URLs to a heap of social linking sites using their recommended icons

Components
ERXEmbeddedPage and ERXSwitchEmbeddedPage allow you to wrap a section of your page and treat return values from invokeAction as a replacement only for the this element and not for the entire page. This allows you to write components that operate like a sequence of top level elements, yet actually they live within a larger page.

ERXAccessibleSubmitButton provides support for defining hot keys for submit buttons.

ERXJSToManyRelationshipEditor provides a nice javascript-based to-many relationship editor

ERXBooleanPopUpButton provides a simple Yes/No/All (labels configurable) three-state popup button that binds out a Boolean value, which is handy for boolean search filters

ERXRedirect supports redirecting to a stateful component (in addition to several other variants).

EOF
New "javaEnum" prototype ... Select it and just set the valueClassName to point to your java Enum class.

Lots of fixes for Oracle in the EROraclePlugin including many fixes to make Wonder's ERXMigration API work properly. The Oracle plugin also has a new delegate that allows you to provide a custom constraint name generator (to provide custom truncation rules).

FrontBase, Postgresql, and Oracle plugins now automatically correct the EOF bug with generating "not null" columns for attributes that only appear in subclasses of single table inheritance tables.

ERExtensions
Added ERXSession support for requiring secure session cookies to prevent session hijacking.

ERXEnterpriseObjectCache now supports optionally caching EO's rather than just their GID's, lazily filling the cache rather than preloading the entire set of objects, and caching with a qualifier (i.e. only cache objects where published=true)

ERXYahooContentAnalysisService connects to Yahoo's term extraction service (for use with auto-tagging)

Misc
Lots of fixes to ERRest framework, including many changes necessary to be able to generate a validating schema for a rest document (the schema generator is not yet committed). Lots of additional enhancements to run ERRest documents without a request, which makes it easier to use for data loading.

WOOgnl no longer requires a different source path for 5.3 and 5.4, though it does require a different binary framework.

Lots of fixes to SproutCore framework to bring it more in line with the latest SproutCore releases.

Friday, October 3, 2008

This Belated Week in Wonder

Yeah. It's been a few weeks. I know .... Better late than never:

Ajax
AjaxExpansion - If you've ever tried to make a component that has a triangle (or whatever) that you can turn down to show additional information, you know it's actually a little tricky to build that component and make it animate nicely with a slide down effect. AjaxExpansion makes this easy to do and there is an addition to the AjaxExample2 ToggleDetails example that shows how to use it.

By popular demand, AjaxTabbedPanel can now hide tabs.

AjaxUpdateLink, AjaxSubmitButton, and AjaxObserveField now support updateContainerID="_parent", which will update the nearest ancestor component AjaxUpdateContainer. This makes it so you don't have to pass id's around in the common case that you're just updating your parent container.

There's a new example of using AjaxModalContainer in AjaxExample2.

Chuck fixed tons of weird little border cases.

AjaxModalDialog is now in ... It's a competitor to AjaxModalContainer based on the modalbox Javascript library, but is designed to have a slightly nicer component backend that can track the open state on the server side (which allows for fancier component content). There's a new AjaxExample that shows this in action.

ERExtensions
ERXExceptionUtilities provides a bunch of handle methods for printing and handling stack traces, including stack trace filtering that tries to hide all those nasty looking WO/EOF stack frames. See the javadoc for more info. Also, you can set your log appender to er.extensions.logging.ERXConsoleAppender to get stack trace filtering wired into all of your log4j output. Check out StackTraceSkipPatterns-Normal.plist in ERExtensions/Resources to see how you can provide your own stack trace filtering extensions.

ERXApplication can now load Properties from inside of jar frameworks.

multipleSubmit=true is now defaulted on for all WOForms. Rest in peace stupid binding.

ERXLazyValue provides a way to model lazy-loaded values that invalidate with different methods. This is very useful for storing expensive values that are returned from bound component methods as well as values that are cached that are influenced by different areas of a single page (i.e. ajax operations on one part of the page that need to invalidate a cache on another part of the page).

ERXDisplayGroup now uses generics.

ERXKey now uses generics in all of the .is(..) etc methods.

ERXWOComponentContent is now a little bit slicker and supports the concept of a "default" template. If you define an ERXWOComponentContent with no template name, it will find all of the component content children that are not contained inside of an ERXWOTemplate and treat them as if they were in a default component content.

There's an NSBundle replacement in Wonder now. This fixes a bug with jar loading in embedded frameworks that would end up loading in the application bundle, which causes the very common bug of getting a Session class that isn't your Session. This is also provides some support for making launching non-WOApplication WO things (like EOF main methods) in WOLips a little smarter.

ERXFetchSpecification has a new setIncludeEditingContextChanges(boolean) option. When true, fetching with this fetch spec will call through ERXEOControlUtilities.objectsWithQualifier and also process the new (uncommitted) changes from your EC. For instance, if you have inserted EO's into your EC, includeEditingContextChanges = true will cause those new EO's to be included in the results of the fetch. Likewise, updated, deleted, and parent EC objects will be processed accordingly.

ERPrototypes
New IP Address prototype (along with new migration methods to support it).

New byte24 prototype for generating guid PKs.

Maven
Both the 5.3 and 5.4 version of Wonder can be now be built with Maven. Talk to Henrique for more info :)

ERAttachment
You can now register a custom delegate onto your ERAttachmentProcessors to be notified of various events in the attachment lifecycle. This allows your application to perform additional operations in response to those events.

Friday, August 22, 2008

This Week in Wonder

Ajax
The AjaxExample2 app has been committed to Wonder. This is the application that was shown during the Ajax session at WOWODC 2008. Whereas AjaxExample shows off many features of the framework but not with real-world examples, AjaxExample2 takes the approach of trying to show the framework off in the context of solving real interface problems.

ibox.js in AjaxModalContainer was updated to 2.17b

You no longer have to iBox.init() at the end of your AjaxUpdateContainers when you generate new AjaxModalContainers in ajax responses. This all "just works" now.

AjaxModalContainer has a new locked flag that disallows closing and an open flag that forces it open (rather than waiting for a click).

AjaxModalContainer works with HTTPS URLs now.

New AjaxUtils.arrayValueForBinding utility method, which supports loading array bindings that are defined as references to NSArray as well as inline JSON-syntax Strings.

Migrations
ERXMigrationTable provides a newLargeStringColumn method that corresponds roughly to the varcharLarge prototype in Wonder. This helps to abstract out the weird big column width you'd previously have to define in your migrations for those columns and hopefully makes this more database independent.

EOF
ERXModelGroup checks for a subtle problem that is probably more common than people might think where your connection dictionaries across multiple models aren't EXACTLY the same, which results in EOF treating them like different databases. Now this will generate an exception at startup.

ERXJDBCConnectionBroker has a new fix for a resource contention problem with leaving connections in an incorrect state.

FrontbasePlugIn
You can now set com.frontbase.unique.[ModelName].[EntityName]=xxx, com.frontbase.unique.[ModelName]=xxx, or com.frontbase.unique=xxx to specify the initial unique value that is used by the FrontBasePlugIn when it generates sequences. I don't think EntityModeler will pick this up, but if you're using migrations, you'll get it.

Components
Ravi Mendis has committed fixes for XHTML compliance in several components.

Misc
ERXResponse supports pushing and popping response content on a stack. This is interesting if you want to post process the output of a single component in isolation from the rest of the response (but you want to maintain all the other state of the response).

ERXExtensions.initApp and ERXExtensions.initEOF should be a little easier to use now. In your JUnit TestSuites, you can just add a static method:


static {
ERXExtensions.initApp(Application.class, new String[0]);
}


and you will be running your test case in a full Wonder-ful Application environment.

ERIUI
If you've ever tried out the iui css + js for making iPhone apps, you may have noticed that it is a complete disaster for connecting to component-action-based WO apps. The Javascript presumes stateless URLs and eventually will explode. ERIUI takes the base CSS work from iui but with a completely rewritten Javascript layer that provides much richer stateful component-based interactions with your app. The docs are severely lacking on this one at the moment (this was just a hobby framework for me). To get good performance on the phone, the framework uses WebKit CSS animations (which currently only works in the WebKit nightlies, not in Safari 3.x), though it "gracefully" degrades (to no animation) on the desktop. Checkout ERIUIExample to see it in action ... This should be considered "preview" quality for now.

Google Chart
There's a new GoogleChart framework for generating charts via the Google Chart API. This is inspired (quite a bit) by the Ruby googlecharts framework. There's more info here.

Friday, August 8, 2008

These 9 Weeks in Wonder

 Yeah, I know, long time no write ... Occasionally Real Work (TM) gets in the way.

Migrations
newLocalizedStringColumn supports creating string columns that work with Wonder's localized attributes ("name_en," "name_de," etc).

Migration support for dropping composite pks (though the FrontBase plugin doesn't actually support this :( ).

BigInteger column support.

newFlagBooleanColumn which generates a Types.BOOLEAN column instead of a varchar(5) or int boolean column.

ERIndexing
Updated to Lucene 2.3.2.

ERIndexingExample is a new example app that shows how to use ERIndexing.

ERCaching
More work on memcached integration, though I think (correct me if I'm wrong, Anjo?) it's not quite ready for primetime yet.

ERSelenium
StandaloneRunner supports running Selenium tests from the commandline.

SproutCore
Initial work on supporting the development of SproutCore applications with WO. Currently the work on SproutCore has been replacing the rails-based templating system with a WO-based templating system. While not necessarily required for developing SC apps, it provides nicer integration with existing tools. Currently you can run the WO-equivalent of several of the SC example apps in live mode ..... mostly :) This is to be considered very experimental right now.

Check out the SproutCoreExample app to see it in action.

Wonder 2.0
We're on Wonder 5.0, but iTunes has lots of miscellaneous enhancements to their Wonder 2.0 fork. Thanks to the iTunes folks, all the enhancements that live in 2.0 are now moving up to the trunk.

JSON
Lots of work on JSON support in Ajax framework.

You can now optionally include attributes and relationships in your JSON results via the client class property setting in your model.

You can specify writable vs read-only attributes.

Marshalling/unmarshalling of EOTemporaryGlobalIDs is supported, so you can pass around uncommitted EO's to/from the server.

There is now support in the client API's for converting full EO's to EO stubs as a performance enhancement when passing to API's that only require an EO's id (the server side faults it back in for you).

Support for custom EO serializers. For instance, you can add the custom serializer for ERAttachments by calling JSONRPCBridge.getSerializer().registerSerializer(new ERAttachmentObjectSerializer()), which will inject the attachmentUrl into the JSON object during serialization so your client can simply refer to the attachment without doing another round-trip.

JSONComponents are an experiment in trying to rethink web services in the language of WOComponents. JSON service endpoints can now return JSONComponents, which are stateful service endpoints. This allows for cleaner encapsulation of your services while also allowing the server to make decisions on the routing path through your service as well as the services themselves being stateful. For instance, clients can call the login method of the authentication service, which can return back the next service to talk to, and just like WOComponents, repeated calls to the component return to the correct state on the server. The end result is actually a bit like PDO ... JSONComponent are to Component Actions as traditional WOWebServices are to DirectActions.

ERAttachment
ERAttachment URLs are now a little smarter and more optimized in that the URL can now include the PK of the attachment being requested. It still verifies the provided webpath for security, but the server can almost always avoid an extra fetch by attempting to fault the PK rather than fetch by webpath.

ERExtensions
ERXRemoteNotificationCenter provides support for posting arbitrary notifications across multiple servers. Provides a simple implementation as well as a JGroups implementation.

ERXIFrame can act as a component for simply creating an iframe to a URL, or more interestingly can render its component content as the iframe contents, which is really handy.

ERXPartialMarker/ERXPartialWrapper is crazy, but if I understand it properly, it provides support for rendering one section of your page that will appear in another section of your page. It's currently used by the SproutCore framework.

ERXFlashMovie is just a handy wrapper around embedding an SWF in a page.

ERXEOGlobalIDUtilities does a lot more work to make sure that it doesn't refetch objects that were already faulted.

ERXQ.containsObject. If you're a fan of the "contains" qualifier selector, you'll be a fan of this method.

ERXRecursiveBatchFetching is a terrible name. It's now named ERXBatchFetchUtilities. The old class extends the new class and is marked @deprecated. ERXBatchFetchUtilities also now provides several batch fetching variants based on ERXKey.

ERXDatabaseContextMulticastingDelegate now supports both 5.3 and 5.4.

ERXTemporaryGlobalID provides many of the benefits of 24-byte GUID PKs without the annoyance of byte[] PKs in your database by "fitting" a GUID into a long-sized value.

ERXEOControlUtilities.convertEOtoGID and convertGIDtoEO now support non-EO objects that contain EOs (for instance, a pojo proxy object that wraps an EO) via the IERXEOContainer and IERXGIDContainer interfaces.

ERXMutableURL is a little smarter about not generating :80's for http and :443's for https.

ERXEOAccessUtilities.createRelationship and createFlattenedRelationship provide easier methods for programatically mucking with your EOModels

ERXEOControlUtilities.distinctValuesForKeyPath will give you an array of the distinct values of a particular keypath on an entity.

ERXModernNavigationMenu/Item provides an upgraded replacement of ERXNavigationMenu/item that are CSS and semantic markup instead of the older table-based layout.

ERXArrayChooser now supports arbitrary qualifiers and fetching of shared objects.

ERXModuloQualifier can generate SQL queries that use the "mod" keyword.

ERXFetchSpecificationBatchIterator now supports prefetching and raw rows.

ERXGenericRecord will now cache its primary key rather than constantly regenerate.

ERXJobLoadBalancer "solves the following problem: we have a set of jobs (identified by an Id) waiting to be processed. Several worker processes are competing for jobs and we need to way to efficiently parcel out those jobs out. We want to avoid as much as possible several workers attempting to grab the same jobs and locking it." This works across instances, by the way. It's works sort of like Xgrid. The new version of ERMailer coming from Wonder 2.0 will use this class to load balance sending email across multiple instances/apps.

Ajax
AjaxObserveField has a new onCreate option that is called after form serialization, but prior to form submission, which allows you to do things like disabling the form while it's sending in the background.

Better compatibility with FireFox 3's more aggressive caching of Ajax requests.

AjaxModalContainer supports binding "action" even when ajax=true, so you can perform a component action prior to rendering the component content of your container.

BugTracker
BugTracker now include support for the audit trails.

Maven
Lots of work on the maven build files for Wonder. As I understand it, which I don't :), Wonder Maven builds "just work".

WO Adaptors
Q updated all the WO adaptors in Wonder. The 5.4 enhancements are merged with the Wonder enhancements. The build files have all been cleaned up, FreeBSD support was added, and several fixes went into the FastCGI adaptor.

ERRest
ERXUnsafeRestEntityDelegate can now be optionally enabled in production. This is handy if your restful service is behind authentication and only used for administrative services where ACLs are not an issue.

ERXAbstractRestEntityDelegate subclasses can more easily provide support for custom "primary keys" to be generated and resolved by overriding _isEOID, _objectWithKey, and idForEO methods.

Tuesday, July 29, 2008

Not Dead, Just Busy

Saturday, June 7, 2008

This week in Project Wonder

Since the move to svn, we've been able to clean things up a bit.

New structure
There are now three important top-level folders, /Applications, /Frameworks and /Examples. If you use checked-out projects, you need to close and delete these projects, then select /Frameworks and pick the ones you like. Note that - depending on what you actually use - it is WAY simpler than before, where you had to visit X subfolder for importing.

Packages
Also, moving stuff in ERX into packages has been a request for quite a while now. We had good reasons not to do this so far, there are numerous thread on the lists where you can read the arguments at your leasure. But eventually we had to do it and now is as good a time as any.

So: the current trunk in SVN contains the repackaged ERX and ERDirectToWeb, complete with all fixes that are needed to build Wonder itself. In your own apps, you should:

- commit outstanding changes (!)
- select the projects, run an "Organize imports"
- check all your EO templates, as a lot of stuff changed packages
- check all your logging configs. A stub ERXPatternLayout is currently
still in er.extensions, but it will go away soon.
- check any xxx.className property which has a er.extensions thing in
it *
- check your model for custom attributes which reference ERX classes
(erprototypes has been fixed)

Deployment

WOTaskd+JavaMonitor have been updated:

- backups of SiteConfigs in /Library/WebObjects/Configuration, prior
to changes. The name indicates the action that happened afterwards.
- fixed an issue with the app delete page
- selection in app detail page is now Ajax and kept
- JavaMonitor/wotaskd are now ERX apps with embedded frameworks

Monday, June 2, 2008

Short break

We interrupt our scheduled program for a news flash:

As of Saturday, Mai 30th 2008, we moved the Wonder repository to SVN. Check out the trunk via

svn co https://wonder.svn.sourceforge.net/svnroot/wonder/trunk/Wonder Wonder

The CVS repository will NOT be updated any time soon.

Now on with our regular schedule.

Friday, May 30, 2008

Thi(e)s(e) (2.5) Week(s) in Wonder

ERCoreBusinessLogic
ERCoreBusinessLogic has a nice new generic audit trail mechanism in the form of ERCAuditTrail. More documentation to come soon on this.

ERXKey
Chainable sort orders via ERXSortOrder (and/or ERXKey's sort order methods). For instance, you can do:

NSArray sortOrders = Person.LAST_NAME.asc().then(Person.FIRST_NAME).asc()).array();

ERXKey has "plural forms" of the sort order methods. For instance, Person.FIRST_NAME.ascs() (the "s" on the end will give you an NSArray containing a single eosortordering that represents "firstName asc") -- this is just a sort-cut for cases where you just have a single EOSortOrdering that you want to pass to a fetch spec.

Ajax
AjaxSubmitButton can perform a partial submit without having an updateContainerID specified now (which really could be considered a bug, which I usually don't list here, but it's handy to know). So it behaves similarly to AjaxUpdateLink and AjaxSubmitButton's without a partial submit in that it will turn into a background request only.

You can now control Ajax resource insertion by providing a delegate to ERXResponseRewriter via ERXResponseRewriter.setDelegate(yourDelegate). See ERXResponseRewriter.Delegate. This lets you override when the framework (or other code) asks to include "Ajax" "prototype.js" and instead replace it for your own custom resource. For instance, if you want to bundle all your js into a single file, you can provide a delegate that overrides requests for any of the individual files and instead use your custom ones, or replace files with a minimized version of the original which may only be used in production.

AjaxModalContainer
AjaxModalContainer got a bit of a face lift (this is quoted from my original post on wonder-disc:)

Previously if you put contents inside the container tag, it would always render, which could be really big if you have a repetition. Now you can set ajax=true, and it will fetch the contents in an Ajax request instead. If you set ajax=true, you must also provide an id binding.

Previously, all the Ajax requests that were happening were not tagged with the proper request header, so it made Ajax requests appear to the server to be non-ajax requests.

There is now an iBox.init() function that is exposed to allow reinitializing iBox. For instance, if you have iBoxes in an update
container, you will want to call this at the bottom of your container. We need to add a better, more generalized way, to address this problem at some point, because several of the libraries have similar requirements.

You really should carefully consider the use of the action binding. It does not execute as an Ajax request (I'm not sure why, but it's explicitly documented as such), which means you can burn your backtrack cache using it. The preferred method of use for modal container should really be external hrefs, direct contents, or the new ajax=true binding with contents. In fact, unless someone has an example where the action binding is valid (which is possible -- I just can't think of an example), I'm almost tempted to consider it deprecated, or at least the behavior might change to make it more like other action bindings on Ajax components.

Lastly, there's a new example in ModalContainerExample that shows AjaxModalContainer used inside a repetition with an ajax=true that contains a form that allows you to edit objects in the repetition.

Migrations
Migrations support more batch operations. For instance, previously you had to call .create() on a table prior to calling .setPrimaryKey(..). The Migration API now keeps track of whether or not it has been created and will work the same either way. Additionally, there are some new methods on ERXMigrationTable that provide support for PK generation through the usual EOF routes.

EOF
ERXQualifierInSubquery provides support for fetching objects of an entity where one of its to-many relationships matches a given qualifier.

ERXJDBCUtilities has some more convenience methods for doing ResultSet manipulation (for use primarily in complex migrations) via processConnection and processResultSetRows (see the javadoc for more info on using). Mainly these guys take care of opening and closing JDBC resources for you based on EOF adaptors.

ERXKeyGlobalID provides support for serializable EOKeyGlobalID's.

There is a new "globalID" prototype for storing globalID values in other EO's that uses ERXKeyGlobalID.

Rather than set the 4 or 5 recommended EC locking Properties, you can now just set er.extensions.ERXEC.safeLocking=true which will set all the recommended values for you instead.

Misc
ERXExtensions.initApp and ERXExtensions.initEOF static methods have been added to support running Wonder in test cases and main methods without wrapping your code in ERXMainRunner or a WOApplication.

ERXQuicksilverQualifier is a KeyValueQualifier that compares values with ERXStringUtilities.quicksilverContains, which considers "QS" to be 'equal' to "QuickSilver" -- matches the original string as long as the letters appear in sequence, but not necessarily contiguous. This does _NOT_ work in EOF -- only in memory.

"wo:img" and "wo:image" are now built-in shortcuts for the inline bindings parser.

Friday, May 16, 2008

Last Year's Last 20 Weeks in Wonder

We'll resume our regularly scheduled This Week in Wonder soon, but I had to go through all the ChangeLogs back to last year's WOWODC to figure out what I wanted to talk about at this year's WOWODC. I thought I'd go ahead and post my notes. There's very little detail here, but it was about 5000 lines of commit logs between June 2007 and January 2008, so these are just the ones that stood out to me. I'm sure there's a inadvertent bias towards thing I worked on (and things at the beginning of the list when I wasn't yet totally annoyed by changelogs).

5.4
* Lots of 5.4 compatibility work

Ajax
* AjaxPing - support very small Ajax poller that can refresh a larger container when the cache key changes
* AjaxInPlace - added support for link vs button submits + better support for being in an existing form
* AjaxLongResponse

Components
* ERXClickableContainer - makes arbitrary elements into links
* ERXWORepetition EO support - if er.extensions.ERXWORepetition.eoSupport=true, GIDs will be used instead of hashcodes
* ERXFlickrBatchNavigation/AjaxFlickrBatchNavigation
* ERXComponent - handy component baseclass

Deployment
* Wonder has slurped up JavaMonitor and wotaskd
* Lots of enhancements to JavaMonitor

EOF
* ERXJDBCConnectionAnalyzer (from GVC) to help debug when you have a connection problem
* Support for ordering adaptor operations (to support SQLServer)
* Put a nail in the coffin of editing context locking
* FrontBasePlugIn - predictable/stable constraint names (for use in migrations)
* Partial Entities (experimental) - more info
* JavaMemoryAdaptor - an in-memory "database" ... really handy for example apps and test cases

ERSelenium
* LOTS of enhancements

Migrations
* New ERXMigration baseclass for migrations that use SQL scripts
* Support for vendor-specific SQL scripts in script migrations
* ERXModelVersion is a top level class now
* Added new API-based migrations - ERXMigrationDatabase, ERXMigrationTable, ERXMigrationColumn

Qualifiers
* ERXFullTextQualifier (if your database supports it)
* ERXQ - shortcut methods for lots of different ways of creating qualifiers
* ERXS - shortcut methods for lots of different ways of creating sort orderings

WOOGNL
* Added support for // VALID on inline bindings

Misc
* New pluralizer for ERXLocalizer (ported from Rails)
* iPhone support in ERXBrowser
* Support for multiple connections in ERIMAdaptor
* Redesigned ERXCrypto to allow pluggable encryption algorithms
* Added support for encrypted properties
* ERXMutableURL
* ERXExpiringCache supports version numbers in addition to timeouts
* ERXStats / ERXStatisticsPage - much more powerful stats tracking
* Refuse new sessions on low memory
* ERXResourceManager supports WebServerResource versioning to control browser caching
* Finally a SINGLE Properties setting for default encoding - er.extensions.ERXApplication.DefaultEncoding
* Lots of enhancements to RuleModeler

New: ERAttachment.framework
Inspired by th attachment_fu rails gem. Provides drop-in support for attachments that can be easily stored locally as static resource, locally as proxied resources via a custom request handler, as in-database resources (not currently streamed out of the database, so this should really only be used for person icons and other small resources), or on S3 as remote resources. See package.html for more details.

ERAttachment, btw, might be my favorite framework in Wonder ... If you use in-database attachments, you're talking add one relationship to your entity and a almost-no-code migration, then drop an ERAttachmentUpload component in your edit page, and an ERAttachmentViewer in your view page, and that's it. Very high bang-for-the-buck.

New: ERChronic.framework
Natural language date parsing (well, assuming your "natural language" is English). Direct port of Chronic from ruby (see http://chronic.rubyforge.org/ and package.html for more details).

New: ERCaching.framework
Support for memcached with WO. I don't actually use this one yet, so Anjo can fill in more info here.

Friday, May 9, 2008

This Week in Wonder

Not the most exciting Week in Wonder, but they can't ALL be awesome :)

BugTracker
Attachments in BugTracker are now based on ERAttachments, and ERTags support has been added.

Migrations
Migrations now support creating blob columns without specifying a size (it appears most databases don't require it).

Migrations should work much more reliably with Derby.

Unique index declarations for Migrations now support passing the index length, which is necessary to support indexes on MySQL (which cannot exceed certain lengths).

Certain Migrations are now declared to be optional, meaning a failure of the plugin to generate SQL will not result in an exception, but instead a log error. Foreign keys is an example, as not all database support foreign key constraints, but it's not really a failure condition.

Migrations now support adding regular indexes (rather than just unique indexes).

ERAttachments
ERAttachments was converted from SQL-script-based migrations to api-based migrations. This should allow it to have much better support for other databases in the future.

Ajax
AjaxObserveField has a new "observeDelay" binding that gives better periodic refresh behavior. This is particularly useful for textfields so that it doesn't fire as often as it would with just the regular frequency setting. With frequency, if a change occurred within the frequency period, a request will fire. WIth observeDelay, the request will only fire after the specified observeDelay amount of idle time. So as long as you're typing, it won't fire. When you pause, it will then fire.

If you spell the name of an update container ID wrong, you will now get a javascript error from your update links and submit buttons telling you the specified update container could not be found rather than just getting an update with no response.

Batch Fetching
ERXBatchingDisplayGroup and ERXRecursiveBatchFetching have much better batch fetching behavior for to-one relationships to abstract entities (read: it works now vs ... it didn't before).

ERXBatchingDisplayGroup now supports defining and using prefetching relationship key paths.

ERXBatchingDisplayGroup now supports overriding the row count manually. If you have a better method of setting the number of rows in the results compared to the display group's, you can now set it yourself. For instance, if you know you're only ever going to fetch two pages, you could set your row count to page size * 2 and the display group will 1) not fetch more than the row count you set and 2) skip executing the count(*) query, which can potentially be expensive. If you guess too high, it will correct for you when it runs out of rows.

OGNL
Previously in OGNL, if you declared a helper function on a keypath and one of the elements of that keypath evaluated to null, WOOGNL was not able to identify which helper class to use. For instance, if you bound your value to "person.company.name|dosomething" and person was null, it would not know to use StringHelper.dosomething(..). Now when this happens, it will walk the keypath to figure out what classes are in use and properly pass a null to your helper function. This allows you to make helpers that can do null replacement (similar to valueWhenEmpty on WOString, but in the general case).

Misc
Instead of using ERXKey.append, you can now use ERXKey.dot, which makes sense when you read your code out loud, but more importantly it's three characters shorter, which is kind of nice.

Saturday, May 3, 2008

FishEye

Atlassian has provided a hosted FishEye for Project Wonder at http://fisheye1.cenqua.com/browse/wonder/.

This Belated Week in Wonder

EOF
If you use databases sequences for PK generation that have an increment greater than one, you can now set er.extensions.ERXPrimaryKeyBatchSize or entity.userInfo.ERXPrimaryKeyBatchSize and Wonder will automatically provide a high-low implementation in memory. This can be a big performance gain for insert-intensive applications.

This was actually last week, but I forgot to mention it. Sometimes in migrations, you have to drop down and perform JDBC operations. A common one is adding a column and needing to set computed values for those rows. ERXJDBCUtilities.processResultSet can make this a little bit easier:


ERXJDBCUtilities.processResultSet(channel, "select id from SomeTable", new ERXJDBCUtilities.IResultSetDelegate() {
  public void processRow(EOAdaptorChannel rsChannel, ResultSet rs) throws Exception {
    int id = rs.getInt("id");
    ERXJDBCUtilities.executeUpdate(rsChannel, "update SomeTable set uuid = '" + something + "' where id = " + id);
  }
});

There is now a longInt prototype added to ERPrototypes.

Qualifiers
ERXQ and chainable qualifiers now have qualifier.one(array) which will return the single object that matches the qualifier (or null if missing) or qualifier.requiredOne(array), which will do the same but throw an exception if it's not there. Additionally, you can call the variant qualifier.first(array), which will return the first object in the array (or null if there isn't one).

All qualifiers in Wonder now are chainable qualifiers.

ERXQ now provides the new shortcut methods .matches(..) (for regex qualification), .has(..) and .hasAtLeast(..) (for toMany qualifiers).

Properties
Often I find that it would be nice to not have my Properties defined inside my application bundle (so deployment of a new version is easier), but defining them in JavaMonitor can also be sort of annoying. Wonder now provides support for loading "machine global" properties. The default location for these Properties is /etc/WebObjects/[YourAppName]/Properties . You can change this default by setting er.extensions.ERXProperties.machinePropertiesPath .

ERRest
There were a bunch of extensions and additions to ERRest so that it can be used as an EO simple syncing framework. It's not designed to handle conflict resolution (yet), but if you have multiple applications or deployments that need to all share a common set of EO's, ERRest makes it relatively easy to do this. For syncing, you should either be using UUID PK's or there should be a globally unique attribute on your EO. You setup your master side just like a normal REST setup (except that you should set ERXRest.YourEntity.id=globallyUniqueAttributeName -- like ERXRest.Person.id=uuid). On the client, you can write:

EOEditingContext editingContext = ERXEC.newEditingContext();

ERXDefaultRestDelegate restDelegate = new ERXDefaultRestDelegate();
restDelegate.addDelegateForEntityNamed(new ERXUnsafeRestEntityDelegate(true), YourEntity1.ENTITY_NAME);
restDelegate.addDelegateForEntityNamed(new ERXUnsafeRestEntityDelegate(true), YourEntity2.ENTITY_NAME);
...
ERXRestContext restContext = new ERXRestContext(context(), editingContext, restDelegate);

String restPath = "Person";
URL remoteUrl = new URL("http://remotesite/rest/" + restPath + ".xml");
String contentStr = ERXFileUtilities.stringFromURL(remoteUrl);
ERXRestRequest restRequest = new ERXXmlRestRequestParser().parseRestRequest(restContext, contentStr, restPath);
ERXRestKey restResponse = restDelegate.process(restRequest, restContext);

editingContext.saveChanges();

This will sync all Person entities. You can sync arbitrary rest paths as well. For instance, in the example above, you could just as easily use a restPath of "Person/1231-23523-blah123234531-blah" to sync an individual person.

ERRest now also nested insertions, so you could have an update of a Person that does an insert of a new Company specified in the Person.company relationship. This is arbitrarily nested.

ERTaggable
If you use the default separator in ERTaggable, it now supports parsing tags surrounded by quotes with multiple words. For instance, you can now tag your objects: tag1 tag2 "multiple word tag3".

ERSelenium
ERSelenium now includes the necessary requirements for Selenium Remote Control -- see http://selenium-rc.openqa.org/. It's really cool.

Ajax
AjaxSelectionList can now grab focus (focus = true) and has lots of misc fixes.

AjaxBusyIndicator can now watch a particular updateContainerID and either apply styles to that container, or perform custom onCreate and onComplete functions when a request occurs (note, this is onCreate of the request, and onComplete of the request, to explain the odd naming). This makes it easier to make per-component busy indicators that don't just trigger on every request.

AjaxPing now has an onBeforeUpdate binding that you can provide a Javascript function that can deny the update.

AjaxSubmitButton now has an elementName binding like AjaxUpdateLink. This allows you to make "clickable divs" (like ERXClickableComponent) that are Ajax submits.

Some of the Ajax components cached their generated ID values. These generated values were previously based on the component's element ID. The problem with this is that when the page structure changes, these components could be left hanging onto an ID that now belongs to another component on the page. These components now use a new scheme for ID generation that takes advantage of the new ERXResponseRewriter's page userInfo, to generate unique cacheable IDs.

Misc
ERXFlickrBatchNavigation now supports changing the batch size (showBatchSizes and batchSizes) bindings.

ERXCommandLineTokenizer provides a parser for parsing "command line"-style parameters, where individual words are single tokens as well as multiple words in double quotes or single quotes.

ERXFileUtilities.stringFromURL(URL)

ERXFileUtilities.chmod(String, String) -- only works if you are on an OS that supports chmod

ERMovies was converted to migrations and should be a little easier to run out-of-the-box.

Thursday, April 24, 2008

This Week in Wonder

It's been a pretty busy week (and this is a lame effort to summarize 163 commit messages):

ERMovies
Ray Kiddy updated the movie example to 2008. New features include auto-populating DB and Apache Derby support.

Derby plugin
Used by BugTracker and ERMovies and now supported by ERPrototypes, it provides preliminary EOF support for Apache Derby. Most things seem to work, there are some issues with BLOBs, though.

ERXDelayedRequestHandler
If you ever have pages which *might* take a bit too long, but don't warrant a long response page, then this is for you. When you install this response handler (and use ERXApp) then a request that is taking too long is detached and the user is presented a "Uh, this might take a while, get some coffee" page - without you needing to do anything at all. And it has a "Stop now" button in case you don't actually want to finish the action.

This is also very useful when you are running in development and are dropped into a breakpoint. Normally, you'd get the adaptor error page but now it loops merrily until you continue.

loc:foo and negate:foo prefixes

These are the first implementations for the new prefix registration in the WOOgnl parser. They now also support carret bindings like ^title.

ERXLocalizerAssociation
loc:value = bar

first asks the current localizer to handle the value of bar. This is way more powerful and readable than before, where you would either need to use

value = session.localizer.bar

or write an accessor method.

ERXNegateAssociation
Ever had an accessor that was just the opposite of what you needed?

not:disabled = bar

helps here.

ERXRuntimeUtilities
There is no easy way in Java to stop one thread from another. Actually, it's not possible at all unless the thread is waiting in the exact moment you try to stop it. We added a few crucial points where the current thread checks it it should quit: whe fetching a row from the DB and when the context sets a current component.

You just call ERXRuntimeUtilities.checkThreadInterrupt() at regular intervals and the thread that wants to stop calls ERXRuntimeUtilities.addThreadInterrupt(Thread thread, String message).

ERRest
The REST framework is getting quite a bit of work done on it (with more coming soon).

The entity delegates resolver will now guess names that aren't registered (for instance, if you request /Manufacturer, it will look for a ManufacturerRestEntityDelegate), and you can now specify delegate names in Properties (ERXRest.Manufacturer.delegate=ERXUnsafeReadOnlyRestEntityDelegate).

The beginnings of the JSON input/output for ERXRest was committed, though not on by default (still experimental).

There are several new convenience methods for registering ERXRest. The simplest is to add:


ERXRestRequestHandler.register(new YourRestAuthenticationDelegate(), true, true);

to your Application constructor and add Properties entries for registering delegates.

ERXRest now supports non-integer keys. If a key in the URL isn't the property of an entity, it is treated as a key. You can now also specify a custom attribute on your EO's to act as the "id" value by setting:

ERXRest.Manufacturer.id=nameOfAttribute

, which allows your EO's to expose non-PK attributes as the lookup value. For instance, you could have a UUID "external ID" that can be used for syncing EO's across multiple applications.

Ajax Load-on-Demand
[MS: This is a repost from of the announcement the wonder-disc list]
This is the largest change to Ajax framework in a while, and because it introduces some breaking API changes, I wanted to explain what it's all about.

Previously, if you had a page that revealed a new Ajax component (new = first use on the page) only in an Ajax refresh, you are probably familiar with the problem that the necessary Javascript dependencies were not loaded correctly. The cause of this is that the component was hidden and did not have a chance to inject its dependencies into the head tag. With this most recent commit, Ajax framework (transparently) supports load-on-demand of Javascript dependencies. It keeps track of which scripts (and CSS) have been loaded on your page (both on the original render as well as subsequent Ajax requests) and if a new component introduced in an Ajax update requires a script that has not been loaded, it will switch to render the dependency with the new load-on-demand method.

The Javascript side of load-on-demand is actually a feature that appears that it will be in Prototype 2.0 which we have brought forward into wonder.js, and the Java side is just the usual Project Wonder black magic :)

So about breaking API changes and behavior changes:

Most of the ERXWOContext response rewriting methods have been moved to ERXResponseRewriter. They never really made a lot of sense on ERXWOContext, but especially now that these methods actually potentially consider information that crosses contexts, it made sense to reorganize them. Additionally, several of the API's have been changed -- most just to take a WOContext where they didn't before. The most notable API change is that previously the insertion behavior was controlled with two booleans which have now been replaced by an enumerated type that more clearly defines what the behavior of the insertion methods will be when the head tag is not present (either because it's just missing or because you're in an Ajax update). For most people, the only change you may need to make is to add the missing WOContext parameter if it's needed (the other variant of the method probably was not used very much).

As for behavioral changes, there is really one PRIMARY one (well aside from the whole load-on-demand thing). The big behavioral change is that previously you could actually "insert" script and css into the head tag BEFORE it actually existed. Generally this is only even an issue when you try to add script/css in your Page Wrapper by overriding appendToResponse and calling those method BEFORE super.appendToResponse (meaning your page wrapper has not yet rendered the head tag, but you're asking to insert into it). Because of some of the API changes, it was necessary to REMOVE this ability (long story, but the API's require a WOContext and the method that previously provided this ability did not have access to the WOContext to fulfill the API). The fix for this is relatively simple -- Just move any calls to those functions in your page wrapper AFTER the super.appendToResponse. This probably won't impact many people, but if it DOES impact you, it will manifest as your CSS and Javascript not injecting into the head tag and a warning will be generated on the console explaining what happened.

ERXStyleSheet and ERXJavaScript have been modified to register their loaded resources with the same system, so if you use an ERXStyleSheet or ERXJavaScript, it will not double-load if you later load scripts/css with ERXResponseRewriter. ERXStyleSheet will now SKIP rendering its stylesheet if it has already been loaded (so you can put ERXStyleSheet in Ajax rendered components in addition to using ERXResponseRewriter and it will behave the same). ERXJavaScript right now does not skip rendering, but it DOES register that it has loaded, so it will satisfy dependencies if you later use ERXResponseRewriter to load scripts on-demand.

If for some reason you want to turn off load-on-demand, you can 1) just keep doing things the way you were -- declare your scripts at the top level so they have all been loaded by the time the Ajax components render, or 2) set er.extensions.loadOnDemand=false.

While the actually lines of code of these changes is relatively small, it's conceptually sort of significant, so please try out your Ajax apps and let me know if you see any oddities. Hopefully this will make the components much more encapsulated and far easier to use for everyone ... Apologies for any backwards compatibility issues this introduces in the short term.

Misc Ajax
AjaxDroppable has an onBeforeDrop binding that lets you connect a javascript function before the drop happens. AjaxDroppable can also now act like a submit button instead of a link by setting submit = true. Both AjaxDraggable and AjaxDroppable got a shiny new paint job, too -- all the javascript that used to generate in the component output is now moved to wonder.js and the generated output is substantially smaller.

AjaxObserveField has a new onBeforeSubmit binding that allows you to return false to deny the submit.

Misc
ERD2WDirectAction now supports ErrorFoo?__message=bar calls which is an easy way to put up a error page.

We moved the work-in-progress stuff from ERXFetchSpecification to ERXGroupingFetchSpecification.

ERXObjectStoreCoordinatorSynchronizer: The synchronizer now exposes the ability for fine-grained sync controls between stacks. For instance, if you application is a write-mostly app, it may be undesirable to have inserts synced between EOF stacks. You can now setDefaultSettings on the synchronizer (or set the settings per-object store) to control exactly which types of operations will be synced across stacks, including turning syncing off entirely for particular stacks.

Thursday, April 17, 2008

This Week in Wonder

This Week in Wonder's schedule is all thrown off, but to finally catch us back up:

ERXFetchSpecification
This is still new and under development, but ERXFetchSpecification extends the concepts of a fetch spec and adds:

  • support for caching
  • type safety via generics
  • user info for tracking additional information as you pass a fetch spec around
  • support for grouping results by keypaths

One of the primary features here is caching. In EOF, if you traverse a to-many relationship, the GIDs of the members of that relationship are cached, which ensures that you don't have to do a db roundtrip every time you want to traverse your relationship. Unfortunately, if you use a fetch spec, there is no such cache provided and you always hit the database. ERXFetchSpecification allows fetch spec results to be cached to avoid repeatedly hitting the database. Again, this is still being developed, but Anjo has some very cool ideas for integrating fetch caching with memcached.

WOOGNL
The WOOGNL template parser now supports registering custom association prefixes. You can now set WOOgnl.setAssociationClassForPrefix(associationClass, prefix). This allows you to implement associations like i18n:value="title", which could load the "title" key from your localized strings. We haven't yet provided any out-of-the-box association classes yet, but we have several ideas (happily stolen from other frameworks :) ) that we will be implementing.

JNDI/LDAP
ERXModelGroup has always allowed replacing connection dictionaries on a model based on Properties values, but it only supported JDBC adaptor models. JNDI models are now supported with the properties:


[modelName].serverUrl the per-model server URL to set
[modelName].user the per-model username to set
[modelName].password the per-model password to set
[modelName].authenticationModel the per-model authenticationMethod to set
JNDI.global.serverUrl the global JNDI serverUrl to use by default
JNDI.global.username the global JNDI username to use by default
JNDI.global.password the global JNDI password to use by default
JNDI.global.authenticationMethod the global JNDI authenticationMethod to use by default


Misc
The new ERXModelDoc component provides a convenient way to display model documentation for a model, entity, attribute, and relationship.

ERXStyleSheet is more versatile now and supports optionally inlining the stylesheet vs injecting into the head tag.

You can now provide a custom subclass of the WOOGNL template parser by setting the property "ognl.parserClassName" to your custom subclass.

Response compression now supports stream-based responses.

ERXInOrQualifier is no longer on by default. We had to remove it as the default in 5.4, anyway, because of compatibility problems. If you want to re-enable it in your application, add EOQualifierSQLGeneration.Support.setSupportForClass(new ERXInOrQualifierSupport(), EOOrQualifier._CLASS); to your Application constructor.

ERXQualifierTraversal provides an implementation of the visitor pattern on qualifiers.

ERXProxyAssociation allows you to wrap an existing WOAssociation and inject a fixed prefix or suffix to the existing value.

ERXExpiringCache now supports timeouts per-key rather than just a global timeout for all cache entries.

ERDLinkToEditObject can link to to-one's now.

ERXEnterpriseObjectChangeListener provides a base class for implementing cache invalidation or other classes that need to be notified of changes to specific entities.

Saturday, April 12, 2008

JavaRESTAdaptor

I know ... There was no "This Week in Wonder" this week. Mostly because I had "This Week in Real Job". But here's a new framework in the Wonder family to tide you over till the Next Week in Wonder:

JavaRESTAdaptor
Note: My first post called this ERRESTAdaptor, but it's actually JavaRESTAdaptor, because all adaptors have to be named JavaXxxAdaptor. Whoops.

Overview
JavaRESTAdaptor is an EOF adaptor implementation on top of a RESTful web service, similar to ActiveResource in Rails. Currently JavaRESTAdaptor is read-only, but should be sufficient for consuming RESTful services.

Usage
The usage of JavaRESTAdaptor is best explained in an example. This example is adapted from an ActiveResource tutorial, but it provides several examples of common techniques. The service we're going to communicate with is a Beast installation. Beast is a simple Rails forum application. We'll use http://beast.caboo.se as our example service provider.

Creating the Model
Note that the instructions here assume that you're using the build of WOLips that builds tonight (to be able to pick "REST" from the adaptor list).


  1. Create a Wonder project.

  2. Create an EOModel (of any name) and choose "None" from the list of adaptors in the wizard.

  3. In the default database config (assuming you're using a recent WOLips), select the prototype "EORESTPrototypes" and select the Adaptor "REST".

  4. In the URL, enter "http://beast.caboo.se" and leave the username and password blank (currently JavaRESTAdaptor does not support HTTP authentication).


Creating Entites
Beast provides four entities that we want to interact with: Forum, Topic, Post, User.

  1. Create an entity named Forum.

  2. The "table name" of Forum will tell JavaRESTAdaptor the URL extensions and XML tags that can be used to access the entity. In the case of Forum, the XML tag name comes in two variants -- a singular and a plural form. For the Forum entity, set the table name to "forum,forums".

    Table name for JavaRESTAdaptor comes in several forms:
    • If you do not set a table name, JavaRESTAdaptor will simply use the entity name as the singular form, and use ERXLocalizer to generate a plural form.

    • If you only set a single value (i.e. "forum"), the adaptor will use that as the singular form and use ERXLocalizer to generate a plural form.

    • If you specify two values (i.e. "forum,forums"), the adaptor will use the first value as the singular form and the second value as the plural form.

    • Additionally, as you will see later, you can specify a set of possibly URL prefixes to use to access the entity. When you do not specify a URL prefix (as in our Forum example), the adaptor will assume that it can go to /[plural form].xml and /[plural form]/[id].xml to retrieve objects of this entity type.

  3. We need to determine the attributes of Forum, so open http://beast.caboo.se/forums.xml in your browser and view the source. ActiveRecord (or more importantly Ruby) can one-up us here, because they automatically determine the attributes of records based on queries to the service. We ultimately want to generate Java code, so we need to create an EOModel with attributes.

  4. Forum has the attributes: description, description-html, id, name, position, posts-count, and topics-count. Create attributes in your entity with the names converted to camelCase (description-html becomes descriptionHtml, etc). For each attribute, select a representative prototype, and set the external name to be the original name from the XML. For example, descriptionHtml is a "varcharLarge" prototype (we could pick one with a smaller restriction if we want to limit the values) and its external name is "description-html". postsCount is an "intNumber" and its external name is "posts-count". Do this for the rest of the attributes of Forum.

  5. In Beast, forums contain topics, so let's create the Topic entity. Topics present an interesting issue with modeling, because Beast does not allow you to select topics from the top level, rather you can only select topics through a Forum. For example, there is no /topics/1.xml there is only /forums/1/topics/1.xml.

    This oddity does cause some problems for EOF, because EOF expects to be able to fetch objects with only a primary key. JavaRESTAdaptor provides the ability to model fetching these entities, but you should be careful of places where EOF may cause faults for individual objects. You may find it safer to model relationships to entities of this type in code with fetch specs, or if you're using the Wonder eogen templates, traverse these kind of relationships with forum.topics(null, true), which will force a refetch of the entities.

  6. Request http://beast.caboo.se/forums/1/topics.xml to see an example of what topics look like. Follow the same procedure as for Forum, creating attributes from the XML. For dates, use the prototype "dateTime". For foreign keys, use the attribute "id" and mark them as non-class attributes.

  7. Now to address the URL issue for Topics. Because there is no /topics.xml, we need to tell JavaRESTAdaptor how to find topic objects. Edit the Topic entity and set the table name to "/forums/[forumID]/topics,topic,topics". This says that to fetch a topic, you must use the URL "/forums/[forumID]/topics" where forumID is a variable that corresponds to the Topic attribute of the same name. Any time a fetch is performed on a Topic, a forumID must appear in the qualifier or an exception will be thrown from JavaRESTAdaptor. When traversing a to-many relationship from a Forum to a Topic, this happens automatically inside of EOF. However, if you are trying to fetch a particular topic, you must provide its forum in your qualifier to prevent an error.

  8. Now create the Post entity. Posts are similar to Topics in that you cannot access them from the top level of the service, but they can be accessed in several different ways. It turns out that you can get posts for a user, for a forum, or for a topic (which requires a forum). JavaRESTAdaptor allows you to model these methods as alternative URLs in the table name by separating the URLs with a pipe. For instance, the table name for Post is "/users/[userID]/posts|/forums/[forumID]/posts|/forums/[forumID]/topics/[topicID]/posts,post,posts". I admit this is ugly, and ideally these definitions would be defined on the relationships instead of the entity, but unfortunately at the adaptor level, the EORelationship that was used to fetch the objects is long gone. What ERREST does in this case is that it looks at the qualifier provided and finds the URL that matches the most variables from your qualifier keys and uses that as the fetching URL. For instance, if your qualifier only has a userID in it, the /users/[userID]/posts URL will be used. However, if you qualifier has a forumID and a topicID in it, the /forums/[forumID]/topics/[topicID]/posts will be used. An exception will be thrown if a suitable URL cannot be found given the provided qualifier.

  9. Lastly, create your User entity. Nothing fancy here, and top-level fetches are allowed, so take a look at http://beast.caboo.se/users.xml to create your attributes, and use the table name "user,users" on this entity.


Relationships
You have created all of the entities for reading information from Beast. You can now create the relationships between these entities. For entities that can be fetched from the top level, or when modeling relationships that will provide enough context for the fetch, relationships can be modeled just like a normal eomodel.

For instance, from post.user() is a completely normal to-one relationship because User can be fetched from the top level, and post will provide the "id" necessary to execute the fetch. Similarly, forum.topics() is a normal to-many relationship, because while Topic does not have a topic level fetch URL, traversing the relationship from Forum will provide the "forumID" necessary to complete the fetch.

The "problem child" relationships are, for instance, topic.posts(). Traversing the posts relationship on Topic will only provide a topicID. Unfortunately Posts requires a topicID AND a forumID. It turns out that this can be modeled by putting both topicID and forumID in the joins of the to-many relationship definition. The downside of this is that it will not be symmetric with the other side of the relationship, and will not be updated automatically when write ability is added to JavaRESTAdaptor. The other problem is that, while this technique works on to-many relationships, it does not work on to-one relationships. EOF does not allow a to-one relationship to be defined with a join on anything expect a primary key attribute.

In this situation, you will need to construct the relationship using a fetch spec, and not using normal relationship definitions in the model. Your fetch spec will work just like a normal fetch spec, but you must provide all variables necessary to complete a fetch. As an example, if you want to fetch a particular topic, you must fetch it like:


Topic singleTopic = Topic.fetchRequiredTopic(editingContext, Topic.FORUM.eq(aForum).and(ERXQ.equals("id", 633)));


or


aForum.topics(ERXQ.equals("id", 633), true)


Note that JavaRESTAdaptor allows fetching on non-class attributes.

Fetching Notes
When fetching against the remote service, only topic level EOKeyValueQualifiers, EOAndQualifiers, and EOOrQualifiers with a single entry will be processed for constructing the remote URL. Complex qualifiers can be constructed, but they will be evaluated in-memory against the most restrictive URL that could be constructed given your qualifier attributes.

Examples

EOEditingContext editingContext = ERXEC.newEditingContext();

NSArray forums = Forum.fetchAllForums(editingContext);
System.out.println("Application.Application: Fetching all forums");
for (Forum forum : forums) {
System.out.println("Application.Application: " + forum.name() + ", " + forum.postsCount() + ", " + forum.topicsCount());
}

System.out.println("Application.Application: Fetching forum w/ PK");
Forum singleForum = (Forum) EOUtilities.objectWithPrimaryKeyValue(editingContext, Forum.ENTITY_NAME, "3");
System.out.println("Application.Application: " + singleForum.name());

System.out.println("Application.Application: Fetching topics for " + singleForum.name());
NSArray topics = singleForum.topics();
for (Topic topic : topics) {
System.out.println("Application.Application: " + topic.title() + " created " + topic.createdAt());
}

System.out.println("Application.Application: Fetching posts for forum");
NSArray forumPosts = singleForum.posts();
for (Post post : forumPosts) {
System.out.println("Application.Application: " + post.createdAt());
}

System.out.println("Application.Application: Refetching single topic w/ PK");
Topic singleTopic = Topic.fetchRequiredTopic(editingContext, Topic.FORUM.eq(singleForum).and(ERXQ.equals("id", 633)));
System.out.println("Application.Application: " + singleTopic.title());

System.out.println("Application.Application: Fetching topic user");
User user = singleTopic.user();
System.out.println("Application.Application: " + user.displayName());

System.out.println("Application.Application: Fetching posts for topic (composite pk, which is kind of interesting)");
NSArray topicPosts = singleTopic.posts();
for (Post post : topicPosts) {
System.out.println("Application.Application: " + post.createdAt());
}

Post randomPost = topicPosts.lastObject();
System.out.println("Application.Application: Fetching the topic for a post (this will break if topic is not already fetched)");
System.out.println("Application.Application: " + randomPost.topic().title());

System.out.println("Application.Application: Fetch author of post");
User postedByUser = randomPost.user();
System.out.println("Application.Application: " + postedByUser.displayName());

System.out.println("Application.Application: Fetching posts by author");
NSArray userPosts = postedByUser.posts();
for (Post post : userPosts) {
System.out.println("Application.Application: " + post.createdAt());
}


Check out JavaRESTAdaptorExample project to see the model described here fully completed.