You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by fa...@linagora.com on 2007/07/29 16:40:27 UTC

[T5][Info] Scala Programming langage works with T5

Hello guys,

I just began to play with Scala ( http://www.scala-lang.org/index.html ),
a functional, full-OO programming language that run on top of the JVM.

And you know what ? I attempt to build a page in Scala for Tapestry 5, and
it works ! Scala allows to import Java class and use annotation, so I
think that we could use Tapestry 5 full power with Scala.

So, for whose of you who are tired of Java as a language and want to
explore new paradigm, but think that OCaml, Haskell or Erlang are just a
little to cryptic, go for Scala on Tapestry 5 :)

Here an example of the page built (I'm really new to Scala, so the code
may be totally not idiomatic), but it's just to show that it works :

-----
Start.html
8<---------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <head>
        <title>Scala w/ Tapestry 5</title>
    </head>
    <body>
        <h1>Test Scala Start Page</h1>
	<p>The value is incremented in setup: ${mysetupvalue}</p>
        <p>The current time is: ${currentTime}. </p>

        <p>[<t:pagelink t:page="start">refresh</t:pagelink>]</p>

        <t:form>
        <t:textfield value="myvalue" /><t:submit />
        </t:form>
    </body>
</html>
8<---------------------------------------------------------------------
Start.scala
8<---------------------------------------------------------------------
package example.pages;

import java.util.Date
import org.apache.tapestry.annotations._

class Start {
    def getCurrentTime : String = {
        return new Date().toString();
    }

    @SetupRender
    def setup() {
        mysetupvalue += 1;
    }

    @Persist
    private var mysetupvalue : Int = _;

    def getMysetupvalue() : Int = {
        return mysetupvalue;
    }

    @Persist
    private var myvalue : String = _;

    def getMyvalue() : String = {
        return myvalue;
    }

    def setMyvalue(s : String) {
        myvalue = s;
    }
}
8<---------------------------------------------------------------------


Have a nice play !

--
Francois Armand
Etudes & Développements J2EE
LINAGORA SA - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
InterLDAP - http://interldap.org
FederID - http://www.federid.org/
Open Source identities management and federation



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org