하얀늑대 :: 하얀늑대의 일상
bloghome Tags |  Guestbook | 
  Tags
아이콘 사이트관리 인터넷 IT 입냄새 메일보내기 파워포인트 IBM 해킹 벤치마킹 AB형 web2.0 비스타 sql 2005 server paypal 웹페이지 회사가기시러쏭 우울증 롱혼 이슈
banner
하얀늑대 ::
하얀늑대의 일상

Google
내블로그에서 검색
 하얀늑대는?
 Category
allow  모두보기 (257)
spacespace Today Story's (10)
spacespace 핫이슈 (19)
spacespace 디카질 (4)
spacespace Javascript (15)
spacespace 2000 server (9)
spacespace 2003 server (3)
spacespace 리눅스 (3)
spacespace UCC (6)
spacespace 컴퓨터 Tip (15)
spacespace IT news (52)
spacespace 웹 접근성 (3)
 Tags
위키 GetRows MSXML2.ServerXMLHTTP web2.0 사랑 SK커뮤니케이션즈 웹페이지 쇼핑몰 인클루드 Flex utf-8 신조어 닷넷 블루레이 컨텐츠 Stress 포털 윈도우 USB 웹2.0
  Calendar
<< 2010 July >>
S M T W T F S
27 28 29 30 1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
 New Post
line 프로그램에서 전화걸기
line HTML 요소 이름의 풀어쓴
line UI 개발자를 위한 북마크
line 대한민국 웹 표준 사이트
line MS-SQL 설치가이드
 New Comment
line클럽4242 : 10/03/17
reply우리사이 좋은사이!! 클
linesusanna : 08/11/07
replyhey,find <a href=http:
line하얀늑대 : 08/05/22
reply위에 페이지는 한페이지 내
line아아아 : 08/04/26
reply개새끼는너야
line아이니 : 08/02/23
reply《$mode 값이 mailsend 일
 New Tracbacks
lineWeb 1.0 과 Web 2.0
line06/11/18
line괴물 - 2006. 7. 28.
line06/07/29
 New Archive
2010 July (1)
2010 April (3)
2009 August (1)
2009 April (2)
2009 March (1)
...more
  Link Site
올블로그
KOON
태터툴즈
엑스파이더
심프로그
디지털예보
thesimplog.com
feed rss
 Visitor Statistics
Total  :  238411
Today :  51
Yesterday :  150


 Google



blog bar tagsbar guest loginbarlogoutbarX-inbar
line Flex asp 연동
Today Story's | 09/04/13 | 하얀늑대

Flex Builder 2 and Classic ASP 3.0 Example

By a1plusok

Where I’m coming from

Isn’t it interesting how some people get totally caught up in specific technologies and then spend the rest of their lives (or at least a few good years) developing in nothing else than that specific set of “programming languages + IDE + APIs + server architecture + delivery platform”?

If you’ve been around the block a couple of times, and if you’ve been developing software and web applications for some time, you probably know of some people like that. Not that there is anything wrong with that, of course, but it is interesting how scary (or exciting) the world looks outside of that comfort zone.

Not that I consider myself a pigeon-holed designer & developer, but I started working with Flex Builder 2 this summer, and I must admit that it was a little scary at first. New concepts (for me), new programming syntax . . . but an awesomely exciting end result. Well, if you’re here because you want to figure out how to make Flex Builder 2 work with Classic ASP 3.0, then I don’t have to tell you anymore about the cool-ness factor of Flex applications.

Let’s get on with the show

For the purpose of this very basic and very simple example, you need to have Flex Builder installed on your computer. You should be at least somewhat familiar with programming concepts and with XML.

And, of course, you will have access to a web server running IIS and a database (SQL Server, for example) to which you can already connect using ASP and ADODB. So, it’s almost a given that you need to be able to write SQL queries.

1. Set up a Flex project. This step is fairly rudimentary and has been covered in detail elsewhere, so I won’t repeat how to set up a Flex project. (Check the Flex Help if you really don’t have a clue.)

2. For extra points, use something other than the default location, and create a new directory on your web server. Call it what you want, but the shorter the name the easier to type in the URL later.

3. When you’re in a front of the Source view of your MXML file, enter the following:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” xmlns=”*”
layout=”absolute” creationComplete=”userRequest.send()”>

<mx:HTTPService
id=”userRequest”
url=”http://www.myurl.com/flex/request.asp”
useProxy=”false”
method=”POST”>
<mx:request xmlns=”">
<username>{username.text}
</username></mx:request>
</mx:HTTPService>

<mx:Form x=”22″ y=”10″ width=”493″>
<mx:HBox><mx:Label text=”Username”/><mx:TextInput id=”username”/></mx:HBox>
<mx:Button label=”Submit” click=”userRequest.send()”/>
</mx:Form>

<mx:DataGrid id=”dgUserRequest” x=”22″ y=”140″
dataProvider=”{userRequest.lastResult.users.user}”
width=”493″ height=”125″>
<mx:columns>
<mx:DataGridColumn headerText=”User ID” dataField=”userid”/>
<mx:DataGridColumn headerText=”User Name” dataField=”username”/>
<mx:DataGridColumn headerText=”E-Mail” dataField=”emailaddress”/>
</mx:columns>
</mx:DataGrid>

<mx:TextInput x=”355″ y=”273″ id=”selectedemailaddress”
text=”{dgUserRequest.selectedItem.emailaddress}”/>

</mx:Application>
(Feel free to copy and paste all of this from here into your Source view.)

4. Modify the following: “http://www.myurl.com/flex/request.asp”

Obviously, you want to point to your URL (whether that’s on a live server or on your development box) and to the corresponding directory which contains the ASP file that will provide the bulk of the information to you.

At this point, you have the basic Flex application ready. However, don’t try to run it yet, since we haven’t prepared the ASP file yet.

5. Create an ASP file and place it in the directory that you specified in step 4:

<%@ LANGUAGE=”VBSCRIPT” %>
<%
REM Prevent page caching
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = “no-cache”
Set Conn = Server.CreateObject(”ADODB.Connection”)
Conn.ConnectionTimeout = 15
Conn.CommandTimeout = 30
Conn_Catalog = “MyDatabase”
Conn_UserID = “web_user”
Conn_Password = “whatever1t15″
Conn_DataSource = “555.55.555.55″

conn.Open “Provider=sqloledb; Data Source=” & Conn_DataSource & “; Initial Catalog=” & Conn_Catalog & “; User Id=” & Conn_UserID & “; Password=” & Conn_Password

If Request.Form(”username”) <> “” Then
dim accessSql
accessSql = “SELECT TOP 55 UserID, UserName, Email FROM Users WITH (NOLOCK) WHERE (Email IS NOT NULL) AND (Email <> ”) AND (Email LIKE ‘%.com’) AND Username LIKE ‘%” & Request.Form(”username”) & “%’ ORDER BY UserID”
Set Comm = Server.CreateObject(”ADODB.Command”)
Comm.ActiveConnection = Conn
Comm.CommandTimeout = 600
Comm.CommandText = accessSql
Comm.CommandType = 1
Set accessSqlRS = Comm.Execute

dim mxmlStr, mxmLoop
mxmlStr = “”

‘PUT THE QUERY RESULTS INTO AN ARRAY
If Not accessSqlRS.EOF AND NOT accessSqlRS.BOF Then
accessSqlArray = accessSqlRS.GetRows()
accessSqlRS.Close
End If

‘LOOP THROUGH THE ARRAY AND FORM THE XML STRING
If IsArray(accessSqlArray) Then
mxmlStr = “<users>”

For mxmLoop = 0 to UBound(accessSqlArray, 2)
mxmlStr = mxmlStr & “<user><userid>” & accessSqlArray(0,mxmLoop) & “</userid><username>” & accessSqlArray(1,mxmLoop) & “</username><emailaddress>” & accessSqlArray(2,mxmLoop) & “</emailaddress></user>” & vbcrlf
Next

mxmlStr = mxmlStr & “</users>”
End If

If delUserSql <> “” Then
delUserSql = NULL
End If

If IsArray(accessSqlArray) Then
Erase accessSqlArray
Set accessSqlArray = Nothing
End If

‘POST THE XML STRING
Response.Write(mxmlStr)
End If

%>
(Feel free to copy and paste all of this from here into your ASP page.)

6. You need to modify the database connection string and the SQL query. Obviously, my example database and its tables might not work for you. Feel free to adjust your query so that it points to the correct database (by SQL Server IP and database name) and to the correct fields in teh correct table.

After you have built the Flex project, you can try and run it. If you already have all of your Flex files on the web server,and if the file reference from Flex to the ASP page is in place, everything should work.

Ideally, you place all the required files on your web server and access the Flex app by entering its URL (probably pointing to the bin directory).

What does it do?

If everything works, the Flex app won’t do anything at first. That’s how it’s supposed to work. In my case (using my database), I enter user name or the first few letters of a user name into the text input field, click Submit and then retrieve a number of user records that fulfill the LIKE requirement.

With the grid control filled in, I can now click on any record row and display the e-mail address in a separate input field underneath.

Not bad for a basic proof-of-concept, eh? (And if you have something much, much cooler than this, using either ASP or SQL Server, please let me know about it.)

Possible Errors

If you get any weird errors, try to Google them, but the most common issues are:

a) Some kind of #1096 error in the Flex app. This has to do with read-only attributes on some of the files in your Flex project directory. The easiest work-around is to disable the History option for the HTML wrapper (Properties -> Flex Compiler).

b) No data, nothing happens when you click the button or some weird-looking error box when the Flex app is done loading. This is the result of referencing the ASP file incorrectly. As far as I can tell, you need an absolute URL for the mx:HTTPService to work. And you might want to double-check and make sure that the location to which you are pointing actually contains the ASP file.

Next Steps

As mentioned throughout this brief and very simple tutorial, all of this is very rudimentary indeed. But you’ve got to start somewhere, right?

If you’re looking for an enterprise-strength solution, you should probably write a web service (using ASP.NET and C#, for example) and include some security measures to protect your data.

In this example, it is presumed that you handle user authentication before the Flex app gets accessed. If you’re dealing with sensitive data, make sure you do not allow unauthorized access to the ASP file that gets accessed by the Flex app. (In no way will I be held responsible for any deployed or publicly accessible solution that has been built as a result of this proof-of-concept tutorial and through which sensitive or otherwise protected data have been compromised.)

Call for Examples

As you probably know by now, the web is full of Flex Builder examples written for ColdFusion, PHP and Java developers. As a matter of fact, the basis for this tutorial was a PHP tutorial from Adobe Labs. However, there are astonishingly few (if any) hints as to how to use Flex Builder with Classic ASP 3.0.

There has been quite a bit of talk about a Flex solution for ASP.NET, but that doesn’t always fit the need. So, I would hope that this proof-of-concept tutorial helps someone else out there accomplish great and wonderful things.

On the other hand, if you have any “Flex with ASP” examples or functional code snippets, please let me know. I’d love to learn from you.

PS: I apologize for the “funky formatting” of the code snippets in this post. The basic WordPress account doesn’t give you much wiggle room in terms of CSS formatting. Feel free to take out extra spaces and extraneous line breaks to format the code to your liking.


태그: Flex
bullet관련글0 | 댓글1
클럽4242 2010/03/17 답글 삭제
우리사이 좋은사이!!

클럽4242 놀러오세요~꼭이요

신나는 친구만들기
가슴설레는 애인만들기
연애상담할수있는 술친구

아~~~우리 무슨사이할까?

http://www.club4242.com
Name :   Pass :  URL :
비밀글로 등록  submit
이전/ 1 2 3 4 5 [6] 7 8 9 10 / 다음 top