Thank Matt. However, I mostly want all error messages show on top of the form. -Bruce
mraible wrote: > > You need to use <ww:textfield> if you want the field errors to show up > next to the input fields - just like signup.jsp and userForm.jsp use. > > Matt > > On 7/31/07, DreamBig <[EMAIL PROTECTED]> wrote: >> >> I use 1.9 WebWork option. I want to validate username and confirmed >> password >> in register.jsp, just same as AppFuse's Signup page. >> The validators seems to work. But the warning message above the register >> form cannot be displayed. I expect the messages like >> "Warning Username is a required field. >> ..." >> >> I took 2 days to play with the xwork.xml, error.jsp, messages.jsp etc. >> But >> <ww:if test="hasFieldErrors()"> in messages.jsp appears not valid. Could >> you >> guys give any leads? I can provide more info if needed. Thanks a lot, >> -Mike >> In xwork.xml >> ... >> <action name="register" class="userAction" method="create"> >> <interceptor-ref name="validationStack"/> >> <result name="success">/WEB-INF/pages/user/login.jsp</result> >> <!-- >> <result >> name="input">/WEB-INF/pages/user/register.jsp</result> >> --> >> <result name="input" type="redirect">/error.jsp</result> >> <result name="error" type="redirect">/error.jsp</result> >> </action> >> >> My validator User-validation.xml >> <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator >> 1.0//EN" >> "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd"> >> <validators> >> <field name="user.userName"> >> <field-validator type="requiredstring"> >> <message key="errors.required"/> >> </field-validator> >> </field> >> <field name="user.password"> >> <field-validator type="requiredstring"> >> <message key="errors.required"/> >> </field-validator> >> </field> >> <field name="user.confirmPassword"> >> <field-validator type="requiredstring"> >> <message key="errors.required"/> >> </field-validator> >> <field-validator type="fieldexpression"> >> >> (user.confirmPassword.equals(user.password)) >> >> <message key="errors.twofields"/> >> </field-validator> >> </field> >> </validators> >> >> My UserAction-validation.xml >> <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator >> 1.0//EN" >> "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd"> >> <validators> >> <field name="user"> >> <field-validator type="visitor"> >> false >> <message/> >> </field-validator> >> </field> >> </validators> >> >> My /web/errors.jsp is same as appfuse demo >> <%@ page language="java" isErrorPage="true" %> >> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> >> <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> >> <%@ taglib uri="webwork" prefix="ww" %> >> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >> >> <html> >> <head> >> <title><fmt:message key="errorPage.title"/></title> >> <link rel="stylesheet" type="text/css" media="all" href="<c:url >> value="/styles/default.css"/>" /> >> </head> >> >> <body> >> <div id="screen"> >> <div id="content"> >> <h1><fmt:message key="errorPage.heading"/></h1> >> <%@ include file="/common/messages.jsp" %> >> <% if (exception != null) { %> >> <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); >> %></pre> >> <% } else if >> ((Exception)request.getAttribute("javax.servlet.error.exception") != >> null) { >> %> >> <pre><% >> ((Exception)request.getAttribute("javax.servlet.error.exception")) >> .printStackTrace(new >> java.io.PrintWriter(out)); >> %></pre> >> <% } %> >> </div> >> </div> >> </body> >> </html> >> >> My /web/common/messages.jsp is same as appfuse demo >> <%-- ActionError Messages - usually set in Actions --%> >> <ww:if test="hasActionErrors()"> >> <div class="error" id="errorMessages"> >> <ww:iterator value="actionErrors"> >> <c:url value= " >> alt="<fmt:message key="icon.warning"/>" class="icon" /> >> <ww:property/><br /> >> </ww:iterator> >> </div> >> </ww:if> >> >> <%-- FieldError Messages - usually set by validation rules --%> >> <ww:if test="hasFieldErrors()"> >> <div class="error" id="errorMessages"> >> <ww:iterator value="fieldErrors"> >> <ww:iterator value="value"> >> <c:url value= " >> alt="<fmt:message key="icon.warning"/>" class="icon" /> >> <ww:property/><br /> >> </ww:iterator> >> </ww:iterator> >> </div> >> </ww:if> >> >> <%-- Success Messages --%> >> <c:if test="${not empty messages}"> >> <div class="message" id="successMessages"> >> <c:forEach var="msg" items="${messages}"> >> <c:url value= " >> alt="<fmt:message key="icon.information"/>" class="icon" >> /> >> <c:out value="${msg}" escapeXml="false"/><br /> >> </c:forEach> >> </div> >> <c:remove var="messages" scope="session"/> >> </c:if> >> >> Finally my register.jsp >> <%@ include file="/common/taglibs.jsp" %> >> >> <title><fmt:message key="user.title"/></title> >> <%--<content tag="heading"><fmt:message >> key="user.heading"/></content>--%> >> <meta name="menu" content="MainMenu"/> >> <%--<p><fmt:message key="user.message"/></p>--%> >> >> <table width="780" border="0" align="center" cellpadding="0" >> cellspacing="0"> >> <tr> >> <td valign="top"> >> <table width="100%" height="300" border="0" cellpadding="0" >> cellspacing="0"> >> <tr> >> <td align="center" valign="top" >> bgcolor="#FFFFFF"><h5><br> >> userRegister</h5> >> <table width="80%" border="0" cellpadding="0" >> cellspacing="0" bgcolor="#FEFFF0" >> class="register2_black_12"> >> <tr> >> <td align="center" valign="top"><br> >> >> <ww:form name="'registerForm'" >> action="'register'" method="'post'" validate="true"> >> <table width="100%" border="0" >> cellspacing="0" cellpadding="0"> >> >> <%-- XX >> <tr> >> <td height="25" >> align="right">* userName: >> </td> >> <td align="left"><input >> value="" type="text" name="user.userName"></td> >> </tr> >> <ww:if >> test="(user.userName==null >> || user.userName.size==0)"> >> <div> <fmt:message >> key="user.userName.null"/> </div> >> </ww:if> >> --%> >> <tr> >> <td height="25" >> align="right">* <fmt:message key="user.userName"/>: >> </td> >> <td align="left"><input >> value="" type="text" name="user.userName"></td> >> </tr> >> <%-- XX --%> >> >> <tr> >> <td height="25" >> align="right">* password: >> </td> >> <td align="left"><input >> type="password" value="" name="user.password"> >> </td> >> </tr> >> <tr> >> <td height="25" >> align="right">* confirm password: >> </td> >> <td align="left"><input >> type="password" value="" name="user.confirmPassword"> >> </td> >> </tr> >> >> <tr> >> <td height="25" >> align="right">* email:</td> >> <td align="left"><input >> type="text" value="" name="user.email"></td> >> </tr> >> >> >> <tr> >> <td height="25" >> align="right">realName:</td> >> <td align="left"><input >> name="profile.realName" type="text" value=""> >> </td> >> </tr> >> <tr> >> <td height="25" >> align="right">Brithday:</td> >> <td align="left"><input >> name="profile.brithday" type="text" value=""> >> </td> >> </tr> >> <tr> >> <td height="25" >> align="right">Country:</td> >> <td align="left"><input >> name="profile.country" type="text" value=""> >> </td> >> </tr> >> >> <tr> >> <td height="25" >> align="right">Province:</td> >> <td align="left"><input >> name="profile.province" type="text" value=""> >> </td> >> </tr> >> >> <tr> >> <td height="25" >> align="right">Address:</td> >> <td align="left"><input >> name="profile.address" type="text" value="" >> >> size="50"></td> >> </tr> >> >> <tr> >> <td height="25" >> align="right">phone:</td> >> <td align="left"><input >> name="profile.phone" type="text" value=""></td> >> </tr> >> >> </table> >> >> <input type="submit" >> align="center" >> name="RegisterSubmit" >> value="Register"/> >> >> >> <br/> >> >> </ww:form> >> >> <br> >> >> </td> >> </tr> >> </table> >> <br></td> >> </tr> >> </table> >> </td> >> </tr> >> </table> >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/Cannot-display-validation-error-message-with-WebWork-tf4194648s2369.html#a11929275 >> Sent from the AppFuse - User mailing list archive at Nabble.com. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > http://raibledesigns.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Re%3A-Cannot-display-validation-error-message-with-WebWork-tf4263776s2369.html#a12171333 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]