I’m not sure if the initial value of text is undefined or if it’s empty-string.  I don’t get why it successfully sent the empty-string over instead of sending nothing, maybe you’re just getting lucky right now J

 


From: hecubus_eh [mailto:[EMAIL PROTECTED]
Sent: Saturday, April 02, 2005 8:09 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Help with binding null data to web service param eters.

 


Thanks for the reply, explanation and workaround, Matt!

Can you explain why this logic:

txtCompany.text == undefined ? 'foo':txtCompany.text

didn't return 'foo' in the VO or the WebService request parameter, and performed the
equivalent of initializing txtCompany.txt?

Thanks again,

Rick...


--- In flexcoders@yahoogroups.com, Matt Chotin <[EMAIL PROTECTED]> wrote:
> Sorry for not responding sooner...
>
> Binding has some "smarts" that are getting in your way here.  Essentially
> the first time binding looks at a value it checks to see if the value is
> null, undefined, or empty string.  If it is any of those it will not copy
> the value over.  Until the value has turned into something that is not one
> of those "non-values" it binding does not execute.  The reason we do this is
> that many times there is to allow the destination of a binding to have an
> initial value that does not disappear until a real replacement is ready.
> For example, if we did not do this logic and you used binding from a web
> service to populate an image source, rather than the image not loading until
> the web service had returned, you'd see the "image not found" icon.
>
> So, this is why you have no values.  And it's also why the test where you
> try to return '' isn't working, the '' is empty-string which means "don't
> copy."  So what I'd do as a quick workaround is go ahead and simply write an
> initialize handler that sets all of the web service request properties to
> null.
>
> <mx:Script>
>   function initWS()
>   {
>     wsCustomer.methCustMatches.request.txtZip = null;
>     wsCustomer.methCustMatches.request.txtLastLastName = null;
>     wsCustomer.methCustMatches.request.txtFirstName = null;
>     ...
>   }
> </mx:Script>
>
> Sorry for the confusion,
>
> Matt
>
> -----Original Message-----
> From: hecubus_eh
> To: flexcoders@yahoogroups.com
> Sent: 3/30/2005 9:12 PM
> Subject: [flexcoders] Help with binding null data to web service parameters.
>
>
> I'm building a simple Flex form that has several TextInput fields
> that a person can use as search criteria.  They are basically
> optional fields.
>
> The text from the TextInput fields are bound directly to a set of web
> service request parameters that is sending to a CFC-based WSDL.
>
> The problem I'm running into is that if any of the TextInput fields
> are not filled in by the user, no value is being passed to the web
> service request
> parameters that the TextInput.text values are bound to.  The result
> is that they are
> treated as null by the WebService and the parameters are not sent in
> the SOAP request.
> Since all parameters are required in a WSDL, the web service is
> resulting in a SOAP
> message that some parameters are not being passed into the request.
>
> Here is a code snippet:
>
> --------------------------------
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml
> <http://www.macromedia.com/2003/mxml> "
> xmlns:r="view.*" pageTitle="Customer Search" initialize="">
>       <mx:WebService
> wsdl="http://localhost/Customer.cfc?wsdl
> <http://localhost/Customer.cfc?wsdl> " id="wsCustomer">
>             <mx:operation name="methCustMatches">
>                   <mx:request>
>                         <txtZip>{txtZip.text}</txtZip>
>                         <txtLast>{txtLastName.text}</txtLast>
>                         <txtFirst>{txtFirstName.text}</txtFirst>
>                         <txtPhone>{txtPhone.text}</txtPhone>
>                         <txtCompany>{txtCompany.text}</txtCompany>

> <CustomerNumber>{CustomerNumber.text}</CustomerNumber>
>                   </mx:request>
>             </mx:operation>
>       </mx:WebService>
>       <mx:Script>
>       <![CDATA[
>             function sendReq(event) {
>                   wsCustomer.methCustMatches.send();
>             }
>       ]]>
>       </mx:Script>
>
>       <mx:TextInput text="" id="numShipTo" width="100" maxChars="9"
> restrict="0-9" />
>       <mx:TextInput text="" id="txtPhone" width="100" enabled="false"
> maxChars="12" /
> >
>       <mx:TextInput text="" enabled="false" id="txtCompany" width="100"
> />
>       <mx:TextInput text="" id="txtZip" width="50" maxChars="11" />
>       <mx:TextInput text="" id="txtFirstName" width="75" />
> <mx:TextInput
> id="txtLastName" width="75" />
>       <mx:Button id="submitForm" label="Go" textAlign="center"
> click="sendReq(event);"/
> >
> </mx:Application>
>
> --------------------------------
>
> That's the first problem...is there a way to explicitly send the
> parameters that have no
> value, basically as if I did not bind any variables to the request
> parameters?  If I send the
> request with no value inside the parameters (e.g.
> <txtPhone></txtPhone>), the
> parameters are sent in the SOAP request with no values, which is fine
> since the WSDL
> doesn't yell at me for not providing all the parameters. 
>
> While debugging this problem, instead of binding the TextInput text
> value directly to the
> WebService request parameters, I bound the values to a data model and
> used the model as
> a value object.  I then bound the properties of the object to the
> corresponding parameters
> in the WebService request.  The same error resulted, BUT...I tried to
> use the following code
> to determine what the value of the TextInput.text was for each
> TextInput:
>
> --------------------------------
>
> <mx:Model id="modelCS">
> ...
>       <txtCompany>{txtCompany.text == undefined ? 'foo':
> txtCompany.text}</txtCompany>
> ...
> </mx:Model>
>
> --------------------------------
>
> I expected the value of modelCS.txtCompany to be 'foo', but I ended
> up with modelCS.txtCompany resulting in '', which incidentally the
> WebService
> recognized as an empty string.  Strangely enough, if I used ''
> instead of 'foo' in my simple
> logic test inside the data model, it resulted in modelCS.txtCompany
> to be undefined.
>
> Does anyone have any idea what's happening here???  I'll be more than
> happy to go into any more detail if necessary.
>
> Thanks,
>
> Rick...
>
>
>
>
>
> Yahoo! Groups Sponsor     
>
> ADVERTISEMENT

> <http://us.ard.yahoo.com/SIG=129n214b4/M=298184.6018725.7038619.3001176/
> D=groups/S=1705007207:HM/EXP=1112332390/A=2593423/R=0/SIG=11el9gslf/
*htt
> p://www.netflix.com/Default?mqso=60190075> click here
     

> <http://us.adserver.yahoo.com/l?M=298184.6018725.7038619.3001176/D=group
> s/S=:HM/A=2593423/rand=366044414>      
>
>   _____ 
>
> Yahoo! Groups Links
>
>
> *      To visit your group on the web, go to:
> http://groups.yahoo.com/group/flexcoders/
> <http://groups.yahoo.com/group/flexcoders/>
>  
>
> *      To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>  
>
> *      Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .






Yahoo! Groups Links

Reply via email to