• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validation problem

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

I have a question concerning the way of doing a validation.

I have an action and the input and the response jsp (view) are the same file.
Depending on the selection the jsp page shows in the same form based on a if-else statement a list and an edit mode. But I want to validate the fields in the edit mode.
Only I have a problem, I want to validate these fields if they are empty or not. But the action tries to validate these fields also when the view is in "list mode" and nothing else happens because the fields are of course empty (because they are not represented anymore)
To validate an action there are 2 methods: in a xml file or in a validate method.
I have tried with both but the effect is the same.

Can I accomplish this?
If yes, how?

Many thanks
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Liviu Mitrofan:


I have an action and the input and the response jsp (view) are the same file.



Your action is different file , I guessed !

Originally posted by Liviu Mitrofan:

Depending on the selection the jsp page shows in the same form based on a if-else statement a list and an edit mode. But I want to validate the fields in the edit mode.



If you are listing only then there is no need to take them in <html:form tag with <html:submit > button , which validate the fields , simple print them in table or put them in FORM w/o SUBMIT button ! But If you want to edit them you need this field value in <html:form> tag (with validations )!

Is that sounds OK ?
 
Liviu Mitrofan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sagar Rohankar:


If you are listing only then there is no need to take them in <html:form tag with <html:submit > button , which validate the fields , simple print them in table or put them in FORM w/o SUBMIT button ! But If you want to edit them you need this field value in <html:form> tag (with validations )!

Is that sounds OK ?



The action is in its file AdministrationCampanyAction.java.
Yes, I want also the list in the form, because the list is in a table form. One can filter the rows based on a column clicking the column header or he can select a row and after that press edit button.
All are very nice generated by Struts2. But the problem is: The action tries to validate the fields from the edit mode even when this is not shown.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I`m not getting your need exactly, If you want the "list" data into FORM, then simplest way I thought is , display the FORM FIELDS with data w/o <html:submit> tag, so that validation doesn't trigger , But when you want the row to be "EDITED" , just put all the data into FORM FIELD with <html:submit> button !

Its looks something like this :
 
reply
    Bookmark Topic Watch Topic
  • New Topic