[flexcoders] Re: Passing Value Object to CFC as an argument?

2007-02-01 Thread boy_trike
--- In flexcoders@yahoogroups.com, "Douglas Knudsen" <[EMAIL PROTECTED]> wrote:
>
> you need a EmployeeVO CFC with matching properties and the full array of
> mutators and accessors.  

Actually, you don't.  If you want to save a lot of typing and do it the KISS 
(keep it simple, 
stupid) way, you can pass your VO with NO reference to a cfc and coldfusion 
will be happy 
to accept it as a STRUCT.  Of course, you do have to know (and spell correctly) 
the field 
names.  Following is a code snippet.

 VO 
notice that there is NO remote line, just a simple object
package vo
{
[Bindable]
public class WebOrder
{   
public var recID: int;
public var nameNumber   : int;
public var contact  : String;
public var userID   : int;
public var dateEntered  : Date;
public var deliveryFrom : Date;
public var deliveryThru : Date;
public var item : int;
public var customerQty  : int;
public var customerUM   : String;
public var tallyQty : int;
public var price: Number;
public var per  : int;
public var comments : String;
public var cancelReason : String;
public var cancelOption : String;
public var PONumber : String;
public var wholeUnits   : int;
public var customTallyFlag  : int;
public var pickUp   : int;
public var status   : String;

public function WebOrder()  {
}
}
}

--- FLEX CODE ---

cfcOrderInquiry.webOrderInsert( {obj: model.webOrder} );


--- CF CODE -
 



  Insert Into WebOrder  (NameNumber, UserID, Contact, 
DeliveryFrom, 
DeliveryThru,
Item, CustomerQty, CustomerUM, Price, per) 
values ( #obj.nameNumber#, #obj.userID#,  '#obj.contact#', 
#obj.deliveryFrom#, 
#obj.deliveryThru#, 
#obj.item#, #obj.customerQty#,'#obj.customerUM#', #obj.price#, 
#obj.per#)

select @@IDENTITY as webOrderRecID




 

It is this simple.

Bruce




[flexcoders] Re: Passing Value Object to CFC as an argument?

2007-01-31 Thread malik_robinson

Hi,

That helps quite a bit.

Two questions arise.

1.  Can you explain the dynamic class usuage and why one might use that?

2.  I always see VO's with an empty function declared after the
properties  (see below) , why is this?

public function securityVO()
  {
  }

Thanks for your help

-M
--- In flexcoders@yahoogroups.com, "Douglas Knudsen"
<[EMAIL PROTECTED]> wrote:
>
> you need a EmployeeVO CFC with matching properties and the full array
of
> mutators and accessors. Further you need to add the metadata to your
AS VO
> so Flex knows how to tie it in to your CFC. THen service.saveEmployee(
> employeeVO ) can work on the EmployeeVO CFC bamm! Below is a example
>
> package com.mycom.myapp.vo
> {
>
> [RemoteClass(alias="myapp.model.security.security")]
>
> [Bindable]
> public dynamic class securityVO implements ValueObject
> {
>
> public var emplid:String = "";
> public var name:String = "";
> public var secgroupid:Number = 0;
> public var secgroup:String = "";
> public var isactive:Boolean = false;
>
>
> public function securityVO()
> {
> }
>
> }
> }
>
>
> 
> 
> 
> 
> 
> 
> 
>
> 
> //Initialize the CFC with the default properties values.
> variables.emplid = "";
> variables.name = '';
> variables.secgroupid = 0;
> variables.secgroup = '';
> variables.isactive = false;
> 
>
> 
> 
> 
>
>
>  returntype="any">
> 
> 
>
>  returntype="void">
> 
> 
> 
>
>  returntype="any">
> 
> 
>
>  returntype="void">
> 
> 
> 
>
>  returntype="any">
> 
> 
>
>  returntype="void">
> 
> 
> 
> 
> 
> 
> 
>
>  returntype="boolean">
> 
> 
>
>  returntype="void">
> 
> 
> 
> 
> 
> 
> 
>
>  returntype="any">
> 
> 
>
>  returntype="void">
> 
> 
> 
>
> 
>
> The above is how the CF-Extension wizards create things.
>
> DK
> On 1/31/07, malik_robinson [EMAIL PROTECTED] wrote:
> >
> > Hi,
> >
> > I am confused on how pass in arguments to the CFC when I am sending
a
> > ValueObject in from Flex. I have this code.
> >
> > *public* *function* saveEmployee( employeeVO : EmployeeVO ): *void*
{
> >
> > *var* call:AsyncToken = service.saveEmployee( employeeVO );
> >
> > call.addResponder( responder );
> >
> > }
> >
> > The parameter employeeVO in the above function contains all the data
the
> > user typed in on my form. I want to pass this data to my CFC as an
> > argument.
> >
> > From there I *think* I can do the rest.
> >
> > How do I do this?
> >
> > -Malik
> >
> >
>
>
>
> --
> Douglas Knudsen
> http://www.cubicleman.com
> this is my signature, like it?
>