Problem in struts validator

hai
I have a problem while using the struts validator in my program.
It gives the error as:
HTTP Status 404 - Servlet action is not available
type Status report
message Servlet action is not available
description The requested resource (Servlet action is not available) is not available.
The program is given below
File : one.jsp
<html:form action="/test" method="post">
<table width="309">
<tr>
<td width="149"><div align="right">User Name: </div></td>
<td width="148"><html:text property="username" value=""/></td>
</tr>
<tr>
<td><div align="right">PassWord: </div></td>
<td><html:password property="password" value="" /> </td>
</tr>
     <tr>
<td><div align="right">Number: </div></td>
<td><html:password property="number" value="" /> </td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><html:submit /> </td>
</tr>
</table>
</html:form>
web.xml file is ordineary file which contains the tag which is necessary for the struts.
File : struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<global-forwards>
<forward name="database" path="/database"/>
</global-forwards>
<form-beans>
<form-bean name="form1" type="struts1.bean1">
</form-bean>      
</form-beans>
<action-mappings>
<action path="/test" name="form1" type="struts1.one" input="one.jsp" validate="true" scope="request" >
     <forward name="success" path="/two.jsp"/>
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
     <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>
File validator.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<form-validation>
<formset>
<!-- Form for Validation example -->
<form name="form1">
<field property="username" depends="required">
<arg0 key="test.string"/>
</field>
<field property="password" depends="required">
<arg0 key="test.password"/>
</field>
<field property="number" depends="required">
<arg0 key="test.number"/>
</field>
</form>
</formset>
</form-validation>
File validator-rules.xml
The validator-rules.xml file is default validator-rules.xml file.
Iam using the two java file for ActionForm and Action
ActionForm file
package struts1;
import org.apache.struts.validator.ValidatorForm;
public class bean1 extends ValidatorForm
private String username=null;
private String password=null;
private int number=0;
public void setUsername(String username)
this.username=username;
public String getUsername()
return username;
public void setPassword(String password)
this.password=password;
public String getPassword()
return password;
public void setNumber(int number)
this.number=number;
public int getNumber()
return number;
Action class:
package struts1;
import struts1.bean1;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorActionForm;
import org.apache.struts.validator.ValidatorForm;
import java.io.IOException;
import javax.servlet.ServletException;
public class one extends Action
public ActionForward execute(ActionMapping mapping,ActionForm form1,HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
String uname=null;
String pword=null;
String target=new String("success");
int num=0;
HttpSession session=request.getSession(true);
try
if(form1 !=null)
bean1 form=(bean1) form1;
uname=form.getUsername();
pword=form.getPassword();
num=form.getNumber();
session.setAttribute("uname",uname);
session.setAttribute("word",pword);
session.setAttribute("num",""+num);
catch(Exception e)
return mapping.findForward(target);
In two.jsp file Iam just getting the session value and displaying the result.
The Action and ActionForm are used inside the struts1 file which is placed inside the classes folder.
The Two file is also compiled successful.
When executing the one.jsp file is displayed but when clicking the submit button it giving the error as servlet action is not available.
So Iam try to change some coding in the Action Class
In the execute method I changed ValidatorForm instead of ActionForm.
but it giving the same error.
The same error is displayed when Iam trying the DynaValidatorForm
instead of struts bean class i.e ActionForm.
If any one knows what is the problem in the program please give some instrutction to correct the error or give some simple example program for practice.
Regards
A.K. Raj

Add the Validator as the 6th argument and it should work fine.
Amy
<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

Similar Messages

  • Problem with struts validator on WLS 8.1

    I am having a strange problem, when I run my app in eclipse using weblogic plugin it works fine and I get no exception. As soon as I run it externally in a standalone server I get an ServletException which seem be be because of struts validator classes. I have checked the classpath and it seems to be identical in eclipse and startweblogic.cmd
              By the way, this code works fine on WLS 6.0
              Root cause of ServletException.
              javax.servlet.jsp.JspException: ServletException in '/common/sea-layout.jsp': ServletException in '/secure/sea
              -basicBOL-body.jsp': org/apache/commons/validator/Validator
              at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:921)
              at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
              at jsp_servlet._secure.__basicbol._jspService(__basicbol.java:368)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
              at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
              at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:322)
              at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
              at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
              at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
              at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316)
              at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
              at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
              at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
              at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.jav
              a:6718)
              at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
              at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
              at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
              at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
              Any pointer to fix this situation will be greatly appreciated.
              -Sankate

    Got the solution.
              It was an classloader issue and I fixed by modifying the way EAR was getting packaged.
              I was including all commons-validation.jar and other commons jars in WEB-INF/lib dir. Some how it worked on WLS 6.0 but was not able to load the jars in WLS 8.1
              Move the jars out of lib dir and copy them to app/lib dir and add them to ejb manifest file because ejb jar is loaded before WAR by the classloader. This way when WAR is loaded, all the required jars are already loaded.
              I was getting servletexception and was not able to get to the root of exception (i.e. its a NullPointerexception or NoClassDefFoundException etc) so I added a scriplet in the root jsp and caught Throwable, that was I came to know the root of the problem.
              -Sankate

  • Problem with Struts Validation and apache dtd definition.

    Jakarta Struts
    Java Version 1.5
    We have one web application that is being a little problematic, on startup two errors are thrown relating to the same problem (errors below).
    We get 401 returned for http://jakarta.apache.org/commons/dtds/validator_1_0.dtd
    both the validation.xml and validation-rules.xml have the same doc type set as below:
    <!DOCTYPE form-validation PUBLIC
    "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
    "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
    We have the same configuration set for several other web application deployed succesfuly on the same tomcat application server without any problems. I'm not sure why this one application is causing a problem, I don't see any difference between the validation.xml and validation-rules.xml files in this application to any of the others that have been succesfully deployed, infact the validation-rules.xml is identical for all the web applications hosted on this server.
    Any ideas appreciated
    Error
    2006-03-30 15:04:50,968 ERROR [HttpRequestHandler-169] validator.ValidatorPlugIn (ValidatorPlugIn.java:224) - Server returned HTTP response code: 401 for URL: http://jakarta.apache.org/commons/dtds/validator_1_0.dtd
    java.io.IOException: Server returned HTTP response code: 401 for URL: http://jakarta.apache.org/commons/dtds/validator_1_0.dtd
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:791)
         at java.net.URL.openStream(URL.java)
         at oracle.xml.parser.v2.XMLReader.openURL(XMLReader.java:2292)
         at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:265)
         at oracle.xml.parser.v2.NonValidatingParser.pushExternalDTD(NonValidatingParser.java:540)
         at oracle.xml.parser.v2.NonValidatingParser.parseDoctypeDecl(NonValidatingParser.java:465)
         at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:298)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:277)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:184)
         at org.apache.commons.digester.Digester.parse(Digester.java:1515)
         at org.apache.commons.validator.ValidatorResourcesInitializer.initialize(Unknown Source)
         at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:222)
         at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:161)
         at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
         at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
         at javax.servlet.GenericServlet.init(GenericServlet.java:259)
         at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2141)
         at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4582)
         at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4676)
         at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:820)
         at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:542)
         at com.evermind.server.Application.getHttpApplication(Application.java:889)
         at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:690)
         at com.evermind.server.http.HttpSite.getApplication(HttpSite.java:420)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:422)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    2006-03-30 15:04:50,968 INFO [HttpRequestHandler-169] validator.ValidatorPlugIn (ValidatorPlugIn.java:209) - Loading validation rules file from '/WEB-INF/validation.xml'
    2006-03-30 15:04:50,984 ERROR [HttpRequestHandler-169] validator.ValidatorPlugIn (ValidatorPlugIn.java:224) - Server returned HTTP response code: 401 for URL: http://jakarta.apache.org/commons/dtds/validator_1_0.dtd
    java.io.IOException: Server returned HTTP response code: 401 for URL: http://jakarta.apache.org/commons/dtds/validator_1_0.dtd
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:791)
         at java.net.URL.openStream(URL.java)
         at oracle.xml.parser.v2.XMLReader.openURL(XMLReader.java:2292)
         at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:265)
         at oracle.xml.parser.v2.NonValidatingParser.pushExternalDTD(NonValidatingParser.java:540)
         at oracle.xml.parser.v2.NonValidatingParser.parseDoctypeDecl(NonValidatingParser.java:465)
         at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:298)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:277)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:184)
         at org.apache.commons.digester.Digester.parse(Digester.java:1515)
         at org.apache.commons.validator.ValidatorResourcesInitializer.initialize(Unknown Source)
         at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:222)
         at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:161)
         at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
         at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
         at javax.servlet.GenericServlet.init(GenericServlet.java:259)
         at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2141)
         at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4582)
         at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4676)
         at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:820)
         at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:542)
         at com.evermind.server.Application.getHttpApplication(Application.java:889)
         at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:690)
         at com.evermind.server.http.HttpSite.getApplication(HttpSite.java:420)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:422)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    -----------------------------------------------------------------------

    hi,
    I am also facing the same issue. Could you tell me which are those jar files you were missing & from where you got those?
    regards
    prasanth

  • Problem in struts validation

    hi,
    i am doing a project using struts framework.
    i've configured strtus-config.xml , validation.xml
    but validation framework is not working for me.
    when i click submitt button without entering any values, it directly maps to the success page. but it should show the errors.
    i've attached all the files with this. plz give me the solution
    struts-config.xml
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <struts-config>
    <form-beans>
    <form-bean name="allotIssueFormBean" type="issues.AllotIssueFormBean"/>
    </form-beans>
    <action-mappings>
    <action path="/allotIssue"
    type="issues.AllotIssueAction"
    scope="request"
    name="allotIssueFormBean"
    validate="true"
    input="/allotIssue.jsp">
    <forward name="success"
    path="/results/success.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validator/validation.xml" />
    <set-property property="stopOnFirstError" value="true" />
    </plug-in>
    </struts-config>
    -- validation.xml --
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE form-validation PUBLIC
    "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
    "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
    <form-validation>
    <!--
    This is a minimal Validator form file with a couple of examples.
    -->
    <global>
    <!-- An example global constant
    <constant>
    <constant-name>postalCode</constant-name>
    <constant-value>^\d{5}\d*$</constant-value>
    </constant>
    end example-->
    </global>
    <formset>
    <!-- An example form -->
    <form name="AllotIssueFormBean">
    <field
    property="issueID"
    depends="required" >
    <arg0 key="ddd" resource="false"/>
    </field>
    <field
    property="listName"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="projectName"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectAllotting"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectDate"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectMonth"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    <field
    property="selectYear"
    depends="required">
    <arg0 key="ddd"/>
    </field>
    </form>
    </formset>
    </form-validation>
    allotIssue.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <html:html>
    <head>
    <TITLE> ALLOTT ISSUE </TITLE>
    <html:javascript formName="allotIssueFormBean" staticJavascript="true" method="validateAllotIssueFormBean"/>
    <STYLE>
    body{
    font-family:verdana;
    background-color:#0111d3;
    color:white;
    font-size:8px;
    table
    font-size:10px;
    </STYLE>
    </head>
    <html:errors/>
    <html:form action="/allotIssue.do" >
    <TABLE border="1" align="center" bodercolor="silver" bgcolor='#4478f0' width="40%">
    <tr>
    <td colspan="2" style='border:0px' align="center">ALLOT ISSUE</td>
    </tr>
    <TR style='border:0px'>
    <TD>IssueID:</TD>
    <TD><html:text property="issueID"/></TD>
    </TR>
    <TR style='border:0px'>
    <TD>List Name:</TD>
    <TD><html:text property="listName"/></TD>
    </TR>
    <TR style='border:0px'>
    <TD>Project Name:</TD>
    <TD><html:text property="projectName"/></TD>
    </TR>
    <TR style='border:0px'>
    <TD>Allotted To:</TD>
    <TD><html:select property="selectAllotting" >
    <html:option value="associatename1">Name1</html:option>
    <html:option value="associateName2">Name2</html:option>
    <html:option value="associatename3">Name3</html:option>
    </html:select>
    </TD>
    </TR>
    <TR CLASS="tr">
    <TD CLASS="td" style='border:0px'>Projected-End-Date</td>
    <TD><html:select property="selectDate" >
    <html:option value="1">1</html:option>
    <html:option value="2">2</html:option>
    <html:option value="3">3</html:option>
    </html:select>
    <html:select property="selectMonth" >
    <html:option value="1" >Jan</html:option>
    <html:option value="2" >Feb</html:option>
    </html:select>
    <html:select property="selectYear">
    <html:option value="1990">1990</html:option>
    <html:option value="1991">1991</html:option>
    </html:select>
    </TD>
    </TR>
    <TR style='border:0px'>
    <TD colspan="2" align="center">
    <html:submit value="AllotIssue"/>
    <html:reset value="Reset"/>
    </TD>
    </TR>
    </TABLE>
    </html:form>
    </html:html>
    -- AllotIssueAction.java --
    * AllotIssueAction.java
    * Created on April 27, 2006, 4:49 PM
    * To change this template, choose Tools | Options and locate the template under
    * the Source Creation and Management node. Right-click the template and choose
    * Open. You can then make changes to the template in the Source Editor.
    package issues;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    public class AllotIssueAction extends Action {
    public ActionForward execute(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    return(mapping.findForward("success"));
    -- AllotIssueFormBean --
    package issues;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    import org.apache.struts.validator.*;
    public class AllotIssueFormBean extends ValidatorForm {
    private String issueID = "";
    private String listName = "";
    private String projectName = "";
    private String selectAllotting = "";
    private String selectDate="";
    private String selectMonth="";
    private String selectYear="";
    public String getIssueID() {
    return(issueID);
    public void setIssueID(String issueID) {
    this.issueID = issueID;
    public String getListName() {
    return(listName);
    public void setListName(String listName) {
    this.listName = listName;
    public String getProjectName() {
    return(projectName);
    public void setProjectName(String projectName) {
    this.projectName = projectName;
    public String getSelectAllotting() {
    return(selectAllotting);
    public void setSelectAllotting(String selectAllotting) {
    this.selectAllotting = selectAllotting;
    public String getSelectDate() {
    return(selectDate);
    public void setSelectDate(String selectDate) {
    this.selectDate = selectDate;
    public String getSelectMonth() {
    return(selectMonth);
    public void setSelectMonth(String selectMonth) {
    this.selectMonth = selectMonth;
    public void setSelectYear(String selectYear) {
    this.selectYear = selectYear;
    public String getSelectYear() {
    return(selectYear);
    }

    In the following code...
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <struts-config>
    <form-beans>
    <form-bean name="allotIssueFormBean" type="issues.AllotIssueFormBean"/>
    </form-beans>... should the <form-bean> type attribute be org.apache.struts.validator.DynaValidatorForm? I've only done validation in this way (though I'm still a novice myself). Then you wouldn't need your allotIssueFormBean, and instead you would define the properties in the struts-config using...
    <form-bean ...>
      <form-property name="issueID" type="java.lang.String" />
      <form-property name="listName" type="java.lang.String" />
    ... etc...
    </form-bean>

  • Lost Locale problem with Struts/Validator Plugin client side validation

    Has anyone else had problems losing the locale in the generated javascript ?
    With the following tiles def and layout (nmLayout.jsp) I can get the locale from the browser OK with
    <html:html locale="true"> and it works ok for imported text (picking up the enCA properties file. But when the javascript executes in the provisionCustomer.jsp the locale reverts to the default property file.
    The Strruts Validator loses the locale of the containing html page. (I do a show source.) I've tried an explicit <fmt:setLocale value="en_CA" scope="session"/> but this has no effect either.
    Thanks
    Bruce
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE tiles-definitions PUBLIC
    "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
    <!--
    Tiles definition file
    -->
    <tiles-definitions>
    <definition name="nm.MainMenu" path="/nmLayout.jsp">
    <put name="pageTitle" value="Distibutel Network Management" />
    <put name="header" value="header.jsp" />
    <put name="body" value="mainMenuBody.jsp" />
    <put name="footer" value="footer.jsp" />
    </definition>
    <definition name="nm.customer" path="/nmLayout.jsp">
    <put name="pageTitle" value="Distibutel Network Management -- Provision Customer" />
    <put name="header" value="header.jsp" />
    <put name="body" value="provisionCustomer.jsp" />
    <put name="footer" value="footer.jsp" />
    </definition>
    <!-- sample tiles definitions
    <definition name=".mainLayout" path="/common/layouts/classicLayout.jsp">
    <put name="title" value="Sample Page Title" />
    <put name="header" value="/common/header.jsp" />
    <put name="menu" value=".mainMenu" />
    <put name="footer" value="/common/footer.jsp" />
    <put name="body" value=".portal.body" />
    </definition>
    <definition name=".mainMenu" path="/common/layouts/vboxLayout.jsp" >
    <putList name="list" >
    <add value=".menu.links" />
    <add value=".menu.taglib.references" />
    <add value=".menu.printer.friendly" />
    <add value=".menu.old.documents" />
    </putList>
    </definition>
    <definition name="aPage" extends=".mainLayout">
    <put name="title" value="Another Title" />
    <put name="body" value=".aPage.body" />
    </definition>
    end samples -->
    <definition name="${YOUR_DEFINITION_HERE}">
    </definition>
    </tiles-definitions>
    nmLayout.jsp :
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <%@ taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %>
    <%@ taglib uri="http://struts-menu.sf.net/tag-el" prefix="menu-el" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
    <html:html locale="true">
    <head>
    <title><tiles:getAsString name="pageTitle"/></title>
    <link rel="stylesheet" type="text/css" media="screen"
    href="styles/global.css" />
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <style type="text/css">
    body { background: AliceBlue; }
    #appcontent {
                             position:absolute;
                             top: 300px;
                             left: 200px;
                   h1 {color: red;}
                   h2 {color: green;}
    </style>
    </head>
    <body topmargin="0" leftmargin="0">
    <!--
         <fmt:setBundle basename="ApplicationResources"/>
         <fmt:setLocale value="en_CA" scope="session"/>
    -->     
         <script type="text/javascript" src="./scripts/coolmenus3.js"></script>
         <!-- Custom config for this example -->
         <script type="text/javascript" src="./scripts/coolmenu2-config.js"></script>
         <menu:useMenuDisplayer name="CoolMenu"
         bundle="org.apache.struts.action.MESSAGE">
         <menu:displayMenu name="ToDoListMenuProvision"/>
         </menu:useMenuDisplayer>
    <table>
    <tr>
    <td><tiles:insert attribute="header"/></td>
    </tr>
    <tr>
    <td><div id="appcontent"><tiles:insert attribute="body"/></div></td>
    </tr>
    <tr>
    <td><tiles:insert attribute="footer"/></td>
    </tr>
    </table>
    </body>
    </html:html>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
    <html:javascript formName="customerForm" />
    <html:errors/>
    <h1><fmt:message key="ProvisionCustomer.title"/></h1>
    <html:form action="/saveCustomer"
    onsubmit="return validateCustomerForm(this)" >
    <table>
    <tr>
    <td><h2><fmt:message key="ProvisionCustomer.TenantName"/>:</h2></td><td> <html:text property="tenantName"/></td>
    </tr>
    <tr>
    <td><h2><fmt:message key="ProvisionCustomer.TenantID"/>:</h2></td><td> <html:text property="tenantID"/></td>
    </tr>
    <tr>
    <td><h2><fmt:message key="ProvisionCustomer.CustomerID"/>:</h2></td><td> <html:text property="customerID"/></td>
    <td></td><td><input type="submit" value=<fmt:message key="ProvisionCustomer.insert"/>></td>
    </tr>
    </table>
    </html:form>

    you can always get the locale from the request like so....
    <html>
    <%
    request.getLocale().toString();
    %>
    </html>
    you can even stuff it into javascript like so....
    <html>
    <head>
    <script>
    function foo() {
    var locale = '<%=request.getLocale().toString()%>';
    </script>
    </head>
    </html>
    then you can have access to it in javascript code.

  • Struts validation not working properly

    Hi,
    I'm using the struts validator to validate my form.. I've followed all the steps required.. I've checked it quite a few times :)
    Currently I want to verify if my form fields have any value, so am verifying the required property.. but when I submit an empty form, it doesn't show an error.. but the log shows the following;
    Any suggestions what could be missing?
    2005-08-11 16:20:08,804 [http-8080-Processor25] ERROR org.apache.struts.validator.ValidatorForm - org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest)
    org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest)
         at org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:627)
         at org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:557)
         at org.apache.commons.validator.Field.validateForRule(Field.java:827)
         at org.apache.commons.validator.Field.validate(Field.java:906)
         at org.apache.commons.validator.Form.validate(Form.java:174)
         at org.apache.commons.validator.Validator.validate(Validator.java:367)
         at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:152)
         at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:942)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

    I had a similar problem upgrading from struts 1.1 to 1.2.7. The method signatures in FieldChecks changed to include a Validator object:
    1.1
    validateRequired(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)
    1.2.7
    validateRequired(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
    After I added org.apache.commons.validator.Validator to the methodParams attribute of validator in validator-rules.xml I no longer got the error (which was a NoSuchMethodException... I had to look at the ValidatorAction code to find that out, for some reason it wasn't in the stack trace).

  • Inconsistent Form Behavior on Failed Struts Validation

    So I'm working on a strange bug regarding an Edit User form for an application, where some fields revert to their default and some fields do not.
    We have a form for editing users in our system, with most of the usual information inputted in text boxes (login, first name, last name, password, password confirmation). We also have three possible levels of 'admin' - none, admin, and superadmin. These are chosen via radio buttons. There are also a couple of checkboxes (like 'user is active'). Overall, it's a fairly simple form.
    When the form is submitted, we do struts validation. We've set up the validation via comment annotation in our Java code, like so:
         * @struts.validator type="minlength"
         *                   arg1value="${var:minlength}"
         * @struts.validator-var name="minlength" value="8"
         * @struts.validator type="maxlength"
         *                   arg2value="${var:maxlength}"
         * @struts.validator-var name="maxlength" value="50"
        public void setPassword1(String string) {
            password1 = string;
        }All of the fields in our form are set from user properties, so they're initialized by the values in the user object. For example, if we had user John Smith, an admin, with login 'jsmith,' we'd have the first name and last name fields initialized to John and Smith, and the radio buttons for Admin set to 'admin.' For reference, here's the EditUser.jsp code for the radio buttons, based off of the selectedAdminRole property:
    <div class="InputElement">
            <label for="selectedAdminRole"><bean:message key="userForm.adminType"/></label>
              <html:radio styleId="selectedAdminRole" property="selectedAdminRole" value="None"
                          disabled="${userForm.loggedInUser.admin and userForm.userId == userForm.loggedInUser.id}">None</html:radio>
              <html:radio property="selectedAdminRole" value="Admin"
                          disabled="${userForm.loggedInUser.admin and userForm.userId == userForm.loggedInUser.id}">Admin</html:radio>
              <c:if test="${userForm.loggedInUser.superAdmin}">
                  <html:radio property="selectedAdminRole" value="SuperAdmin">Super</html:radio>
              </c:if>
         </div>As you can see above, the struts validator requires passwords to be at least 8 characters long. So if the user tries to change their password to something with less than that, they'll fail validation and they'll end up back on the form with the validation errors in red at the top of the page. However, the form data that they've edited will be preserved. So if John had tried to change his first name to 'Fred,' he'd still see 'Fred' in the First Name text field, even though it wouldn't actually get saved to the user object until he submitted the form with no errors. This works with radio buttons too - if John had tried to set his admin status down to 'none' from 'admin,' the radio button 'none' would still be checked. Basically, it preserves all your progress on the form until you navigate away.
    Unfortunately, it does NOT do this when you create a new user. Creating a new user uses the same form, and since there's no user object to get the fields from, they all get initialized to blank - except for one of the checkboxes ('user is active') and the radio buttons for admin (starts with 'none' checked). Now, if the user fills out the form and hits submit, but fails the struts validation, it preserves all the form data in the text fields, but reverts the checkboxes and the radio buttons to their default state.
    This leads to the following problem: say I'm trying to create a new admin, Jane Smith. I fill out the whole form, check the 'admin' button, and then enter a four-letter password. I submit, and the form fails struts validation and throws me back to the page with an error message informing me that passwords need to be at least 8 characters. I look over the form again - the login field is still 'janesmith,' the first name field is still 'Jane,' the last name field is still 'Smith,' everything looks fine except I screwed up the password. I enter an 8 letter password and resubmit. Jane then logs in and complains that she's not an admin, because I didn't notice that the 'admin' button had reset itself to the default of 'none' when I failed validation.
    My question is, why does it reset the radio buttons and checkboxes - but not the text fields - on failed validation when a new user is being created, but resets nothing at all when an existing user is being edited? I'd like it to reset none of the information when a new user is being created, but I cannot figure out the reason for this inconsistent behavior.
    If anyone can help me figure out how to get this working so that nothing gets reset - or at least explain to me the reason for this inconsistent behavior - I would be very grateful. I will also try to provide any additional information I can if this isn't enough.

    So what you are saying is that radio and checkboxes don't retain their state when validation fails?
    Checkboxes are always troublesome because of their design. If not selected, they don't submit any value - so you have to specifically unset them.
    My first instinct would be to look at the formbean which you are populating from, and see what (if anything) modifies its values.
    - for originally loading the new user page is it an action or JSP? Does it apply any default values to the form?
    - check the "input" page you redirect to when validation fails. Is it an action or a JSP?
    - is the same form being uses on the newUser jsp and whatever action you are submitting it to?
    - is there a form reset() method?
    My theory is that the "input" page you are redirecting to when validation fails is an action, and it sets some values on the form prior to loading.
    But thats just a guess at this point. Its hard to debug this without a working example. Its been a while since I worked with struts, and never with annotations providing the validation.
    Suggestion for debugging: dump the contents of the form bean at strategic points in the process to see that the values are what you think they should be.
    - running the save action
    - just after validation
    - on the jsp page.
    Hope this helps some,
    evnafets

  • Integrate struts validator framework

    (JHeadstart 9.0.4: Toplink/JSP/Struts)
    I am trying to integrate the struts validator framework . I'm encountering the following
    problem. When a validation rule(defined in the struts validation.xml) is violated I would expect
    that the JSP include named jhsInfo.jsp would show the errormessage because I assumed that it also
    reads from the same Error Bean (ActionErrors object ) struts normally uses.
    When I include a jsp of my own, containing the following:
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html:errors/>
    then messages raised by the struts validation framework are shown and everything seems to work.
    I have the following questions:
    - Is it possible to show struts validation error messages using the jhsInfo.jsp ?
    I investigated the <jhs:ifContainsError> in the JHeadstart Taglibrary
    and noticed how it checks for the JHS_USER_INFO session attribute; apparently, when the validate()
    method in JhsDynaActionForm finds ActionErrors through the Struts Validator framework, this session attribute is not set.
    However, even if we add this attribute explicitly to sessionData in validate(), we do not get the Struts Validator Action Errors.
    - If not possible, how could we adapt the code to make it work? Should we instantiate JHeadstart UserExceptions
    for all ActionErrors or does JHeadstart have built-in functionality to deal with these ActionErrors in the proper way?
    Are we running into a bug, is it intentional to keep Struts Validator Error separate from JHeadstart Exception Errors
    or is JHeadstart currently not equipped with the logic to deal with the ActionErrors?
    Thanks in advance,
    Rob Brands (Amis)

    Rob,
    JHeadstart transforms UserExceptions (controller-independent) to Struts specific ActionErrors and ActionMessages in JhsRequestprocessor.convertUserExceptions.
    So, with JHeadstart you can either use ACtionErrors/ActionMessages directly, or indirectly by thrwoing UserExceptions.
    In jhsInfo we use html:messages to loop over both messages and errors (The boolean attribute message determines whether ActionErrors or ActionMessages are iterated). We do not use html:errors because that does not provide you with control over the layout of individual messages.
    You are right that our custom tags ifContainsError and ifContainsInformation should also directly check for existence of ActionErrors and ActionMessages. We will fix that for the upcoming release.
    With that fix in place, you should be able to use jhsInfo.jsp to display validator messages.
    You mentioned you tried to put a "dummy" JHS_USER_INFO exception on the session in the validate() method. This approach should work, however, to display ActionErrors (as is the case with the validator framework), you should use JHS_USER_ERROR as the key, noy JHS_USER_INFO.
    For now, you could choose to modify jhsInfo.jsp and use your own ifContains tags, until we have fixed this.
    Steven Davelaar.

  • Bussines rules problems using Struts + BC4J

    Hi, I'm using struts + bc4j and I have some problems with the validations made on the entities.
    Looks like sometimes, struts didn't shows the error message until the commit is made. But the problem is that on the navigator shows me the stack trace of the exception, but only when I do the commit of the transaction.
    In the test of the application module, the business rules works perfectly.
    If somebody can help me i will aprecciate it.
    Thanks
    Daniel Gonzalez

    There are already some threads on this topic.
    Unfortunately, they don't give solutions - not yet ;)
    Custom Method Validator
    addVetoableChangeListener for attribute doesn't seem to get fired
    HTH,
    Adrian

  • Validate integer with a comma thousands seperator using struts Validator

    Using struts validator.
    have to validate the user entered value.
    The value entered should be a positive integer with a comma thousands seperator. the number need not be in thousands.
    I have as below to check for positive integer without comma seperator. but not sure how to validate if the user entered value with a comma seperator?
    i.e value like 25,349 // how to validate this?
    <field property="hrs" depends="integer,validwhen">
    <msg name="integer" key="errors.notvalid"/>
    <msg name="validwhen" key="errors.notvalid"/>
    <var>
    <var-name>test</var-name>
    <var-value>(*this* >= 0)</var-value>
    </var>
    </field>
    how to validate the user entered value with a comma seperator? Thanks.

    Found this in Struts' Building View Components section: Note: If your required form property is one of the Java object representations of primitive types (ie. java.lang.Integer), you must set the ActionServlet's convertNull init. parameter to true. Failing to do this will result in the required validation not being performed on that field because it will default to 0. This seems to be part of my problem. With it turned on, Validator picks up that the value is required. Now to figure out the issue with putting in a double value instead of an Integer.

  • Struts Validations

    hi,
    I've written a Struts application which uses Struts Validations, and used <html:javascript>
    tag to have client side validations.
    the problem is , when I start the application, the form is displayed along with the Scripting code of the validator frame work ...
    please help me ....

    Kumar:
    You said you read "Struts In Action", the solution to your problem(at least similar) is right in there on page 397 under "Interrelated Fields" but I was having some trouble implementing that code. As I did not have time to research the problem any further, I just added a "validate" method to my ActionForm eventhough it is not needed because I'm extending ValidatorActionForm which in theory does not need a validate method as it has its own at least according to the book. But anyway, what I did is this to compare two password fields...
    In my ActionForm...
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
    ActionErrors errors = super.validate(mapping,request);
    if (errors == null)
    errors = new ActionErrors();
    if (!password.equals(passwordconfirm))
    errors.add("Passwords Do Not Match",new ActionError("newuser.passwordconfirm.invalid"));
    if (errors == null)
    return null;
    return errors;
    Hope this helps with the part of your question about Amount fields.

  • Problem with Item Validation

    Hello,
    I am running an advanced tutorial: http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/issue_track_ui.htm#BGBJCGIC
    and I have a problem with item Validation.
    Tutorial offers the following:
    You must manually create another validation to ensure that the Actual End Date is the same or later then the Start Date.
    To add a validation for the Actual End Date:
    1.Under Page Processing, Validations, click the Create icon.
    2.For Level, accept the default, Item level validation, and click Next.
    3.For Item, select Project Details: 50.P3_ACTUAL_END_DATE (Actual End Date) and click Next.
    4.For Validation Method:
    a.Select PL/SQL and click Next.
    b.Accept the default, PL/SQL Expression and click Next.
    5.For Sequence and Name:
    a.Sequence - Enter 50.
    b.Validation Name - Enter P3_END_AFTER_START.
    c.Accept the remaining defaults and click Next.
    6.For Validation:
    a.Validation - Enter:
    to_date(:P3_ACTUAL_END_DATE,:APP_DATE_FORMAT) >= to_date
    (:P3_START_DATE,:APP_DATE_FORMAT)
    b.Error Message - Enter:
    Actual End Date must be same or after Start Date.
    c.Click Next.
    7.For Conditions:
    a.Condition Type - Select Value of Item in Expression 1 is NOT NULL
    b.Expression 1 - Enter P3_ACTUAL_END_DATE
    8.Click Create.
    Is there a mistake in explanation? I did it 3 times already, very carefully! I ran the page, entered the date, which is After the Start date, and get the error message: Actual End Date must be same or After Start Date!!
    Thank you for your consideration...

    I got it solved. I don't know if this is documented(or a bug) but what I did was declare an exception and then raise it and put the form_trigger_failure into the exception handler rather than raise form_trigger_failure in the body.
    declare
    alreadyExists exception;
    begin
    -- select .....
    raise alreadyExists;
    exception
    when alreadyExists then
    message('.....exists');
    raise form_trigger_failure
    end;

  • How to use the validation.xml in struts validation?

    Can any one please help me, how to use the validation.xml in struts validation? possible please give me simple example.
    Edited by: SathishkumarAyyavoo on Jan 31, 2009 12:03 PM

    These 2 are the good articles for the beginners to do validation things in Struts. you can follow any one of them.
    1. [http://viralpatel.net/blogs/2009/01/struts-validation-framework-tutorial-example-validator-struts-validation-form-validation.html]
    2. [http://www.vaannila.com/struts/struts-example/struts-custom-validation-example-1.html]
    All the best.

  • Can't get Struts validator to work with ADF 10.1.3.36.73 in Jdev 10.1.3.0.4

    I am attempting to use the "How to Use the Struts Validator Plug-in with JDeveloper 10g" written by Duncan in a JDeveloper 10.1.3.0.4 application with standard model/ViewController projects. I am using JSP/Struts/ADF technologies.
    I have performed the below:
    Struts Config:
    <form-bean name="surveyDataForm" type="oracle.adf.controller.v2.struts.forms.BindingContainerValidationForm" className="oracle.adf.controller.struts.forms.BindingContainerValidationFormConfig"/>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    In the validation.xml:
    <!DOCTYPE form-validation
    PUBLIC "-//Apache Software Foundation//
    DTD Commons Validator Rules
    Configuration 1.0//EN"
    "http://jakarta.apache.org/
    commons/dtds/validator_1_0.dtd">
    <form-validations>
    <formset>
    <form name="surveyDataForm">
    <field property="EmpName" depends="required">
    <arg0 key="survey.name"/>
    </field>
    <field property="DateOfService" depends="required">
    <arg0 key="survey.service.date"/>
    </field>
    <field property="ReloContractor" depends="required">
    <arg0 key="survey.relo.contract"/>
    </field>
    </form>
    </formset>
    </form-validations>
    And in my JSP, I have:
    <script type="text/javascript">
    <html:javascript formName="surveyDataForm"/>
    </script>
    <html:form action="/survey.do" onsubmit="return validateSurveyDataForm(this)">
    (The validation-rules.xml was copied from the JDev install jakarta-struts folder).
    I can now see the Javascript showing up in my JSP page, but I don't have a method generated for validateSurveyDataForm or any form like this. I didn't think I had to create this. Also, even without the Javascript, the validator is not called because the JBO errors for required are still showing up. The only thing I have not done is included the modelReference in the Form Bean definition in the struts-config.xml. I'm not sure this will work, or even what to populate this with, as the UIModel.xml is replaced by PageDef.xml and DataBindings.cpx changes.
    Anyone have any ideas?
    Shay

    Only have one network; wireless. On it's own, the MacBook can use wifi to surf the net and Apple TV can watch movie previews from Apple via wifi.
    It did work about two months ago. I haven't used it since then for home sharing but have used the Apple TV on its own.
    I read the Troubleshooting page on Apple Support. It involves turning various things on and off, which I did

  • Struts Validation not working

    As far as I can tell I can't see anything wrong with my validation on struts, but if I put nothing into a required field it doesn't report an error. Any ideas? Below is the offending code:
    First Validation.xml
    <form-validation>
        <formset>
            <form name="User">
                <field property="email"
                        depends="required,email">
                    <arg0 key="user.email"/>
                </field>
            </form>
        </formset>
    </form-validation>Next my struts-config.xml:
    <form-bean name="User" type="org.apache.struts.validator.DynaValidatorForm">
             <form-property name="userName" type="java.lang.String"/>
             <form-property name="password" type="java.lang.String"/>
             <form-property name="firstName" type="java.lang.String"/>
             <form-property name="lastName" type="java.lang.String"/>
             <form-property name="email" type="java.lang.String"/>
    </form-bean>next the jsp code:
    <html:form action="/profile?action=save">
    <html:errors/><BR><BR>
    <tr>
         <td align="left" valign="top"><font face="Arial, Helvetica" size="2">Email:</font></td>
         <td></td>
         <td align="left"><html:text property="email" size="35" maxlength="255" /><br><font size="1"><i>(Your name @ your company web site address)</i></font></td>
    </tr>
    </form>And my Action code:
              else if (action.equals("save")){
                   errors = form.validate(mapping, request);
                   if ((errors == null) || (errors.isEmpty())){
                        //Save Item goes here
                        return (mapping.findForward("Profile"));
                   else {
                        saveErrors(request, errors);
                        return (mapping.findForward("show"));
              }And my validator-rules.xml (it is the default one that comes with struts, but I included it just in case)
    <form-validation>
       <global>
          <validator name="required"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateRequired"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                      msg="errors.required">
             <javascript><![CDATA[
                function validateRequired(form) {
                    var isValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oRequired = new required();
                    for (x in oRequired) {
                         var field = form[oRequired[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea' ||
                            field.type == 'file' ||
                            field.type == 'select-one' ||
                            field.type == 'radio' ||
                            field.type == 'password') {
                            var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                            value = field.options[si].value;
                                  } else {
                                       value = field.value;
                            if (trim(value).length == 0) {
                                 if (i == 0) {
                                     focusField = field;
                                 fields[i++] = oRequired[x][1];
                                 isValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return isValid;
                // Trim whitespace from left and right sides of s.
                function trim(s) {
                    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
                ]]>
             </javascript>
          </validator>
          <validator name="requiredif"
                     classname="org.apache.struts.validator.FieldChecks"
                     method="validateRequiredIf"
                     methodParams="java.lang.Object,
                                   org.apache.commons.validator.ValidatorAction,
                                   org.apache.commons.validator.Field,
                                   org.apache.struts.action.ActionErrors,
                                   org.apache.commons.validator.Validator,
                                   javax.servlet.http.HttpServletRequest"
                     msg="errors.required">
          </validator>
          <validator name="minlength"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateMinLength"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.minlength">
             <javascript><![CDATA[
                function validateMinLength(form) {
                    var isValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oMinLength = new minlength();
                    for (x in oMinLength) {
                        var field = form[oMinLength[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea') {
                            var iMin = parseInt(oMinLength[x][2]("minlength"));
                            if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
                                if (i == 0) {
                                    focusField = field;
                                fields[i++] = oMinLength[x][1];
                                isValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return isValid;
                }]]>
             </javascript>
          </validator>
          <validator name="maxlength"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateMaxLength"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.maxlength">
             <javascript><![CDATA[
                function validateMaxLength(form) {
                    var isValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oMaxLength = new maxlength();
                    for (x in oMaxLength) {
                        var field = form[oMaxLength[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea') {
                            var iMax = parseInt(oMaxLength[x][2]("maxlength"));
                            if (field.value.length > iMax) {
                                if (i == 0) {
                                    focusField = field;
                                fields[i++] = oMaxLength[x][1];
                                isValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return isValid;
                }]]>
             </javascript>
          </validator>
          <validator name="mask"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateMask"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.invalid">
             <javascript><![CDATA[
                function validateMask(form) {
                    var isValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oMasked = new mask();
                    for (x in oMasked) {
                        var field = form[oMasked[x][0]];
                        if ((field.type == 'text' ||
                             field.type == 'textarea') &&
                             (field.value.length > 0)) {
                            if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
                                if (i == 0) {
                                    focusField = field;
                                fields[i++] = oMasked[x][1];
                                isValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return isValid;
                function matchPattern(value, mask) {
                   return mask.exec(value);
                }]]>
             </javascript>
          </validator>
          <validator name="byte"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateByte"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.byte"
           jsFunctionName="ByteValidations">
             <javascript><![CDATA[
                function validateByte(form) {
                    var bValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oByte = new ByteValidations();
                    for (x in oByte) {
                         var field = form[oByte[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea' ||
                            field.type == 'select-one' ||
                                  field.type == 'radio') {
                                  var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                            value = field.options[si].value;
                                  } else {
                                       value = field.value;
                            if (value.length > 0) {
                                if (!isAllDigits(value)) {
                                    bValid = false;
                                    if (i == 0) {
                                        focusField = field;
                                    fields[i++] = oByte[x][1];
                                } else {
                                     var iValue = parseInt(value);
                                     if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
                                         if (i == 0) {
                                             focusField = field;
                                         fields[i++] = oByte[x][1];
                                         bValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return bValid;
                }]]>
             </javascript>
          </validator>
          <validator name="short"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateShort"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.short"
           jsFunctionName="ShortValidations">
             <javascript><![CDATA[
                function validateShort(form) {
                    var bValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oShort = new ShortValidations();
                    for (x in oShort) {
                         var field = form[oShort[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea' ||
                            field.type == 'select-one' ||
                            field.type == 'radio') {
                            var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                            value = field.options[si].value;
                                  } else {
                                       value = field.value;
                            if (value.length > 0) {
                                if (!isAllDigits(value)) {
                                    bValid = false;
                                    if (i == 0) {
                                        focusField = field;
                                    fields[i++] = oShort[x][1];
                                } else {
                                     var iValue = parseInt(value);
                                     if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
                                         if (i == 0) {
                                             focusField = field;
                                         fields[i++] = oShort[x][1];
                                         bValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return bValid;
                }]]>
             </javascript>
          </validator>
          <validator name="integer"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateInteger"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.integer"
           jsFunctionName="IntegerValidations">
             <javascript><![CDATA[
                function validateInteger(form) {
                    var bValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oInteger = new IntegerValidations();
                    for (x in oInteger) {
                         var field = form[oInteger[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea' ||
                            field.type == 'select-one' ||
                            field.type == 'radio') {
                            var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                      if (si >= 0) {
                                           value = field.options[si].value;
                                  } else {
                                       value = field.value;
                            if (value.length > 0) {
                                if (!isAllDigits(value)) {
                                    bValid = false;
                                    if (i == 0) {
                                         focusField = field;
                                          fields[i++] = oInteger[x][1];
                                } else {
                                     var iValue = parseInt(value);
                                     if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
                                         if (i == 0) {
                                             focusField = field;
                                         fields[i++] = oInteger[x][1];
                                         bValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return bValid;
                function isAllDigits(argvalue) {
                    argvalue = argvalue.toString();
                    var validChars = "0123456789";
                    var startFrom = 0;
                    if (argvalue.substring(0, 2) == "0x") {
                       validChars = "0123456789abcdefABCDEF";
                       startFrom = 2;
                    } else if (argvalue.charAt(0) == "0") {
                       validChars = "01234567";
                       startFrom = 1;
                    } else if (argvalue.charAt(0) == "-") {
                        startFrom = 1;
                    for (var n = startFrom; n < argvalue.length; n++) {
                        if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
                    return true;
                }]]>
             </javascript>
          </validator>
          <validator name="long"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateLong"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.long"/>
          <validator name="float"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateFloat"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.float"
           jsFunctionName="FloatValidations">
             <javascript><![CDATA[
                function validateFloat(form) {
                    var bValid = true;
                    var focusField = null;
                    var i = 0;
                    var fields = new Array();
                    oFloat = new FloatValidations();
                    for (x in oFloat) {
                         var field = form[oFloat[x][0]];
                        if (field.type == 'text' ||
                            field.type == 'textarea' ||
                            field.type == 'select-one' ||
                            field.type == 'radio') {
                             var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                           value = field.options[si].value;
                                  } else {
                                       value = field.value;
                            if (value.length > 0) {
                                // remove '.' before checking digits
                                var tempArray = value.split('.');
                                var joinedString= tempArray.join('');
                                if (!isAllDigits(joinedString)) {
                                    bValid = false;
                                    if (i == 0) {
                                        focusField = field;
                                    fields[i++] = oFloat[x][1];
                                } else {
                                     var iValue = parseFloat(value);
                                     if (isNaN(iValue)) {
                                         if (i == 0) {
                                             focusField = field;
                                         fields[i++] = oFloat[x][1];
                                         bValid = false;
                    if (fields.length > 0) {
                       focusField.focus();
                       alert(fields.join('\n'));
                    return bValid;
                }]]>
             </javascript>
          </validator>
          <validator name="double"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateDouble"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.double"/>
          <validator name="date"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateDate"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           javax.servlet.http.HttpServletRequest"
                  depends=""
                      msg="errors.date"
           jsFunctionName="DateValidations">
             <javascript><![CDATA[
                function validateDate(form) {
                   var bValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
                   oDate = new DateValidations();
                   for (x in oDate) {
                       var value = form[oDate[x][0]].value;
                       var datePattern = oDate[x][2]("datePatternStrict");
                       if ((form[oDate[x][0]].type == 'text' ||
                            form[oDate[x][0]].type == 'textarea') &&
                           (value.length > 0) &&
                           (datePattern.length > 0)) {
                         var MONTH = "MM";
                         var DAY = "dd";
                         var YEAR = "yyyy";
                         var orderMonth = datePattern.indexOf(MONTH);
                         var orderDay = datePattern.indexOf(DAY);
                         var orderYear = datePattern.indexOf(YEAR);
                         if ((orderDay < orderYear && orderDay > orderMonth)) {
                             var iDelim1 = orderMonth + MONTH.length;
                             var iDelim2 = orderDay + DAY.length;
                             var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                             var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                             if (iDelim1 == orderDay && iDelim2 == orderYear) {
                                dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
                             } else if (iDelim1 == orderDay) {
                                dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
                             } else if (iDelim2 == orderYear) {
                                dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
                             } else {
                                dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
                             var matched = dateRegexp.exec(value);
                             if(matched != null) {
                                if (!isValidDate(matched[2], matched[1], matched[3])) {
                                   if (i == 0) {
                                       focusField = form[oDate[x][0]];
                                   fields[i++] = oDate[x][1];
                                   bValid =  false;
                             } else {
                                if (i == 0) {
                                    focusField = form[oDate[x][0]];
                                fields[i++] = oDate[x][1];
                                bValid =  false;
                         } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
                             var iDelim1 = orderDay + DAY.length;
                             var iDelim2 = orderMonth + MONTH.length;
                             var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                             var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                             if (iDelim1 == orderMonth && iDelim2 == orderYear) {
                                 dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
                             } else if (iDelim1 == orderMonth) {
                                 dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
                             } else if (iDelim2 == orderYear) {
                                 dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
                             } else {
                                 dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
                             var matched = dateRegexp.exec(value);
                             if(matched != null) {
                                 if (!isValidDate(matched[1], matched[2], matched[3])) {
                                     if (i == 0) {
                                         focusField = form[oDate[x][0]];
                                     fields[i++] = oDate[x][1];
                                     bValid =  false;
                             } else {
                                 if (i == 0) {
                                     focusField = form[oDate[x][0]];
                                 fields[i++] = oDate[x][1];
                                 bValid =  false;
                         } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
                             var iDelim1 = orderYear + YEAR.length;
                             var iDelim2 = orderMonth + MONTH.length;
                             var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                             var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                             if (iDelim1 == orderMonth && iDelim2 == orderDay) {
                                 dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
                             } else if (iDelim1 == orderMonth) {
                                 dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
                             } else if (iDelim2 == orderDay) {
                                 dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
                             } else {
                                 dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$");
                             var matched = dateRegexp.exec(value);
                             if(matched != null) {
                                 if (!isValidDate(matched[3], matched[2], matched[1])) {
                                     if (i == 0) {
                                         focusField = form[oDate[x][0]];
                                      fields[i++] = oDate[x][1];
                                      bValid =  false;
                              } else {
                                  if (i == 0) {
                                      focusField = form[oDate[x][0]];
                                  fields[i++] = oDate[x][1];
                                  bValid =  false;
                         } else {
                             if (i == 0) {
                                 focusField = form[oDate[x][0]];
                             fields[i++] = oDate[x][1];
                             bValid =  false;
                   if (fields.length > 0) {
                      focusField.focus();
                      alert(fields.join('\n'));
                   return bValid;
             function isValidDate(day, month, year) {
                 if (month < 1 || month > 12) {
                        return false;
                    if (day < 1 || day > 31) {
                        return false;
                    if ((month == 4 || month == 6 || month == 9 || month == 11) &&
                        (day == 31)) {
                        return false;
                    if (month == 2) {
                        var leap = (year % 4 == 0 &&
                                   (year % 100 != 0 || year % 400 == 0));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

    Next my struts-config.xml:That's all? What about an <action-mappings> section
    which specifies the action URIs and whether or not
    validation is turned on for specific ones?Whoops, sorry I forgot to put my action, although you just made me figure out the answer. I forgot I have 2 versions of the bean, one called Profile and one Called User, and I was trying to test the validation on the Profile bean while I was specifying the User bean :)

Maybe you are looking for