Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Simple validation

The sample page

Image Removed

Code Block
xml
xml
titleThe sample page
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
  <title>Hello World!</title>
</head>
<body>
<f:view>
  <h:form id="mainForm">
    <h:panelGrid columns="3">
      <h:outputLabel for="name" value="Please enter your name" />
      <h:inputText id="name" value="#{helloWorld.name}" />
      <h:message for="name" showSummary="true" showDetail="false" />

      <h:commandButton value="Press me" action="#{helloWorld.send}" />
      <h:panelGroup />
      <h:panelGroup />
    </h:panelGrid>
  </h:form>
</f:view>
</body>
</html>

Note that there is no JSF validator in the page.

The sample bean

Code Block
java
java
titleFragment of the HelloWorldController bean

public class HelloWorldController {
    
    @Required
    private String name;

    // getters and setters omitted for brevity
}

The result

Cross validation

...