You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nick56789 <nt...@gmail.com> on 2008/12/23 05:09:36 UTC

Tapestry 5, Netbeans 6.5

We recently got a very basic Tapestry 5 app working with NetBeans 6.5 on
Windows.  We did not use Hibernate, Spring, or Maven (Maven's repository is
blocked by work proxy server).  Just thought I would post what we did in
case it was useful to anyone else.

A lot of this came from the official tutorial
(http://tapestry.apache.org/tapestry5/tutorial1/) and the Tapestry for
Non-Believers tutorial (http://www.infoq.com/articles/tapestry5-intro). Here
is how we got it working:

1. Download and install the latest JDK 1.6 (We used 1.6.0_07)
2. Download Tapestry 5.0.18 (currently the latest release) and unzip
somewhere convenient.
3. Download NetBeans 6.5 (We used build 200811100001), the "Java" version
that includes Tomcat.
4. Install NetBeans; you may to have to specify that you want to install
Tomcat.
5. After the install, open NetBeans and go to File -> New Project
6. Choose Java Web -> Web Application
7. Name the project something like "Test" and keep the default options (Set
as main project), then hit Next.
8. If you don't have a Server listed, hit "Add" and follow the steps to set
up a Tomcat server.
9. Leave frameworks empty and hit "Finish".

Now you should have a basic Web project that will compile and run in Tomcat. 
To convert this to a Tapestry application:

10. Under Web Pages, right-click and delete the index.jsp.
11. Open WEB-INF/web.xml (or "Configuration Files -> Web.xml") and go to the
XML view.
12. Change the XML between the <webapp> tags so the doc looks like this:

<web-app ...(leave this)>
   <display-name>Test Application</display-name>
   <context-param>
       <param-name>tapestry.app-package</param-name>
       <param-value>test</param-value>
   </context-param>
   <filter>
       <filter-name>app</filter-name>
       <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
   </filter>
   <filter-mapping>
       <filter-name>app</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>
</web-app>

13. The only two you need to change are the <display-name> and the
<param-value> for tapestry.app-package; the latter is the name of your
package and is where Tapestry will look for your Java classes.
14. Right-click "Web Pages" and do New -> Other, then choose Other -> Empty
File
15. Name the file "Start.tml" and hit Finish.
16. Copy the following HTML into the new file:

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
   <head>
       <title>Start Page</title>
   </head>
   <body>
       <h1>Start Page (Start.tml/Start.java)</h1>
       <p> The current time is: ${currentTime}. </p>
       <p>
           [<t:pagelink t:page="Start">Refresh</t:pagelink>]
       </p>
   </body>
</html>

17. Save the Start.tml file, then right-click "Source Packages" and go to
New -> Java Class
18. Name the class "Start" (.java) and put it in the package "test.pages",
substituting "test" for the package you specified in the web.xml.  Then hit
Finish.
19. Open the Start.java file and make it look like this, with your package
instead of "test":

package test.pages;
import java.util.Date;

public class Start {
   public Date getCurrentTime()
       {
               return new Date();
       }
}

20. This next step may not be 100% necessary (or even done correctly) but is
was the only way to we were able to see the logs:  Right-click "Source
Packages" and go to New -> Empty File.  Name the file "log4j.properties" and
hit Finish.
21. Copy the following into the new file, then save it, again changing the
last line to match your package:

log4j.rootCategory=WARN, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=[%p] %c{1} %m%n
log4j.category.org.apache.tapestry5.TapestryFilter=info
log4j.category.org.apache.tapestry=info
log4j.category.tapestry=info
log4j.category.test=info

22. Finally, add the tapestry jars to your project by right-clicking
"Libraries" and clicking "Add JAR/Folder".
23. Browse to the unzipped tapestry folder (like C:\tapestry-bin-5.0.18\lib)
and select all the jars EXCEPT tapestry-hibernate-5.0.18.jar.  If you
include this, Tapestry seems to fail trying to set up a default Hibernate
configuration, which we did not use.
24. Now you should be able to Run -> Build Main Project and Run -> Run Main
Project.

It's probably best to use fresh installs of everything, as I had problems
running multiple Tapestry test applications on Tomcat.  Be sure to stop the
Tomcat server before you do a manual Clean (there should be a stop button in
the Tomcat window, or you can do it from the Services tab).  You can
continue adding pages the same way you added Start.java and Start.tml.

I know this was pretty low level and there are probably advanced
Tapestry/Java EE programmers yelling that I did it all wrong, but it would
have been helpful to us in evaluating Tapestry last week.  Hopefully it will
be helpful to someone else.


-- 
View this message in context: http://www.nabble.com/Tapestry-5%2C-Netbeans-6.5-tp21139299p21139299.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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