public class TestHandler implements Serializable {
private static final Logger logger = Logger.getLogger(TestHandler.class .getName());
/** * */ private static final long serialVersionUID = 3844698105980368981L;
private String name = null;
public TestHandler() { logger.info("Constructor initiated"); }
public void setName(String newName) { name = newName; }
public String getName() { return name; }
public boolean isRendered() { boolean rendered = name != null && !("".equals(name)); logger.info("Checking rendered state for name: <" + name + ">. State is: <" + rendered + ">"); return rendered; }
public String buttonClicked() { logger.info("Button was clicked"); return ""; } }
{!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"} {html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"} {head} {meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /} {title}This is a test of JSF on Google Apps{/title} {/head} {body} {ui:composition} {f:view}
{h1}Test of JSF and Facelets running on Google App Engine{/h1}
{h:form} {h:outputText value="What is your name? " /}
Ok, very good, but I wanted to see the code.
ReplyDeleteThe code is beyond simple :)
ReplyDeletepackage com.softwyer.gapp.jsf;
import java.io.Serializable;
import java.util.logging.Logger;
public class TestHandler implements Serializable {
private static final Logger logger = Logger.getLogger(TestHandler.class
.getName());
/**
*
*/
private static final long serialVersionUID = 3844698105980368981L;
private String name = null;
public TestHandler() {
logger.info("Constructor initiated");
}
public void setName(String newName) {
name = newName;
}
public String getName() {
return name;
}
public boolean isRendered() {
boolean rendered = name != null && !("".equals(name));
logger.info("Checking rendered state for name: <" + name
+ ">. State is: <" + rendered + ">");
return rendered;
}
public String buttonClicked() {
logger.info("Button was clicked");
return "";
}
}
=================== jsp ========
{?xml version="1.0" encoding="ISO-8859-1" ?}
{!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"}
{html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"}
{head}
{meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /}
{title}This is a test of JSF on Google Apps{/title}
{/head}
{body}
{ui:composition}
{f:view}
{h1}Test of JSF and Facelets running on Google App Engine{/h1}
{h:form}
{h:outputText value="What is your name? " /}
{h:inputText value="#{testHandler.name}" /}
{h:commandButton value="Click" action="#{testHandler.buttonClicked}" /}
{/h:form}
{p /}
{h:outputText value="Your name is: #{testHandler.name}"
rendered='#{testHandler.rendered}' /}
{/f:view}
{/ui:composition}
{/body}
{/html}