2010. 8. 6. 18:19 flex
[13-D4][notice] MXML main 화면(noticeFx.mxml)
[13-D4][notice] MXML main 화면(noticeFx.mxml)
[01] MXML main 화면
- 1024 X 768: width: 900, height:500
- 1280 X 1024: width: 1000, height:700
>>>>> notice/src/noticeFx.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="startApp()"
layout="absolute"
width="800" height="500">
<mx:Style>
global{
fontSize : 12;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.ListEvent
import flex.notice.*;
private var mgr:NoticeFxMgr;
private var dataGridItem:Object;
// XML데이터를 받을시 한글깨짐 방지
//System.useCodePage = true;
// 어플리케이션이 로딩되면 메모목록을 불러온다.
private function startApp():void {
// dg: DataGrid
this.mgr = new NoticeFxMgr(dg);
this.mgr.list();
}
// 글 목록 출력
private function evtList():void {
this.mgr.list();
}
// 글 추가
private function evtSave():void{
if (subject.text == ""){
Alert.show("제목을 입력해주세요.");
return;
}
if (content.text == ""){
Alert.show("내용을 입력해주세요.");
return;
}
if (passwd.text == ""){
Alert.show("패스워드를 입력해주세요.");
return;
}
// 전송할 데이터의 VO객체
var dto:NoticeFxDTO = getDTO();
this.mgr.save(dto);
}
// 글 수정
public function evtUpdate():void{
if (subject.text == ""){
Alert.show("제목을 입력해주세요.");
return;
}
if (content.text == ""){
Alert.show("내용을 입력해주세요.");
return;
}
if (passwd.text == ""){
Alert.show("패스워드를 입력해주세요.");
return;
}
// 전송할 데이터의 VO객체
var dto:NoticeFxDTO = getDTO();
mgr.update(dto);
}
// 글 삭제
public function evtRemove():void{
if (passwd.text == ""){
Alert.show("패스워드를 입력해주세요.");
return;
}
// 전송할 데이터의 VO객체
var dto:NoticeFxDTO = getDTO();
mgr.remove(dto);
}
// DataGrid컨트롤의 아이템 클릭 이벤트
private function evtItemClick(event:ListEvent):void{
dataGridItem = new Object();
// 클릭시 생성된 객체 할당
dataGridItem = event.target.selectedItem;
// 제목
subject.text = dataGridItem.subject;
// 메모리상에 저장된 내용을 TextArea에 출력
content.text = dataGridItem.content;
// 패스워드는 출력 안함.
passwd.text = "";
// passwd.text = dataGridItem.passwd;
}
private function getDTO():NoticeFxDTO{
// 전송할 데이터의 VO객체
var dto:NoticeFxDTO = new NoticeFxDTO();
if (dataGridItem != null){
dto.idx = dataGridItem.idx; // 기존에 글을 클릭한 경우
}else{
dto.idx = 0; // 글 쓰기 일경우
}
dto.subject = subject.text;
dto.content = content.text;
dto.passwd = passwd.text;
passwd.text = "";
return dto;
}
public function evtClear():void{
// 입력 상자 삭제
subject.text = "";
content.text = "";
passwd.text = "";
subject.setFocus();
}
]]>
</mx:Script>
<mx:Panel title="공지사항" layout="horizontal" paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10" left="10" top="10" right="10" bottom="10">
<mx:VBox width="100%" height="100%">
<mx:DataGrid id="dg" width="360" height="100%"
itemClick="evtItemClick(event);">
<mx:columns>
<!-- XML 태그 명시, 컬럼과 일치하지
않는 XML태그는 메모리상에 저장됨 -->
<mx:DataGridColumn dataField="idx" headerText="번호" width="45"/>
<mx:DataGridColumn dataField="subject" headerText="제목" width="145"/>
<mx:DataGridColumn dataField="regdate" headerText="등록일" width="80"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="새로고침" width="100%" click="evtList()" />
</mx:VBox>
<mx:VRule height="100%" />
<mx:VBox width="100%" height="100%">
<mx:VBox width="100%">
<mx:Label text="제목" />
<mx:TextInput id="subject" width="100%" />
</mx:VBox>
<mx:VBox width="100%" height="100%">
<mx:Label text="내용" />
<mx:TextArea id="content" width="100%" height="100%"/>
<mx:Label text="패스워드" />
<mx:TextInput id="passwd" width="100%" displayAsPassword="true"/>
</mx:VBox>
<mx:HBox width="100%">
<mx:Button label="새로 입력" width="100%" click="evtClear();" />
<mx:Button label="저장" width="100%" click="evtSave();" />
<mx:Button label="수정 저장" width="100%" click="evtUpdate();" />
<mx:Button label="삭제" width="100%" click="evtRemove();" />
</mx:HBox>
</mx:VBox>
</mx:Panel>
</mx:Application>
'flex' 카테고리의 다른 글
[15-D4] HTML 페이지상에 Flex Application 의 배포 (0) | 2010.08.06 |
---|---|
[14-D4][notice][JSP] 글 추가, 글 수정, 글 삭제 (0) | 2010.08.06 |
[12-D4][notice][JSP] Eclipse 프로젝트 설정, 글 목록(list.jsp) (0) | 2010.08.06 |
[11-D3][notice] DTO, Manager의 제작 및 사용 (0) | 2010.08.06 |
[10-D3][notice] DB, ActionScript Class, getter, setter function (0) | 2010.08.06 |