• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Problems with Validator Framework

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am fairly new to Struts and having some issues with the Validator.
I am trying to use invoke the Javascript validation but it does not seem to pick it up.

I have referred thearticle on this forum and it works for one of my forms but seems to fail in the second form.

Any ideas???
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post more details about the scenario, so that the problem can be identified
 
Suzi Cooper
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code :
JSP page
----
----
<HTML>
<HEAD><TITLE><bean:message key="title.login" /></TITLE>
<html:javascript formName="deptEditForm" />
</HEAD>
---
<html:form action="deptEdit" onsubmit="return validateDeptEditForm(this)">
.........

#################
validation.xml

<form name="deptEditForm">
<field
property="department_id"
depends="required">
<arg0 key="hr.account_maintenance.departmentId"/>
<var>
<var-name>field</var-name>
<var-value>department_id</var-value>
</var>
</field>
</form>

########
struts-config.xml

<action
attribute="accountDetailsEditForm"
input="/pages/hr/accountEdit.jsp"
name="accountDetailsEditForm"
path="/accountDetailsEdit"
scope="request"
parameter="do"
type="com.fbbt.matador.mweb.hr.AccountDetailsEditAction"
validate="true">
<forward name="showAddAccount" path="/pages/hr/accountEdit.jsp" />
############
I have multiple buttons on the form---add &mode.IF i click on ADD,it loads the page but does no validation on Submit.
the bean deptEditForm extends ActionForm.If i change it to ValidatorForm it loads the same page in the edit mode.

Hope this helps!
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this link helps:
http://struts.apache.org/userGuide/dev_validator.html

I also have an pdf file which mentions that:


You can�t use the standard Struts ActionForm class with the Validator.



You will have to use ValidatorForm for validating.

If i change it to ValidatorForm it loads the same page in the edit mode.



To specify a page to be displayed in case of validation errors you need to specify an value for the attribute 'input' for the action in your struts-config.xml as follows:


<action.....

validate = "true"
input = "/errorPage.jsp">

I wanted to mail to you the pdf file, but could not find your id
 
Suzi Cooper
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
I did manage to fix it.The code worked fine, it was only jboss trouble.
I would really appreciate if u could mail me the pdf file @ suzi_403@rediffmail.com

Cheers
 
I want my playground back. Here, I'll give you this tiny ad for it:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic