On Mon, Dec 7, 2009 at 2:23 PM, Alex Black <[email protected]> wrote:
> > How about starting with a Lift 1.1 project?
>
> I'll give it a try. I was mimicking how I tried to upgrade my 1.0
> project.
>
> > Did you update the version of Scala?
>
> Nope, it is a 2.7.3 in the pom.
>
> Just now I updated it to 2.7.7, re-ran, and saw the same behaviour.
>
> > What is the issue with the constructor being called repeatedly?
>
> In my test the constructor is getting called with every snippet method
> call from the same page.
>
> Given that you'd described only one snippet is used for all those
> calls, let me put the question back to you: why is the constructor
> being called 18 times when once would have sufficed?
>
If there is an actual issue, then identify it. Throwing questions back at
me doesn't really engender a lot of motivation for me to help.
>
> >
> >
> >
> > > and here is the output:
> >
> > > [INFO] Started Jetty Server
> > > [INFO] Starting scanner at interval of 5 seconds.
> > > Constructor
> > > Constructor
> > > INFO - Service request (GET) / took 393 Milliseconds
> > > INFO - Service request (GET) /classpath/jquery.js took 39 Milliseconds
> > > INFO - Service request (GET) /ajax_request/
> > > liftAjax.js;jsessionid=11x3vru6uimmg took 11 Milliseconds
> > > INFO - Service request (GET) /favicon.ico took 6 Milliseconds
> > > INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 11
> > > Milliseconds
> > > INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 1
> > > Milliseconds
> >
> > > Snippet code:
> >
> > > package com.liftcode.hello.snippet
> >
> > > class HelloWorld {
> > > println("Constructor")
> >
> > > def howdy = <span>Welcome to hello-lift at {new
> > > _root_.java.util.Date}</span>
> > > }
> >
> > > index.html:
> >
> > > <lift:surround with="default" at="content">
> > > <h2>Welcome to your project!</h2>
> > > <p><lift:helloWorld.howdy /></p>
> > > <p><lift:helloWorld.howdy /></p>
> > > </lift:surround>
> >
> > > Here is the pom.xml:
> >
> > > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
> > >www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
> > > maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">
> > > <modelVersion>4.0.0</modelVersion>
> > > <groupId>com.liftcode.hello</groupId>
> > > <artifactId>hello-lift</artifactId>
> > > <version>1.0-SNAPSHOT</version>
> > > <packaging>war</packaging>
> > > <name>hello-lift</name>
> > > <inceptionYear>2007</inceptionYear>
> > > <properties>
> > > <scala.version>2.7.3</scala.version>
> > > </properties>
> >
> > > <repositories>
> > > <repository>
> > > <id>scala-tools.org</id>
> > > <name>Scala-Tools Maven2 Repository</name>
> > > <url>http://scala-tools.org/repo-releases</url>
> > > </repository>
> > > </repositories>
> >
> > > <pluginRepositories>
> > > <pluginRepository>
> > > <id>scala-tools.org</id>
> > > <name>Scala-Tools Maven2 Repository</name>
> > > <url>http://scala-tools.org/repo-releases</url>
> > > </pluginRepository>
> > > </pluginRepositories>
> >
> > > <dependencies>
> > > <dependency>
> > > <groupId>org.scala-lang</groupId>
> > > <artifactId>scala-library</artifactId>
> > > <version>${scala.version}</version>
> > > </dependency>
> > > <dependency>
> > > <groupId>net.liftweb</groupId>
> > > <artifactId>lift-util</artifactId>
> > > <version>1.1-M6</version>
> > > </dependency>
> > > <dependency>
> > > <groupId>net.liftweb</groupId>
> > > <artifactId>lift-webkit</artifactId>
> > > <version>1.1-M6</version>
> > > </dependency>
> > > <dependency>
> > > <groupId>javax.servlet</groupId>
> > > <artifactId>servlet-api</artifactId>
> > > <version>2.5</version>
> > > <scope>provided</scope>
> > > </dependency>
> > > <dependency>
> > > <groupId>junit</groupId>
> > > <artifactId>junit</artifactId>
> > > <version>4.5</version>
> > > <scope>test</scope>
> > > </dependency>
> > > <dependency>
> > > <groupId>org.mortbay.jetty</groupId>
> > > <artifactId>jetty</artifactId>
> > > <version>[6.1.6,)</version>
> > > <scope>test</scope>
> > > </dependency>
> > > <!-- for LiftConsole -->
> > > <dependency>
> > > <groupId>org.scala-lang</groupId>
> > > <artifactId>scala-compiler</artifactId>
> > > <version>${scala.version}</version>
> > > <scope>test</scope>
> > > </dependency>
> > > </dependencies>
> >
> > > <build>
> > > <sourceDirectory>src/main/scala</sourceDirectory>
> > > <testSourceDirectory>src/test/scala</testSourceDirectory>
> > > <plugins>
> > > <plugin>
> > > <groupId>org.scala-tools</groupId>
> > > <artifactId>maven-scala-plugin</artifactId>
> > > <executions>
> > > <execution>
> > > <goals>
> > > <goal>compile</goal>
> > > <goal>testCompile</goal>
> > > </goals>
> > > </execution>
> > > </executions>
> > > <configuration>
> > > <scalaVersion>${scala.version}</scalaVersion>
> > > </configuration>
> > > </plugin>
> > > <plugin>
> > > <groupId>org.mortbay.jetty</groupId>
> > > <artifactId>maven-jetty-plugin</artifactId>
> > > <configuration>
> > > <contextPath>/</contextPath>
> > > <scanIntervalSeconds>5</scanIntervalSeconds>
> > > </configuration>
> > > </plugin>
> > > <plugin>
> > > <groupId>net.sf.alchim</groupId>
> > > <artifactId>yuicompressor-maven-plugin</artifactId>
> > > <executions>
> > > <execution>
> > > <goals>
> > > <goal>compress</goal>
> > > </goals>
> > > </execution>
> > > </executions>
> > > <configuration>
> > > <nosuffix>true</nosuffix>
> > > </configuration>
> > > </plugin>
> > > <plugin>
> > > <groupId>org.apache.maven.plugins</groupId>
> > > <artifactId>maven-eclipse-plugin</artifactId>
> > > <configuration>
> > > <downloadSources>true</downloadSources>
> > > <excludes>
> > > <exclude>org.scala-lang:scala-library</exclude>
> > > </excludes>
> > > <classpathContainers>
> >
> > > <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</
> > > classpathContainer>
> > > </classpathContainers>
> > > <projectnatures>
> > > <java.lang.String>ch.epfl.lamp.sdt.core.scalanature</
> > > java.lang.String>
> > > <java.lang.String>org.eclipse.jdt.core.javanature</
> > > java.lang.String>
> > > </projectnatures>
> > > <buildcommands>
> > > <java.lang.String>ch.epfl.lamp.sdt.core.scalabuilder</
> > > java.lang.String>
> > > </buildcommands>
> > > </configuration>
> > > </plugin>
> > > </plugins>
> > > </build>
> > > <reporting>
> > > <plugins>
> > > <plugin>
> > > <groupId>org.scala-tools</groupId>
> > > <artifactId>maven-scala-plugin</artifactId>
> > > <configuration>
> > > <scalaVersion>${scala.version}</scalaVersion>
> > > </configuration>
> > > </plugin>
> > > </plugins>
> > > </reporting>
> > > </project>
> >
> > > On Dec 7, 3:28 pm, David Pollak <[email protected]> wrote:
> > > > On Sun, Dec 6, 2009 at 5:44 AM, Alex Black <[email protected]>
> wrote:
> > > > > > We made this change for Lift 1.1. So, if you're using 1.1, the
> same
> > > > > > instance of a snippet should be used for a given HTTP request.
> >
> > > > > Hi David, I've just switch from Lift 1.0 to Lift 1.1-M6, do you
> think
> > > > > this change is in M6?
> >
> > > > Yes.
> >
> > > > Snippet:
> >
> > > > class HelloWorld {
> > > > lazy val date: Box[Date] = DependencyFactory.inject[Date] // inject
> the
> > > > date
> >
> > > > val random = randomString(20)
> >
> > > > def howdy(in: NodeSeq): NodeSeq =
> > > > Helpers.bind("b", in, "time" -> date.map(d => Text(d.toString)))
> >
> > > > def dog: NodeSeq = <b>String is {random}</b>
> >
> > > > def cat: NodeSeq = <b>From cat String is {random}</b>
> >
> > > > }
> >
> > > > View:
> >
> > > > <lift:surround with="default" at="content">
> > > > <h2>Welcome to your project!</h2>
> > > > <lift:helloWorld.howdy>
> > > > <span>Welcome to iscached at <b:time/></span>
> > > > </lift:helloWorld.howdy>
> > > > </p>
> >
> > > > <p> Dog sez <lift:HelloWorld.dog/></p>
> >
> > > > <p> Cat sez <lift:HelloWorld.cat/></p>
> >
> > > > </lift:surround>
> >
> > > > Browser:
> >
> > > > Welcome to your project!
> >
> > > > Welcome to iscached at Mon Dec 07 12:26:41 PST 2009
> >
> > > > Dog sez String is 4G2NRM4TBGCJBYNGFCUF
> >
> > > > Cat sez From cat String is 4G2NRM4TBGCJBYNGFCUF
> >
> > > > Works as advertised and has been in the code since at least M6.
> >
> > > > Thanks,
> >
> > > > David
> >
> > > > > It doesn't seem to be... I have many calls to my
> > > > > snippet for a particular page, and I put a println statement in the
> > > > > body of the snippet, and it gets called 18 times each request!
> >
> > > > > - Alex
> >
> > > > > > > I'd imagine lift could even generate a requestVar representing
> each
> > > > > > > snippet for the developers, allowing snippets in a given HTTP
> > > request
> > > > > > > to access each other easily.
> >
> > > > > > I don't think this is technically possible within the bounds of
> the
> > > type
> > > > > > system.
> >
> > > > > > > On Nov 20, 11:09 am, Ross Mellgren <[email protected]> wrote:
> > > > > > > > RequestVar is the standard way of doing this. For example
> >
> > > > > > > > object MySharedInformation {
> > > > > > > > object myData extends
> RequestVar[List[Thing]](loadThings)
> > > > > > > > // ^^^^^^^^^^^ ^^^^^^^^^^
> > > > > > > > // Type of thing to store How to
> > > initialize
> > > > > > > > variable first time it's accessed
> >
> > > > > > > > private def loadThings: List[Thing] = ...
> >
> > > > > > > > }
> >
> > > > > > > > class Snippet1 {
> > > > > > > > import MySharedInformation.myData
> > > > > > > > def render(ns: NodeSeq):
> >
> > ...
> >
> > read more ยป
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.