MentaTutorials

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/HelloMenta/trunk/src/main/java/org/mentawai/AppManager.java
New file
0,0 → 1,16
package org.mentawai;
 
import org.mentawai.action.HelloAction;
import org.mentawai.core.ApplicationManager;
 
public class AppManager extends ApplicationManager {
 
@Override
public void loadActions() {
action("/Hello", HelloAction.class, "hi")
.on(SUCCESS, fwd("/jsp/hello.jsp"));
}
}
/HelloMenta/trunk/src/main/java/org/mentawai/action/HelloAction.java
New file
0,0 → 1,15
package org.mentawai.action;
 
import org.mentawai.core.BaseAction;
 
public class HelloAction extends BaseAction {
public String hi() {
String msg = input.getString("msg");
if (isEmpty(msg)) {
msg = "Why you did not type anything?";
}
output.setValue("msg", msg);
return SUCCESS;
}
}
/HelloMenta/trunk/src/main/webapp/WEB-INF/web.xml
New file
0,0 → 1,30
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<!-- Override default start page -->
<welcome-file-list>
<welcome-file>/jsp/index.jsp</welcome-file>
</welcome-file-list>
 
<!-- The Mentawai controller -->
<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>org.mentawai.core.Controller</servlet-class>
<init-param>
<param-name>applicationManager</param-name>
<param-value>org.mentawai.AppManager</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
 
<!-- You must choose an extension to indicate a mentawai action -->
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>*.mtw</url-pattern>
</servlet-mapping>
 
</web-app>
/HelloMenta/trunk/src/main/webapp/jsp/index.jsp
New file
0,0 → 1,10
<%@taglib prefix="mtw" uri="http://www.mentaframework.org/tags-mtw/"%>
<html>
<body>
<mtw:form action="Hello.hi.mtw" method="post">
Type something: <mtw:input type="text" name="msg" size="30" maxlength="30" />
<input type="submit" value="Go!" />
</mtw:form>
</body>
</html>
/HelloMenta/trunk/src/main/webapp/jsp/hello.jsp
New file
0,0 → 1,7
<%@taglib prefix="mtw" uri="http://www.mentaframework.org/tags-mtw/"%>
<html>
<body>
<mtw:out value="msg" />
</body>
</html>
/HelloMenta/trunk/pom.xml
New file
0,0 → 1,138
<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.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mentawai</groupId>
<artifactId>HelloMenta</artifactId>
<packaging>war</packaging>
<version>0.9.0-SNAPSHOT</version>
<name>Mentawai Hello World</name>
 
<dependencies>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.soliveirajr</groupId>
<artifactId>mentawai</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
 
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.1.0.v20100505</version>
<configuration>
<webApp>${basedir}/target/${project.artifactId}.war</webApp>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
</webAppConfig>
<reload>manual</reload>
<connectors>
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8080</port>
</connector>
</connectors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath>WEB-INF/sources</targetPath>
</resource>
</webResources>
<failOnMissingWebXml>true</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>HelloMenta</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
</configuration>
</plugin>
</plugins>
</pluginManagement>
 
</build>
<profiles>
<profile>
<id>endorsed</id>
<activation>
<property>
<name>sun.boot.class.path</name>
</property>
</activation>
<build>
<plugins>
 
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<!-- javaee6 contains upgrades of APIs contained within the JDK itself.
As such these need to be placed on the bootclasspath, rather than classpath
of the compiler. If you don't make use of these new updated API, you can
delete the profile. On non-SUN jdk, you will need to create a similar profile
for your jdk, with the similar property as sun.boot.class.path in Sun's JDK. -->
<compilerArguments>
<bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>