RE: [flexcoders] StringValidator and required fields

2005-08-10 Thread Alistair McLeod










Hi Blake,



You cant have bindings in
Validators, so the compiler is parsing required={usePurchaseOrder.selected}
to either true or false  and it looks like true from what youre
saying. Itd be good if the compiler helper a bit more here, but it doesnt.



We dont think Cairngorm store has
any bindings on validators  please let us know if it does.



For what youre wanting to do, youre
best bet will be to drop into ActionScript and change your validators at
runtime.



Cheers,



Ali





--

Alistair
 McLeod

Development Director

iteration::two



[EMAIL PROTECTED]

Office: +44 (0)131 338 6108



This e-mail and any associated attachments
transmitted with it may contain confidential information and must not be copied,
or disclosed, or used by anyone other than the intended recipient(s). If you
are not the intended recipient(s) please destroy this e-mail, and any copies of
it, immediately.



Please also note that while software
systems have been used to try to ensure that this e-mail has been swept for
viruses, iteration::two do not accept responsibility for any damage or loss
caused in respect of any viruses transmitted by the e-mail. Please ensure your
own checks are carried out before any attachments are opened.













From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Blake Kadatz
Sent: 09 August 2005 22:26
To: flexcoders@yahoogroups.com
Subject: [flexcoders]
StringValidator and required fields





I've been playing around with validators
and seem to have encountered a behavior which is unexpected. Here's a
sample of what I'm doing:



---

[snip...]



mx:Model
id=paymentInformationModel
 usepurchaseorder{ usePurchaseOrder.selected
}/usepurchaseorder
 purchaseordernumber{ purchaseOrderNumber.text
}/purchaseordernumber
/mx:Model



mx:StringValidator
field=paymentInformationModel.purchaseordernumber
required={usePurchaseOrder.selected} /

mx:Form width=100%
mx:FormHeading label=Purchase Order
/







 mx:FormItem
label=Pay using purchase order required=false
 mx:CheckBox
id=usePurchaseOrder label=/
 /mx:FormItem

 mx:FormItem label=Purchase Order Number
required={usePurchaseOrder.selected}


 enabled={usePurchaseOrder.selected}
mx:TextInput
id=purchaseOrderNumber width=100
maxChars=50 /
 /mx:FormItem
/mx:Form









[...snip]





--











(This is modified from the Cairngorm store
and uses the Validator.isStructureValid call in the same way.)











This displays correctly -- the user clicks
the checkbox to use a purchase order and the field becomes enabled and displays
an asterisk beside it. But if the user leaves it unchecked, then upon
submitting the form it still thinks the field is required. The telling
part is that if I change the StringValidator to have required=false
instead of required={usePurchaseOrder.selected} then it correctly
sees it as not required.











What am I missing here?











Thanks,











Blake











--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Computer software testing
  
  
Macromedia flex
  
  
Development
  
  


Software developer
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  











RE: [flexcoders] StringValidator and required fields

2005-08-10 Thread Blake Kadatz
 You can't have bindings in Validators, so the compiler is parsing
 required={usePurchaseOrder.selected} to either true or false - and
it looks
 like true from what you're saying. It'd be good if the compiler helper
a bit
 more here, but it doesn't.

I was hoping that wouldn't be the case.  Is there some architectural
reason why bindings don't apply to Validators?  I couldn't find anything
in the docs about why this would be the case.

 We don't think Cairngorm store has any bindings on validators - please
let us
 know if it does.

No, it doesn't.  I modified the store and apparently tried to be too
clever.

 For what you're wanting to do, you're best bet will be to drop into
ActionScript
 and change your validators at runtime.

Okay, will do that -- thanks for the information.

Cheers,

Blake


 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12h71oldl/M=362329.6886308.7839368.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123700056/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
Fair play? Video games influencing politics. Click and talk back!/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




RE: [flexcoders] StringValidator and required fields

2005-08-10 Thread Blake Kadatz
 For what you're wanting to do, you're best bet will be to drop into
 ActionScript and change your validators at runtime.

I've been working on this trying to figure out the best way to handle
it.  The compiler nicely informs me that id tags aren't supported on
validators, so it appears setting the required property on a validator
isn't directly possible.

The only way I can determine is that I should be calling the validator's
disable method, eg:

http://livedocs.macromedia.com/flex/15/asdocs_en/mx/validators/Validator
.html#disable

So I modified the PaymentInformation.mxml to have:

  mx:Model id=paymentInformationModel
usepurchaseorder{ usePurchaseOrder.selected }/usepurchaseorder
purchaseordernumber{ purchaseOrderNumber.text
}/purchaseordernumber
... etc ...
  /mx:Model

  mx:StringValidator
field=paymentInformationModel.purchaseordernumber
  requiredFieldError=Please enter your purchase order number. /

Then, in CheckoutViewHelper.as, I modified it to have:

  public function validateCheckOutForm() : Boolean
  {
var validStructures : Number = 0;
var structuresToBeValidated : Number = 2;

// manually set required for non-binding validators
if (view.paymentInformationComp.usePurchaseOrder.selected)
{
  mx.validators.Validator.enable(view,
 paymentInformationModel.purchaseordernumber);
}
else
{
  mx.validators.Validator.disable(view,
 paymentInformationModel.purchaseordernumber);
}

... etc ...
  }

However, this doesn't seem to work.  I've tried passing in
purchaseOrderNumber and other variations to the disable and enable
methods, but it still shows up as being a required field.

I hope I'm missing something obvious -- my next step would be to use a
generic Validator with a custom validate() function, which all seems
rather messy.

Thanks,

Blake


 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12h65lnr9/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123702726/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] StringValidator and required fields

2005-08-10 Thread Battershall, Jeff
Blake,

I would take the click event from your checkbox and map that to an event 
handler which enables/disables your StringValidator.

function setValidator(event)
{
if (event.target.selected == true)
{

mx.validators.Validator.enable(view,paymentInformationModel.purchaseordernumber);
}
else
...
}
Jeff

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Blake 
Kadatz
Sent: Wednesday, August 10, 2005 1:39 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] StringValidator and required fields


 For what you're wanting to do, you're best bet will be to drop into 
 ActionScript and change your validators at runtime.

I've been working on this trying to figure out the best way to handle it.  The 
compiler nicely informs me that id tags aren't supported on validators, so it 
appears setting the required property on a validator isn't directly possible.

The only way I can determine is that I should be calling the validator's 
disable method, eg:

http://livedocs.macromedia.com/flex/15/asdocs_en/mx/validators/Validator
.html#disable

So I modified the PaymentInformation.mxml to have:

  mx:Model id=paymentInformationModel
usepurchaseorder{ usePurchaseOrder.selected }/usepurchaseorder
purchaseordernumber{ purchaseOrderNumber.text }/purchaseordernumber
... etc ...
  /mx:Model

  mx:StringValidator field=paymentInformationModel.purchaseordernumber
  requiredFieldError=Please enter your purchase order number. /

Then, in CheckoutViewHelper.as, I modified it to have:

  public function validateCheckOutForm() : Boolean
  {
var validStructures : Number = 0;
var structuresToBeValidated : Number = 2;

// manually set required for non-binding validators
if (view.paymentInformationComp.usePurchaseOrder.selected)
{
  mx.validators.Validator.enable(view,
 paymentInformationModel.purchaseordernumber);
}
else
{
  mx.validators.Validator.disable(view,
 paymentInformationModel.purchaseordernumber);
}

... etc ...
  }

However, this doesn't seem to work.  I've tried passing in 
purchaseOrderNumber and other variations to the disable and enable methods, 
but it still shows up as being a required field.

I hope I'm missing something obvious -- my next step would be to use a generic 
Validator with a custom validate() function, which all seems rather messy.

Thanks,

Blake



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 






 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12hhhrjj4/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123703053/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




RE: [flexcoders] StringValidator and required fields

2005-08-10 Thread Blake Kadatz
 I would take the click event from your checkbox and map that to an
event handler
 which enables/disables your StringValidator.

Thank you, that seems to have done the trick!  Now to submit a feature
request for validator bindings... :)

Blake


 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12h392bgq/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123704489/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/