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.

Wednesday, April 2, 2008

This Week In Wonder

The big one for this week is much better 5.4.x support. We've fixed quite a few outstanding issues and we should be in a pretty good place when the next 5.4.x release comes out (which is looking good).

Wonder/5.4 Changes
ERXWOForm
ERXWOForm works properly with the new 5.4 context.isSecure setting (defaulting to secure if context.isSecure())

ERXWOConditional/ERXElse
ERXWOConditional/ERXElse simply cannot play nicely with 5.4 wo:if/wo:else. In the 5.4 build of Wonder, a notable change is that you need to pick your conditional horse. In 5.4, WOConditional will no longer be automatically replaced by ERXWOConditional. WOOgnl's wo:if and wo:else will still resolve to the ERX variant, but if you use WOConditional directly and you want the Wonder behavior, you will need to search for all ":\s*WOConditional" and change them to ": ERXWOConditional". We looked at this quite a bit, but the semantic of the "else" implementation in 5.4 is very different than Wonder's, and continuing to replace WOConditional in the way that we do would break any 3rd party 5.4 components (like Apple's) that are written to expect if/else to work like 5.4's.

[edit: Oh -- I forgot to mention. If you DO NOT intend to use 5.4's if/else and you just want to switch to 5.4 without having to change your components, you can set er.extensions.WOConditional.patch=true and it will override the default disabled patching of WOConditional to be ERXWOConditionl. At the moment this should be OK, because none of the Apple components use their if/else, but in the longer term, you should switch over to ERXWOConditional if you intend to use ERXElse]

ERMemoryAdaptor
This .... actually builds now in 5.4.

ERXWOContext
Through a small bit of trickery, ERXWOContext URL rewriting fully works with 5.4's new context API's.

Foundation
The 5.3 Wonder NS* collections classes better match the 5.4 versions so there should be fewer compatibility issues (which was an issue if you were running 5.4 code with the ERExtensions project checked out).

FrontBasePlugIn and PostgresqlPlugIn
Both of these plugins have been updated/slightly mangled to properly generate SQL under both 5.3 and 5.4 (as long as you aren't calling the new 5.4 schema sync API's). Pierre has merged nearly all (except the latest feature where you can generate SQL without a running database) of the Wonder FrontBasePlugIn features into 5.4, and it fully implements both the 5.3 and 5.4 schema sync API's, so Apple's should be the preferred one under 5.4. Wonder still maintains the primary PG plugin, though, so you will be limited to 5.3 schema sync for now. If you're doing anything with schema sync/sql gen, you need to be very careful of what API's you are using -- it's a bit of a minefield in 5.4 when you're using anything except the built-in plugins.

Source
Almost all of Wonder runs under both 5.3 and 5.4 without mucking with your build path. However, because of some refactorings in WOOgnl, if you are checking out the Wonder source in Eclipse, you will have to remove the Sources_WO53 from your WOOgnl build path and add Sources_WO54 to your build path if you intend to use 5.4. There was unfortunately no obvious way around one.

Other Misc Things
Ajax/ERXFlickrBatchNavigation now support pagination of plain java arrays without using a display group, which should make it easier to paginate non-WOish collections.

ERXKey supports an easier API for filtering arrays. For instance:

NSArray filteredCompanies = Company.NAME.is("Mike").filter(arrayOfCompanies);

WOLips.framework and Click2Open now work under FireFox and IE.

Wednesday, March 26, 2008

This week in Wonder

AjaxModalContainer updated

The AjaxModalContainer has been updated to ibox 2.17. It now has an example with the various options it supports, like images, inline content, external URLs etc.

Wednesday, March 19, 2008

This Week In Wonder

Misc Stuff
AjaxTabbedPanel tracks selected tabs and allows you track the selection. Check out AjaxTabbedPanelDemo for an example.

ERXStyleSheet generates a <link> tag. For non-XHTML, browsers expect the link tag to not have a closing tag. You can now set "er.extensions.ERXStyleSheet.xhtml=false" to make your link tags not generate a closing tag.

ERXWOContext now has a bunch of static directActionUrl(..) generation methods that allow you to override various combinations of host name, port, path, directaction name, http/https, and query string params.

JSON
The big one for this week is the enhanced JSON features (with a lot more surprises coming). We've had page-based JSON proxy support almost since the beginning, but it has been enhanced quite a bit along with the addition of a JSON Request Handler for JSON web services. We've upgraded our implementation from the old metaparadigm.com JSON library to the new jabsorb.org library (which metaparadigm turned into). We also spent some time to add some new JSON EO features. One of the problems we had previously was the complexity of the demo app for JSON. There are now much easier examples that show just how simple it is to pass data around. You can hand an NSArray of EO's to your browser client and the browser can make changes and hand them back -- more to come on this front.

Stateful Page Clients
Do you need access to stateful objects from your component in the browser? Just bind:


AjaxProxy : AjaxProxy {
name = "json";
proxyName = "example";
proxy = proxy;
}

make a "proxy" method that returns an object that you want to be able to message (if you leave the proxy binding off, it will bind to your component directly):

public SomeProxyObject proxy() {
return _proxy;
}

public class SomeProxyObject {
public NSArray people() { ... } // these can be EO's!
public void doSomethingWithAPerson(Person person) { ... }
}

and then in javascript:

var people = json.example.people();
people.nsarray.each(function(person, index) { alert(person.firstName); }
json.example.doSomethingWithAPerson(people[0]);

It's pretty cool how easy it is.

JSON Web Services
Or you can use JSON for web services instead of SOAP/WOWebServices:

In your Application:

JSONRequestHandler requestHandler = JSONRequestHandler.register();
requestHandler.registerService("exampleService", new ExampleService());

Your service class is similar to a registered WOWebService class:

public class ExampleService {
public void printThisString(String string) { .. }
}

JSON services also support "local args", which allow the server to fill in parameters to your method for you based on the request. For instance, if your method is stateful and you need a session, you can just add a WOSession parameter to your method:

public class ExampleService {
public void printThisStringStateful(WOSession session, String string) { .. }
}

And you will be given a session, and the session will be maintained with cookies. The external signature of the method does not change. This works for WOSession, WORequest, WOResponse, and WOContext.

JSON Browser Client
If you want to call your JSON service from a component:

<webobject name = "AjaxJSONClient"/>.exampleService.printThisString('hi');


AjaxJSONClient : AjaxJSONClient {
}

JSON Java Client
If you need JSON in a Java client app:

Client client = JavaJSONClient.create("http://yourhost/cgi-bin/WebObjects/YourApp.woa/-yourPort/json", true);
IExampleService exampleService = (IExample) client.openProxy("exampleService", IExampleService.class);
exampleService.printhisString("hi");

public interface IExampleService {
public void printThisString(String str);
}

(the "true" means you want to use HttpClient as the backing impl, which requires you have that installed in your classpath). Currently there is no stubs generator, so you have to write the stub classes yourself. For most classes it's pretty straightforward (just write the accessor methods). For EO's, it's the same, but you should extend JSONEnterpriseObject on the client. JSONEnterpriseObject just exposes a set/getGlobalID method for tracking purposes. Note that EO's in a Java JSON client app do not track changes -- they only support pass-by-reference right now. That may change at some point.

Check out JSONExample in the AjaxExample app for a bunch of examples that show various ways to use the feature.

Wednesday, March 12, 2008

This Week in Wonder

Automatic Inverse Relationship Updating
This feature was partially implemented a while back, but it didn't work in all cases. This now should work all the time (Chuck! It has test cases!). Essentially what it means is that you no longer have to think about addObjectToBothSidesOfBlah or removeObjectFromBothSidesBlah, you can just use the normal EOF methods and it will automatically call the necessary methods to update your relationships.

The EOGenerator templates that ship with WOLips (and that were inherited from some long-since-paste original version) have always had methods that made this easier -- the person.setCompanyRelationship(company) and company.addToEmployeesRelationship(Person person) methods, and these are nice in code, but you are vulnerable in certain cases (like binding in components) that don't know about those methods and can leave you with only one side being updated properly.

There are new Wonder templates in WOLips that provide overrides for the core setXxx method variants, and they check to see if inverse updating is enabled. If it is, then the new way will be used, if not, the old way will be. So in the above example, when auto-updating of inverse relationships is enabled, you can can person.setCompany(company) and company.addToEmployees(person), and it will Do The Right Thing™.

To enable it, in your Properties file, just set:

er.extensions.ERXEnterpriseObject.updateInverseRelationships=true

Misc API
ERXJavaScript now has the same binding naming conventions as ERXStyleSheet (and the rest of WO) -- framework = "xxx" filename = "yyy", though the old bindings are still maintained.

Utilities
ERXUtilities.deepClone (for anything -- it will call the corresponding object, array, or dictionary methods), ERXArrayUtilities.deepClone (for arrays), and ERXDictionaryUtilities.deepClone (for dictionaries) have been added. If you ever run into a situation where cloning a dictionary is not enough, and you need to clone arrays and dictionaries INSIDE that dictionary, these are the methods for you. deepClone will attempt to recursively clone all of the objects in the graph. You can optionally have it clone just the collections or the leaf nodes as well. Leaf nodes will only clone if they implement Cloneable and provide a clone method -- Currently this will not properly clone EO's, for instance.

Database PlugIns
There's been a long-standing totally annoying (what I consider a) bug in EOF that you have to open a database connection to be able to retrieve jdbc2Info, which is required to do things like SQL generation. If you've ever noticed when you made a new model in EOModeler, or when you try to generate SQL in Entity Modeler, it would yell at you if it couldn't connect to your DB, that's why. jdbc2Info contains things like database type information, which is almost always static with your database version.

Thanks to Andrew Lindesay, the plugins in Wonder (Postgresql and FrontBase right now) both now provide overrides for loading jdbc2Info from a static resource in the plugin jar, which means you can fully create a model and generate SQL without needing a database connection.

For postgresql, make your connection string: jdbc:postgresql://yourhost/yourdb?useBundledJdbcInfo=true

For FrontBase, make your connection string: jdbc:FrontBase://yourhost/yourdb/useBundledJdbcInfo=true

Click-To-Open
Chuck documented Click-To-Open support here.

Ajax
Ajax framework has been upgraded to Prototype 1.6 and Scriptaculous 1.8. Check your apps accordingly.

Wednesday, March 5, 2008

This Week in Wonder

Every two weeks might make more sense, but as soon as I say that, they'll be a flurry of commits to Wonder and it will be a huge post :)

Migrations
Migrations were made more compatible for people not using ERPrototypes. One of the tricky parts of migrations is converting the API request into a database type (for instance, getting newStringColumn to turn into a VARCHAR in your db). EOF doesn't do a very good job at guessing these values, and in some cases it's impossible to guess. When you use ERPrototypes, we can secretly cheat and lookup some known prototype values. If you don't, though, we have to guess effectively. The guessing code was made better, as well as an explicit override for an unguessable type in Postgresql. So migrations should work properly for PG and FB (at least) even if you don't use ERPrototypes now.

Why aren't you using ERPrototypes again? When you use ERPrototypes, Entity Modeler will work more efficiently as well. For instance, when you create a new entity, it will automatically give you an "id" column that is of the "id" prototype.

Property Operators (Properators?)
There are certain cases where you want to be able to have conditional Properties, or properties that get processed in some special way at load time. Wonder now offers support for "property operators". Similar to NSArray operators, you can register operators that will allow you to convert, extend, modify, and add properties during the loading process.

As an example, you can register and use the "Encrypted" operator in your Application's static block (these have to load very early):

static {
ERXProperties.setOperatorForKey(new ERXProperties.EncryptedOperator(), ERXProperties.EncryptedOperator.Key);
}

and you can then specify properties like:

com.mdimension.somesecretvalue.@encrypted=akxb)*@HASBC*#@$&%&@(NSJKX&XZ#

which will use Wonder's default crypter to decrypt the value when it loads.

Or, if you happen to have, say, a really really big WO deployment, you may want to override properties based on instance range, so you can register the InRange operator named "forInstance":

static {
ERXProperties.setOperatorForKey(new ERXProperties.InRangeOperator(ERXProperties.intValueForKey("yourInstanceNumber")), ERXProperties.InRangeOperator.ForInstanceKey);
}

and make a property:
com.mdimension.somethingNotReadyForFullDeployment.@forInstance.100-500,1000-1500=sometestvalue

Note that instance number is a per-request concept, generally, so it's up to you to specify what "instance number" means to your app (so you would have to define and pass in instance number in Java Monitor). This is a pretty specialized feature, but if you have the problem, this should help.

You can write and register your own operators, though, so if you ever have to perform some processing on keys and values, you know where to look.

Wednesday, February 27, 2008

This Week in Wonder

I thought it might be kind of useful to summarize the commits to Project Wonder that don't end up getting a top-billing article of their own for folks who don't just sit waiting for their wonder-cvs mailing list phone to ring.  We end up having to do this when we write release notes each year, anyway, so this might give us a head-start.

Given that this is the first one, I thought I'd catch us up for 2008.  So bear with me, this might be a big post :) I hope to do this on a semi-regular basis, maybe once a week.

ERXKey and Chainable Qualifiers
There are many ways to construct qualifiers in code, but there's often a trade-off between verbosity and type safety.  ERXKey and chainable qualifiers add  pretty cool balance that provides very readable qualifiers while also ensuring type-safety and compile-time checking.  For example:

Person.country.is(germany).and(Person.birthDate.after(someRandomDate));

Also check out ERXQ for a bunch of handy shortcuts for building qualifiers.

JavaMonitor
JavaMonitor was open-sourced in WebObjects 5.4 and slurped into the Project Wonder tree. Anjo has already cleaned things up quite a bit and has started making this old dog do some new tricks.
* Lots of code cleanups
* "Bounce" Action
* Refuse New Sessions bug fixes
* "Statistics" action

Migrations
Lots of new things on the database migration front.
* support for changing allows null constraints
* support for renaming tables and columns
* support for defining unique indexes

AjaxSelectionList
AjaxSelectionList is a component for rendering selectable list views with full keyboard navigation support. Think of it as a WOPopupButton with component renderers for each node.

ERXExpiringCache
ERXExpiringCache now supports reaping with a background thread, which makes it quite a bit safer

EROpenID
Chris Meyer donated all the patches necessary to bring EROpenID into compliance with OpenID 2.0.

WOLips.framework
When combined with a recent WOLips nightly and extending ERXComponent, WOLips.framework provides some very slick debugging tools, like the ability to click on arbitrary components in your web browser and have the corresponding component in WOLips. Check out the screencast at the mDimension build site. Anjo added support for click-to-open in all of the ERD2W components as well.

ERXPageTracker
Anjo added support for easily integrating with Google Analytics via the ERXPageTracker component.

ERXSQLHelper
Lots of additional cross-database SQL trickery added, like support for generating group by's, having's, and other more complicated SQL constructs.

ERTaggable
Based on the Rails acts_as_taggable plugin, ERTaggable provides a very easy way to drop in support for tagging arbitrary entities in your application along with several useful components for inputting and displaying tags (slick tab-completing like del.icio.us, tag clouds, etc).

Ajax Partial Submits
Due to the way WO handles missing form values during a submit, getting partial submits to work properly with Ajax.framework has been a problem for quite a while. The partial submit problem has finally been solved, and in a way that does not require custom input tags. Check out ERXAjaxContext for more info.

ERXRssPage
Surprised this didn't exist already? Me, too. But finally there is a very easy way to generate RSS feeds with Wonder.

JSON and YUI
Anjo already wrote about his new JSON and YUI enhancements in previous posts.

ERXClickableContainer
Need a clickable div that fires an action like a WOHyperlink? ERXClickableContainer is your man.

currencyAmount / amount prototypes
These prototypes had some shoddy definitions in some of the databases. This has been corrected to be a fixed precision number in all of the supported databases. Double-check your apps on this one.

General Ajax Improvements
The html generation of Ajax submits has been substantially size-optimized. If you had lots of Ajax submits on a page, your page just got a lot smaller. Also, the long-standing bug that could cause an update area to disappear under clicking-to-fast-in-just-the-right-circumstances has finally been fixed. The bad man is gone.

URL Rewriting
If you've been using ERXApplication's _rewriteUrl method, for the common case where you just want to pop off the /cgi-bin/WebObjects/YourApp.woa and replace it with something .... not 30 characters long, check out the er.extensions.ERXApplication.replaceApplicationPath.pattern and er.extensions.ERXApplication.replaceApplicationPath.replace properties.

Turn off Secure
If you develop with DirectConnect (or you're too lazy too setup SSL on your dev Apache), you've probably been stuck by your secure=true links or forms in development. Never again ... Just set er.extensions.ERXRequest.secureDisabled=true and all https:// URLs will be disabled. Note that this will ignore you if isDevelopmentMode is false, just to prevent you from hurting yourself.

AjaxObserveField
AjaxObserveField was useful for observing single form elements, but was a big of a pain for observing a set of them. You can now wrap a set of form elements in an AjaxObserveField and it will observe all of them for you. You no longer have to set your own unique id's on each of the fields.

Those are the ones that stood out to me as I skimmed the ChangeLogs. For all of the gritty details, you can read them in all of their glory at http://webobjects.mdimension.com/wonder/ChangeLog.txt. Apologies to any commits that I may have overlooked -- let me know if I missed something deserving (and I'm sure this is totally skewed towards my own commits :) ).

There was a lot to go through, and we're only about 60 days into 2008!