SOLVED:

Thanks everyone for the input. @Bob; that last comment helped. The
biggest help was this thread:
http://groups.google.com/group/transfer-dev/browse_thread/thread/7b55d3bcf66985ec/6ae6d3681b9d0164?lnk=gst

SOLUTION:
Here is the solution to having an empty string for a date field in
Transfer instead of Now()

** Transfer Config **

<object name="PressRelease"
decorator="decorators.PressReleaseDecorator">
        <id name="pressReleaseId" column="press_release_id" type="numeric"></
id>
        <property name="heading" type="string"></property>
        <property name="releaseDate" type="date" nullable="true"
nullvalue="01/01/1000"></property>
</object>

Key points:
1) Add the decorator attribute to your object tag and point it to your
decorator (you'll need to write a decorator CFC - see next step for
instructions).
2) On the property fields of type="date" (where you want them to be
empty string instead of Now()) add these attributes: nullable="true"
nullvalue="01/01/1000" (use another date if you expect 01/01/1000 to
be used :))

** Decorator CFC Code **
<cfcomponent extends="transfer.com.TransferDecorator" output="false">
        <cffunction name="configure" access="public" returntype="void"
output="false">
                <cfset setReleaseDateNull() />
        </cffunction>
        <cffunction name="setReleaseDate" output="false" returntype="void">
        <cfargument name="releaseDate" type="any" required="true">
        <cfif Len(arguments.releaseDate) EQ 0>
            <cfset setReleaseDateNull() />
        <cfelseif isDate(arguments.releaseDate)>
            <cfset getTransferObject().setReleaseDate
(arguments.releaseDate) />
        </cfif>
    </cffunction>
    <cffunction name="getReleaseDate" access="public" output="false"
returntype="any">
        <cfif getReleaseDateIsNull()>
            <cfreturn "" />
        <cfelse>
            <cfreturn getTransferObject().getReleaseDate() />
        </cfif>
    </cffunction>
</cfcomponent>

Key points:
1) extends="transfer.com.TransferDecorator"
2) Note that you have one decorator per Transfer object so if you have
more than 1 property in the object where this is required then
duplicate the relevant bits of code for each property.
3) Call the set{PropertyName}Null() for each property in the configure
method.
4) Add the getter and setter code for each property as per example.
These will override the Transfer object/beans getters setters but as
you can see if it detects a valid date it just uses the base getter /
setter.

All done.

Mark: perhaps there is a way of building this into Transfer (when you
have time :)) so that people don't have to write decorators for every
date field that they want to be "" instead of Now().

P.S. Transfer is great but as always there is a learning curve - you
can't make it too easy for us :)

Cheers
Matthew

On Mar 24, 10:58 am, Matt Quackenbush <[email protected]> wrote:
> To expand a little bit on set{PropertyName}Null() when the property is a
> date, Transfer sets the value to the oldest date that CF will support: {ts
> '0100-01-01 00:00:00'}.  Why this isn't done by default, I'm not really
> sure.  It sure would make hellamore sense.  :-)
--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to