webgui/docs/migration.txt

86 lines
3.9 KiB
Text

WebGUI 8 Migration Guide
------------------------
The information contained herein documents the API changes that have occurred in the WebGUI 8 development effort and how to migrate your code to accomodate the new APIs.
WebGUI::Cache
=============
WebGUI::Cache has been completely rewritten. If you were using the cache API in the past, you'll need to update your code to reflect the changes. NOTE: you can get a cached reference to the cache object from WebGUI::Session, which will be substantially faster than instantiating the object yourself.
my $cache = $session->cache;
WebGUI::Asset
=============
The Asset API has been changed in small, but significant ways. You'll need to make a few changes to your asset subclasses to support these changes.
Definition
----------
You must migrate your asset to use the new WebGUI::Definition::Asset class instead of the definition() method. This executes several orders of magnitude faster, but is different in a few ways.
1) You define your definition using property and attribute calls, as well as standard Moose syntax.
2) You no longer have a reference to $session, so you'll need to make sub routine refs to to method calls. However, you cannot use sub refs on any attributes or the following property elements: tableName, fieldType.
3) You no longer have the "customDrawMethod" element. You must make custom form controls.
4) You no longer have filters. Instead, each property has a method called propertyName (so a property called 'title' would be title()). You can override that to achieve the same result.
5) Because you don't have a reference to $session, you can't internationalize right in the definition. So property elements like "label" and "hoverHelp" are just i18n identifiers and will automatically be run through internationalization on calling the getProperty() method.
6) Definition's are now rigid. This means that every property needs to be defined in the definition, and it must at least have a "fieldType" element. If the field is to be displayed (ie: it doesn't have a noFormPost=>1 element) then it must also at minimum have label elements. In addition, you must specify assetName, tableName, and properties attributes at minimum. Anything less is invalid.
7) The properties attribute must be an array reference of properties. No more Tie::IxHash.
8) The autoGenerateForms has been removed. All edit forms are autogenerated in WebGUI 8.
9) You no longer have the "visible" element. It was a duplicate of "noFormPost", so use "noFormPost" instead.
10) You no longer have the "displayOnly" element. Make a custom form control instead.
11) You no longer have the "allowEmpty" element. However, you can now specify an initial value in the "value" element, and set "defaultValue" to undef if you want to have an initial value but allow the field to become empty or undef.
Here's an example.
use WebGUI::Definition::Asset (
assetName => 'Gadget',
tableName => 'gadget',
properties => [
urlToJavascript => {
fieldType => 'url',
label => ['URL to Javascript Class','Asset_Gadget'],
hoverHelp => ['URL to Javascript Class help','Asset_Gadget'],
},
foo => {
fieldType => 'text',
noFormPost => 1,
},
bar => {
fieldType => 'codearea',
uiLevel => 9,
label => ['Bar','Asset_Gadget'],
hoverHelp => ['Bar help','Asset_Gadget'],
defaultValue => sub {
my $self = shift;
return $self->callSomeMethod;
}
},
],
);
Removed Methods
---------------
assetDbProperties - Simply instantiate the asset if you want it's properties.
assetExists - Simply instantiate the asset if you want to know if it exists.
getValue - Use get() or the individual property accessors instead.
fixTitle - The title() method does what this used to do as the title is set.
fixUrlFromParent - This functionality is built into fixUrl, so that all fixes happen and can't cause breakages.
fixId - Never assign the asset anything other than a GUID.