2013-08-21 1 views
-1

스피에서 : http://tourdeflex.adobe.com/flex4samples/GroupsAndContainers/TabbedNavigator/sample1.html무슨 실수를 내 코드이 같은 출력을 재현하는 tyring

다음은 내 자신의 코드는 자신을 개발하지만, 스피 필요하지 않음지고 출력이 .. 무엇이 잘못되었는지 잘 모릅니다. pls는 친절하게 내 코드를 실행하고 나에게 정확한 솔루션을 제공합니다

TabBarDemo.mxml을

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*"> 

    <fx:Script> 
     <![CDATA[ 
      import events.EmployeeEvent; 

      import mx.collections.ArrayCollection; 
      import mx.controls.Alert; 

      import vo.EmployeeVO; 

      public var empVO: EmployeeVO; 

      [Bindable] 
      public var empList: ArrayCollection; 

      protected function contactInfo_employeeEventHandler(event:EmployeeEvent):void 
      { 
       empVO = event.employeeInfoVO; 

       if(empVO != null) 
        empList.addItem(empVO); 
       else 
        Alert.show("Object is null"); 

      } 
     ]]> 
    </fx:Script> 

    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 


    <s:VGroup> 

     <s:TabBar dataProvider="{contact}" /> 

     <mx:ViewStack id="contact" 
         resizeToContent="true"> 

      <components:ContactInfo id="contactInfo" 
            label="Employee Info" 
            employeeEvent="contactInfo_employeeEventHandler(event)"/> 

      <components:ContactList label="Employee List" 
            empList="{empList}"/> 


     </mx:ViewStack> 

    </s:VGroup> 

</s:Application> 

ContactInfo.mxml

<?xml version="1.0" encoding="utf-8"?> 
<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"> 


    <fx:Metadata> 

     [Event(name="employeeEvent", type="events.EmployeeEvent")] 

    </fx:Metadata> 

    <fx:Script> 
     <![CDATA[ 
      import events.EmployeeEvent; 

      import vo.EmployeeVO; 


      protected function submit_clickHandler(event:MouseEvent):void 
      { 
       var empVO: EmployeeVO = new EmployeeVO(); 

       empVO.empName = empName.text; 
       empVO.address = address.text; 
       empVO.state = state.text; 
       empVO.city = city.text; 
       empVO.zip = zip.text; 

       var empEvent: EmployeeEvent = new EmployeeEvent("employeeEvent", empVO); 
       dispatchEvent(empEvent); 

      } 
     ]]> 
    </fx:Script> 

    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <s:Form> 

     <s:FormItem label="Name"> 
      <s:TextInput id="empName"/> 
     </s:FormItem> 

     <s:FormItem label="Address"> 
      <s:TextInput id="address" /> 
     </s:FormItem> 

     <s:FormItem label="City"> 
      <s:TextInput id="city" /> 
     </s:FormItem> 

     <s:FormItem label="State"> 
      <s:TextInput id="state" /> 
     </s:FormItem> 

     <s:FormItem label="Zip"> 
      <s:TextInput id="zip" /> 
     </s:FormItem> 

     <s:FormItem> 
      <s:Button id="submit" 
         label="Submit" 
         click="submit_clickHandler(event)"/> 
     </s:FormItem> 

    </s:Form> 

</s:NavigatorContent> 

ContactList.mxml

<?xml version="1.0" encoding="utf-8"?> 
<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" 
     > 

    <fx:Script> 
     <![CDATA[ 
      import mx.collections.ArrayCollection; 

      import spark.components.List; 

      import vo.EmployeeVO; 

      [Bindable] 
      public var empList: ArrayCollection; 



     ]]> 
    </fx:Script> 

    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <s:DataGrid dataProvider="{empList}"/> 

</s:NavigatorContent> 

EmployeeEvent.as

package events 
{ 
    import flash.events.Event; 

    import vo.EmployeeVO; 

    public class EmployeeEvent extends Event 
    { 

     public var employeeInfoVO: EmployeeVO; 

     public function EmployeeEvent(type: String, employeeInfoVO: EmployeeVO) 
     { 
      super(type); 
      this.employeeInfoVO = employeeInfoVO; 
     } 
    } 
} 

EmployeeVO.as

package vo 
{ 
    public class EmployeeVO 
    { 
     public function EmployeeVO() 
     { 
     } 

     public var empName: String; 
     public var address: String; 
     public var state: String; 
     public var city: String; 
     public var zip: String; 


    } 
} 

응답을 기다리는 중!

+1

오류 출력이 있습니까? FYI : swf를 마우스 오른쪽 버튼으로 클릭하고 "소스보기"를 선택하여 해당 TourDeFlex 예제의 소스를 볼 수 있습니다. 다음은 직접 링크입니다 : http://tourdeflex.adobe.com/flex4samples/GroupsAndContainers/TabbedNavigator/srcview/index.html – dvdgsng

+0

iam은 필수 출력을 얻지 못하고 있습니다. iam은이 예제의 소스 코드를 사용하지 않고 있습니다. 구성 요소를 사용하여 노력하고 있습니다 .. –

답변

1

문제는 사용자가 empList:ArrayCollection을 초기화하지 않았기 때문입니다. 그냥 바로 링크를 클릭하면

+0

고마워요! 지금,하지만 점점 더 하나의 쿼리 : 지금 내 두 번째 구성 요소에 어떤 행을 클릭하면 그 행 세부 shud 구성 요소의 형태로 표시됩니다 .. 할 수있는 가능한? 간단히 말해서 : 그것은 양방향 비뚤림이 될 것입니다. 그래서 pls는 어떻습니까? –

+1

사실은 다른 질문이므로 해결하기 위해 새로운 질문을 만들어야합니다. 우선, 여기에 바인딩 할 필요가 없습니다. 목록 및 업데이트 양식에서 변경된 항목 만 표시 할 수 있습니다. – catholicon

+0

여기 왜 대답하지 않으시 겠어요? 새로운 질문에 전체 코드를 다시 붙여 넣기를 원하는 이유는 무엇입니까? 제가 필요한 것은 양방향 바인딩입니다. U가 나에게 말해 준다면 나는 기쁠 것입니다! ... 고맙습니다! –

1

(난 당신이 점점되지 않습니다 필요한 출력이 연락처 목록에 연락처 정보 제출 직원 정보의 목록을 표시해야한다는 것입니다 있으리라 믿고있어)

[Bindable] 
public var empList: ArrayCollection = new ArrayCollection(); 

사용 tht 게시했습니다, 당신은 원본을 볼 수 있습니다.

Here

관련 문제