CROQUET MEETS JAVA OR .NET

The next step in our "Bookstore project" would be to create the logic for the buyer to send his data to the server of the bookstore.

But, before to do this, we need to remember how a modern network application works today.

There are the concept of 3 tiers, like you can say in the figure.

We are presenting, in the figure, 2 professional sceneries: the first uses Java and the other the .NET architecture.

We will work, at this course,in a very simplified way (the 3th scenery) using Squeak-Croquet at the first tier - using its Smaltalk language. In the 2nd tier we will use ASP.Net with JavaScript, a very usual choice.

To do our exercices, if your server is not Windows (having the .NET framework and ACCESS database) it' s easy to find a cheap web-hoster having this configuration. Some are free, but can have some restrictions and bad performance. By ethics reasons I can't recomend any service provider. Sorry.

At our first exercice about 3 tiers applications using Squeak-Croquet we will create a project where: the user types a word in a TextField, clicks a Button and the string goes to the server and returns like an echo to other TextField.

We will have this objects:

The script glued to the object Click (a rectangle having a text - event: MouseDown) will be:

| page parsedPage thebody clean |
Msg2  show.
page:=HTTPSocket httpGet:'http://www.dmu.com/croquet/echo.aspx?thename=', Shout1 getCharacters.
parsedPage := HtmlParser parse: page. 
thebody := parsedPage body.
clean := thebody   contents at:1 .  
clean := clean  asString .
clean := clean copyReplaceAll: '[' with:''. 
clean := clean copyReplaceAll: ']' with:''. 
Echo1 setCharacters: clean.

CODE COMMENTS

VERY VERY IMPORTANT: The objects change their names during the codification when something changes on them, adding new numbers of versions. This is not usual in other languages...IF YOU ARE HAVING PROBLEMS, VERIFY ALL THE NAMES, AND THEIR DESIGNATIONS IN THE CODE!

The ASPX program is coded in JavaScript and is uploaded to that path in the server:

<script language="JavaScript" runat="server">
function Page_Load(sender:Object, e:EventArgs):void{
 var thename=this.Request.Params["thename"];
 Response.Write("echo for = " + thename); 
}
</script>

CODE COMMENTS

Glued to the TextField Shout we have a simple script triggered when the user "MouseStillDown" - clicks and remains with the mouse-button down - this field. It will do this trying to type a new message.

Msg2  hide

You can test this project!

Its address is: http://www.dmu.com/Tealand/echo1.006.pr

And re-read the lesson about how to create a 3D window for a project. Use for "extent": 1050 x 1050.

Look some images of the project working:

WARNING. If you don't have a powerfull computer and a fast communication line it's possible that you will not have a very responsible application. We are doing our tests at a: Notebook DELL Latitude D600 - Intel Pentium M755 2.0 GHZ - Memory: 512 MB - VideoCard ATI Radeon 9000 32MB DDR 4xAGP - Resolution 1400x1050 - Communication: ADSL 256 kbps (Download: 45 kBps, Upload: 14 kBps) - Windows XP Professional SP1

WHERE IS THE PEER-TO-PEER?: Peer-to-peer application is that where the main function doesn't depend of a unique machine. In P2P we don't have a central main server. PCs talk to PCs. Using Squeak-Croquet, the 1st tier communication between spaces/users is a peer-to-peer application :




PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE

DISCLAIMER: This material can be translated for any language, and reproduced total or partially by anybody using any type of media. But, please, don't put your name like author. And let me know if it was useful (americo@dmu.com).The use of any code, 3D model or technique published is free and doesn't need to have any reference about this source.The author is not responsible for any damage that the material can cause to your professional or sexual life.