Steve,

There's no magic about all this. The original binding was probably affecting 
the change. It's perfectly possible to have a loose binding.

Have you tried your code since removing the offending line?

Paul
  ----- Original Message ----- 
  From: justSteve 
  To: [email protected] 
  Sent: Sunday, February 24, 2008 9:54 PM
  Subject: Re: [flexcoders] Where did the value go?


  Thankx much. I see a bit better where I was misunderstanding Alex, now. As to 
binding....the intent here is loose coupling of the MVC sort. This view object 
sends a notification that an item was selected. It's supposed to store that 
selectItem to the type defined by the Value Object. I've fallen victim to the 
assumption that if it's typed right for the DG it'll be typed correctly for the 
form too. They are based on the same VO.

  What really puzzles me is the lack of explicit error when the typecast fails.

  Again...i'm in much appreciation for the feedback. It's clear that it's time 
to pick up unit testing.



  On 2/24/08, Paul Andrews <[EMAIL PROTECTED]> wrote:

    Steve, I think Alex has already pointed out the reason you have a problem:

    selectedItem="{selectedSlide}"

    Remove this line. If you have a panel that contains fields that should be 
bound to the selected item, you need to have the binding there, not as above.

    Paul
      ----- Original Message ----- 
      From: justSteve 
      To: [email protected] 
      Sent: Saturday, February 23, 2008 3:20 PM
      Subject: Re: [flexcoders] Where did the value go?


      Bummer....I was _sure the problem would be the fact that the datagrid 
didn't have columns for all Slide's properties.

      But I've since added all Slide's properties to the DG and still the 
argument comes in null. I tried Beau's suggestion to remove the cast from the 
call and type the argument to Object. Still valid at the call and null at the 
argument.

      Then I changed event.target.selectedItem as Slide to 
event.target.selectedItem.myIdentity and the functions signature to accept a 
Number. That works...the correct number is being passed to the handler. I'm 
tempted to just code a query  to the collection that can build a full Slide 
from the ID property but figure that if I'm not lazy enough to do it right what 
hope is there for my becoming a good programmer.

      So clearly the typecasting is misfiring but why no compile _or runtime 
error? I find that if I intentionally misspell the dataField property of one of 
the DG's columns, that column comes up blank but others render as expected and, 
again, no error reported.


      On 2/22/08, justSteve <[EMAIL PROTECTED]> wrote: 

        @ Alex...i'm unclear about your questions... I have a datagrid that 
displays a table of all rows of the given collection. When I select a row that 
record is supposed to display in a separate - a detail - form. 

        The problem probably traces to the fact that the datagrid doesn't 
define columns for each of the fields specified in the type 'Slide' - the 
datagrid has columns representing only a subset of the properties in 'Slide'. 
But if so, shouldn't that cause either a runtime (if not a compile-time) error?

        thx to all
        --steve... 




        On 2/22/08, Alex Harui <[EMAIL PROTECTED]> wrote: 

          The DG's selectedItem is bound to selectedSlide so anything that 
tickles it will reset the selectedItem.  Maybe you want to call 
selectSlide(selectedSlide), or maybe you just want to init selectedItem once 
and not have it bound permanently?




----------------------------------------------------------------------

          From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf 
Of justSteve
          Sent: Friday, February 22, 2008 2:06 PM
          To: flexcoders
          Subject: [flexcoders] Where did the value go?



          I have a datagrid that should send it's selectItem value to a detail 
form.

          <mx:DataGrid
          selectedItem="{selectedSlide}"
          change="selectSlide(event.target.selectedItem as Slide)"
          dataProvider="{slides}" >

          Placing a breakpoint on the change property and observing the
          event.target.selectedItem value shows the event is carrying the
          expected info. But when execution reaches the handler:

          public var selectedSlide:Slide;
          private function selectSlide(pSlide:Slide):void
          {
          selectedSlide = pSlide ; // pSlide is now null.
          dispatchEvent(new Event(SELECT, true));
          }

          the param is null. How do I go about figuring out where my error is? I
          reason that if there's something wrong with how I've typed 'Slide' I'd
          get a compile-time error.

          many thankx
          --steve...









   

Reply via email to