• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Validation.xml....need some help

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I wanted to validate a input text field.
I am using validation.xml to do this.
This is what i have written in my validation.xml



This works fine.But the problem is,i should not get the error message once the page is loaded .I should get it only when i hit the submit button.
How should i modify my validation.xml to do this.I should basically put
some check to see whether the submit button is hit or not.
Any help will be really useful.
Thanks.
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Override the validate method and return null if the your submit button is not present in the request or is null(if present as a form parameter). If the submit button is pressed, return super.validate(arg0, arg1)

For e.g.
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.But when we are using the validation framework do we need to override the validation()..???
 
Zip Ped
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont see the harm in overriding the validation method for the question you asked.

Alternatively, If you have two action classes - one when the page first loads(ViewAction class) and the other for submitting or CRUD operations(UpdateAction class) then you can set the validate="false" for the first class.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No change needs to be done on the validation.xml. You need to have 2 actions in your struts-config.xml file.

For example:

<action path="/WhenPageLoad"
type="person.employee"
name="employee"
scope="request"
validate="false"
input="empl.page"
parameter="dispatch">
<forward name="nextScr" path="empl.page"
contextRelative="true"/>
</action>


<action path="/WhenSubmitClick"
type="person.employee"
name="employee"
scope="request"
validate="true"
input="empl.page"
parameter="dispatch">
<forward name="nextScr" path="empl.page"
contextRelative="true"/>
</action>

The validate="false" makes it by pass validation on page load.

Luke.
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.I have only one Action class thats the problem....However i have modified my validation.xml this way.


But now i am getting the following error.



what i am all doing is setting a property value to true when the submit button is clicked.Then i am checking that in my validation.xml.
Any suggestion is most welcomed.
Thanks

[ July 10, 2006: Message edited by: meena latha ]
[ July 10, 2006: Message edited by: meena latha ]
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry the error got resolved .The problem was the the end tag for <var-value> was </var-name>.But the validation is not carried out.
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all.It is working.I modified the validation.xml .
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic