Galera,
Sou novato no desenvolvimento de jsf.
Estou tentando fazer uma pagina simples de jsf + facelets e esta danço o seguinte erro:
Alguém sabe me dizer o que é isso??
Web.xml:
javax.faces.DEFAULT_SUFFIX .xhtml facelets.DEVELOPMENT true com.sun.faces.validateXml true com.sun.faces.verifyObjects true Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet *.jsffaces-config.xml:
<?xml version="1.0"?> pt_BR com.sun.facelets.FaceletViewHandler<managed-bean>
<managed-bean-name>numberBean</managed-bean-name>
<managed-bean-class>tutorial.NumberBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>min</property-name>
<value>1</value>
</managed-property>
<managed-property>
<property-name>max</property-name>
<value>10</value>
</managed-property>
</managed-bean>
<!-- going from guess.xhtml to response.xhtml -->
guess.xhtml:
This text above will not be displayed.
<ui:composition template="/template.xhtml">
This text will not be displayed.
<ui:define name=“title”>
I’m thinking of a number from #{numberBean.min} to #{numberBean.max}. Can you guess it?
</ui:define>
This text will also not be displayed.
<ui:define name=“body”>
<h:form id=“helloForm”>
<h:inputText type=“text” id=“userNo” value="#{numberBean.guess}" validator="#{numberBean.validate}"/>
<h:commandButton type=“submit” id=“submit” action=“success” value=“Submit” />
<h:message showSummary=“true” showDetail=“false” style=“color: red; font-weight: bold;” id=“errors1” for=“userNo”/>
</h:form>
</ui:define>
This text will not be displayed.
</ui:composition>
This text below will also not be displayed.
response.xhtml:
<ui:composition template="/template.xhtml">
<ui:define name=“title”>
#{numberBean.message}
</ui:define>
<ui:define name=“body”>
</ui:define>
</ui:composition>
template.xhtml:
Facelets: Number Guess TutorialDefault Title
Default Body
NumberBean:
package tutorial;
import java.io.Serializable;
import java.util.Random;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
public class NumberBean implements Serializable {
protected final static Random rand = new Random();
protected int min;
protected int max;
protected int guess;
protected int actual;
// Default Constructor
public NumberBean() {
this.min = 1;
this.max = 10;
}
// called by JSF to validate user input
public void validate(FacesContext context, UIComponent component, Object value)
throws ValidatorException {
// coerce the value to an int
try {
int param = Integer.parseInt(value.toString());
// validate param
if (param > this.max || param < this.min) {
FacesMessage msg = new FacesMessage("Guess must be between "+this.min+" and "+this.max);
throw new ValidatorException(msg);
}
} catch (NumberFormatException e) {
FacesMessage msg = new FacesMessage("Must be a number");
throw new ValidatorException(msg);
}
}
// lazy generate our actual value
public synchronized int getActual() {
if (this.actual == 0) {
this.actual = rand.nextInt(this.max-this.min);
this.actual += this.min;
}
return this.actual;
}
// our message for the response
public String getMessage() {
if (this.guess == this.getActual()) {
return “Sweet, you got it right!”;
} else if (this.guess < this.getActual()) {
return “Sorry, try something higher”;
} else {
return “Too bad, go lower”;
}
}
// other bean properties
public int getMin() { return this.min; }
public int getMax() { return this.max; }
public int getGuess() { return this.guess; }
public void setMin(int min) { this.min = min; }
public void setMax(int max) { this.max = max; }
public void setGuess(int guess) { this.guess = guess; }
}
libs usadas:
cglib-2.1.1.jar
common-annotations.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.1.jar
commons-digester-1.6.jar
commons-el-1.0.jar
commons-fileupload.jar
commons-lang-2.1.jar
commons-logging-1.0.4.jar
el-api.jar
el-ri.jar
jboss-serialization.jar
jsf-api.jar
jsf-facelets.jar
jsf-impl.jar
jsp-api.jar
jstl-1.1.0.jar
myfaces-all.jar
myfaces-api-1.1.3.jar
myfaces-impl-1.1.3.jar
portlet.jar
servlet-api.jar
standard.jar
tomahawk-1.1.2.jar
Valeu galera