<%-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. $Header:$ --%> <%@ page language="java" contentType="text/html;charset=UTF-8"%> <%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%> <%@ taglib prefix="netui-data" uri="http://beehive.apache.org/netui/tags-databinding-1.0"%> <%@ taglib prefix="netui-template" uri="http://beehive.apache.org/netui/tags-template-1.0"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

This sample demonstrates enabling client-side validation for declarative validation annotations. NetUI does not provide its own client-side validation framework, but the Struts JavaScriptValidatorTag can be used to enable client-side validation.

In general, to use client-side validation with NetUI, you must do the following...

...in your page flow controller class:

  • Add a @Jpf.MessageBundle annotation to the page flow controller, even if your validation annotations use hardcoded messages (without message keys).
  • Provide a message for each validation annotation, using either its messageKey or its message attribute.

...in your JSP:

  • Import the Struts HTML tag library: <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>.
  • Add the Struts <html:javascript> somewhere after the form on the page.
  • Give your <netui:form> a tagId, and use this ID as the formName in your <html:javascript> tag.
  • Choose a unique validation method name for the method attribute on <html:javascript>, and add a call to this method in your <netui:form>'s onSubmit, like this: onSubmit="return myValidationMethod(this)".
  • Give each form input a tagId, which must be the property name of the input field. For example, if a text box has a datasource of actionForm.myProperty, you would use myProperty as the tagId.


Full Name (required, 3 or more characters, letters and spaces, e.g., "Jane Doe"):
Email Address (required, must be a valid email address, e.g., "jane@doe.com"):