This isn't related to anything from the Mendis book, but rather comes from a discussion Griffin and I were having about a project I plan to work on in the future. He wrote some really great stuff, and I wanted to share it.
How would you implement URLs like http://www.site.com/articles/1234 in WO?
It's already handled quite conveniently (and nearly invisibly) by the WOResourceManager. This is a singleton object that manages an application's resources.
If you want to add an image or a reference to a static page in your web site, first copy the file into your Web Server Resources group in Xcode by the following steps:
* select the Web Server Resources group in the Groups & Files pane
* either right click on the group and choose Add->Existing Files... from the pop-down menu, or choose the Project->Add to Project... menu item
* navigate the Open panel to the directory containing your static resources and select it (or them)
* click the Add button in the Open panel to display the Add Items sheet
* check the "Copy items into destination group's folder (if needed)"
* you can typically leave the "Reference Type:" and "Text Encoding" pop-down menus alone
* click the "Recursively create groups for any added folders" (for reasons I'll explain below)
* click the "Web Server" check box in the "Add To Targets" list
* click the Add button.
Once your static resources have been added to this group in your project directory, they are available to your WOComponents. So, if you're adding an image that you've just copied to your project to a WOComponent page:
* open the WOComponent in WOBuilder
* add a WOImage to your page from the Dynamic pop-down menu
* double click on the WOImage in the page to simultaneously select it and to open the WOImage Binding Inspector
* click the reveal triangles to the far right side of the "filename" attribute to reveal a drop-down menu
* choose the filename of the resource that you had copied into the Web Server Resources group earlier
On doing so, you will see the file name (without associated path) appear in quotes as the binding for the "filename" attribute
The rest is up to the resource manager. You can move the file anywhere you want, so long as you let Xcode know where you moved it by updating the GetInfo panel for that resource after you move it. Clearly, there are limits. In particular, you have to move it somewhere in which it can be found in a comparable location on your deployment server.
If you have a hierarchy of resources in a directory with subdirectories, you can move the entire hierarchy into your project at once. The easiest way that I've found to do this is with both Xcode and the Finder. With your project displayed in an open Xcode window, open a Finder window and navigate it to the hierarchy of resources that you want in your project. Then click and option-drag (to copy) the hierarchy from the Finder window into the Groups & Files pane of Xcode, dropping the hierarchy directly beneath the group in which you want it copied.
Earlier, I suggested clicking "Recursively create groups for any added folders" when moving the resources. If you do this, then Xcode recognizes every file in every directory and sub-directory of the copied hierarchy. If you click the other radio button ("Create folder references for any added folders"), then although Xcode will copy the entire hierarchy, it only recognizes (indexes) the top directory as an independent entity and ignores (fails to index) every file and directory below the top, presuming that some other tool (e.g. EOModeler, WOBuilder or some such) will deal with the files and directories below that top level.
Comments