flex
- [FLEX] 비행기 모형 그리기 2009.05.27
- Matrix와 Transform 을 이용한 이미지 회전 2009.05.21
- 마우스 이벤트 (Click & doubleClick 동시에 사용하기) 2009.05.21
- 마우스 오른쪽 버튼 구글 프로젝트 2009.05.20
- [FLEX] 브라우져 풀스크린 모드 전환 2009.04.14
- [펌]Tree에 바인딩 된 XML의 특정 attribute로 아이템을 검색하고 폴더 확장하기 2009.04.06 1
- [FLEX] 현재 날짜 구하기 2009.04.03
- [FLEX3] 스프링프레임워크(SpringFramework)와 플렉스(BlazeDS)를 연동한 간단예제4 - 클라이언트단구현 2009.03.31 1
- [FLEX3] 스프링프레임워크(SpringFramework)와 플렉스(BlazeDS)를 연동한 간단예제3 - 서버단구현2 2009.03.31
- [FLEX3] 스프링프레임워크(SpringFramework)와 플렉스(BlazeDS)를 연동한 간단예제2 - 서버단구현1 2009.03.31
[FLEX] 비행기 모형 그리기
Matrix와 Transform 을 이용한 이미지 회전
마우스 이벤트 (Click & doubleClick 동시에 사용하기)
마우스 오른쪽 버튼 구글 프로젝트
[FLEX] 브라우져 풀스크린 모드 전환
at flash.display::Stage/set displayState()
[펌]Tree에 바인딩 된 XML의 특정 attribute로 아이템을 검색하고 폴더 확장하기
Tracy Spratt <tspratt@lariatinc.com> 의 아이디어입니다
<?xml version="1.0" encoding="utf-8"?>
<!-- Tree control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">
<mx:Script><![CDATA[
[Bindable]
public var _xmlData:XML;
public function initApp():void
{
_xmlData = <element eid="hello">
<element eid="world">
<element eid="123"/>
<element eid="graham"/>
<element eid="weldon">
<element eid="office">
<element eid="thing"/>
<element eid="boat"/>
<element eid="chair"/>
</element>
<element eid="person"/>
</element>
</element>
</element> ;
}//initapp
private function expandParents(xmlNode:XML):void
{
while (xmlNode.parent() != null) {
xmlNode = xmlNode.parent();
myTree.expandItem(xmlNode,true, false);
}
}//expandParents
private function findNodeById(sId:String):void
{
var xmllistDescendants:XMLList = _xmlData.descendants().(@eid == sId);
expandParents(xmllistDescendants[0]);
myTree.selectedItem = xmllistDescendants[0];
}//findNodeById
]]></mx:Script>
<mx:Panel title="Tree Control Example" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:HBox>
<mx:TextInput id="tiId" text="boat" />
<mx:Button label="Find" click="findNodeById(tiId.text)" />
</mx:HBox>
<mx:Tree id="myTree" width="50%" height="100%" labelField="@eid"
showRoot="false" dataProvider="{_xmlData}" />
</mx:Panel>
</mx:Application>
[FLEX] 현재 날짜 구하기
아래 코드를 좀 응용하면 될듯...
var sday:String = nowDate.date.toString();
var smonth:String = (nowDate.month+1).toString();
if(sday.length == 1){
sday = "0"+sday;
}
if(smonth.length == 1){
smonth = "0"+smonth
}
snowDate = nowDate.fullYear.toString()+"-"+ smonth +"-"+sday;
[FLEX3] 스프링프레임워크(SpringFramework)와 플렉스(BlazeDS)를 연동한 간단예제4 - 클라이언트단구현
<< service-config.xml파일을 수정 >>
<factory id="springfactory" class="flex.messaging.factory.SpringFactory" />
</factories>
<< remote-config.xml 파일을 수정 >>
<properties>
<factory>springfactory</factory>
<source>productManager</source>
</properties>
</destination>
자세히 보시면 factory는 위에 service-config.xml파일에 정의한 놈이고, source는 bean이름입니다.
즉 applicationContext.xml파일에 정의한 그 bean이름을 저기에 적어 놓으면 됩니다.
그러면 그 bean을 flex로 가져와서 쓸 수 있습니다.
아 그리고 프로젝트에서 이상하게 contextroot가 WebContent로 되어있는데 프로젝트이름으로 고쳐줍시다-_-;
context root를 프로젝트이름(SpringAndBlazeds)으로 바꿔줍시다.
<< FLEX 작성 >>
자 그러면 flex_src에 있는 SpringAndBlazeds.mxml을 수정해봅시다.
SpringAndBlazeds.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
applicationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.RemoteObject;
private function init():void {
var remoteObject:RemoteObject = new RemoteObject();
remoteObject.destination = "productmanager";
remoteObject.addEventListener(ResultEvent.RESULT, resultHandler);
remoteObject.addEventListener(FaultEvent.FAULT, faultHandler);
remoteObject.getProducts();
}
private function resultHandler(event:ResultEvent):void{
dg.dataProvider = event.result;
}
private function faultHandler(event:FaultEvent):void{
Alert.show("실패 메세지 : " + event.fault.message);
}
]]>
</mx:Script>
<mx:DataGrid id="dg" width="100%" height="100%" />
</mx:Application>
간단하게 Manager에 있는 getProducts를 호출해서 DataGrid에 넣는 코드입니다.
<< 실행 >>
이클립스 오른쪽아래에 server에다가 SpringAndBlazeds프로젝트를 추가합니다.
서버에 대고, 오른쪽버튼누르면, Add and Remove Project클릭해서 추가하면 됩니다.
서버를 가동합니다.
Run Flex Application을 실행해봅시다!
- Spring 프레임워크의 부족한 점 보안
- Flex에서 DataBase의 연동시 처리 방법 보안
- iBatis의 데이터 베이스 정의 및 사용방법 보안
[FLEX3] 스프링프레임워크(SpringFramework)와 플렉스(BlazeDS)를 연동한 간단예제3 - 서버단구현2
package springapp.service;
import java.util.List;
import springapp.domain.Product;
public interface ProductManager {
public List<Product> getProducts();
}
package springapp.service;
import java.util.List;
import springapp.dao.ProductDao;
import springapp.domain.Product;
public class ProductManagerImpl implements ProductManager {
private ProductDao productDao;
@Override
public List<Product> getProducts() {
return productDao.getProductList();
}
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
}
getProducts라는 함수는 Dao에서 getProductList를 호출하는 놈이네요.
요 아래에는 setter가 있네요. 이건 spring에서 DI를 하기위해 존재하는 setter입니다^^
서비스도 완성이 되었네요! 이제 설정파일을 작성해봅시다.
WEB-INF/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- Enable @Transactional support -->
<tx:annotation-driven />
<!-- Enable @AspectJ support -->
<aop:aspectj-autoproxy />
<aop:config>
<aop:advisor pointcut="execution(* *..ProductManager.*(..))"
advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="save*" />
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice>
<bean id="productManager"
class="springapp.service.ProductManagerImpl">
<property name="productDao" ref="productDao" />
</bean>
</beans>
Dao부분의 설정파일인 applicationContext-ibatis.xml파일을 봅시다.
WEB-INF/applicationContext-ibatis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="classpath:properties/jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
p:username="${jdbc.username}" p:password="${jdbc.password}" />
<!-- Transaction manager for iBATIS Daos -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- SqlMap setup for iBATIS Database Layer -->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation"
value="classpath:springapp/dao/SqlMapConfig.xml" />
</bean>
<!-- Add additional Dao definitions here -->
<bean id="productDao"
class="springapp.dao.ProductDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
</beans>
jdbc.properties파일은 properties라는 package를 만들고, jdbc.properties파일을 넣어버립시다.
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://DB주소
jdbc.username=DB아이디
jdbc.password=DB비밀번호
이 설정들의 bean들의 관계를 보고 싶다면-_-;
Spring Elements에서 오른쪽버튼 클릭하고 properties를 선택.
Bean Support를 선택, Add한 뒤 두개의 설정파일(applicationContext.xml, applicationContext-ibatis.xml)선택.
Config set에서 New하고 Name에 applicationContext라고 하고, 두개다 체크 오케이~
그럼 이제 스프링 설정파일에서 에러를 찾아낼 수 있어요!
bean들의 관계를 그래프로도 볼 수 있네요!
Config set에 추가한 applicationContext에다가 마우스오른쪽버튼을 클릭하면 open graph로 볼 수 있어요!
이제 클라이언트 구현으로....다음 시간에-_-;
[FLEX3] 스프링프레임워크(SpringFramework)와 플렉스(BlazeDS)를 연동한 간단예제2 - 서버단구현1
`id` int(11) NOT NULL,
설정파일은 applicationContext.xml과 applicationContext-ibatis.xml 두개를 사용할껍니다.
Java Resources:src에다가 New를 하고 class를 선택합니다.
package는 springapp.domain이라고 하구요.
Name은 Product라고 하고 Finish
package springapp.domain;
public class Product {
private int id;
private String description;
private Double price;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
}
Java Resource:src에 New해서 interface를 추가합시다.
package에다가 springapp.dao라고 써놓고,
Name에다가 ProductDao라고 씁시다.
package springapp.dao;
import java.util.List;
import springapp.domain.Product;
public interface ProductDao {
public List<Product> getProductList();
}
저 Dao인터페이스를 구현해봅시다!!!
package springapp.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import springapp.domain.Product;
public class ProductDaoImpl extends SqlMapClientDaoSupport implements
ProductDao {
protected final Log logger = LogFactory.getLog(getClass());
@SuppressWarnings("unchecked")
@Override
public List<Product> getProductList() {
logger.info("Getting products!");
return getSqlMapClientTemplate().queryForList("getProductList");
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<typeAlias alias="Product" type="springapp.domain.Product"/>
<sqlMap resource="springapp/dao/MySQLProduct.xml" />
</sqlMapConfig>
alias지정해주고, resource는 src/springapp/dao/MySQLProduct.xml파일입니다.
MySQLProduct.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Product">
<resultMap id="ProductMap" class="Product">
<result property="id" column="id" />
<result property="description" column="description" />
<result property="price" column="price" />
</resultMap>
<select id="getProductList" resultMap="ProductMap">
select id, description, price from products
</select>
</sqlMap>
getProductList라는 것은 products테이블에서 내용을 select하는 것이네요.
Dao가 완성되었네요! 너무 길어지니 다음이시간에 ...