• 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

Struts2 + Validation + action.properties issue..

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont understand how Struts2 handle this basic problem, didnt find a conclusive answer

Example:- I have
- 1 simple Action CustomerAction.java ,
- CustmerAction.properties contains label key/values for username/password
- Customer.jsp with two textfield fields username/password,
- CustomerAction-Validation.xml , having a simple validation


Now if i give URI as http://somserver/CustomerAction.action , immediately validator framework is invoked and i see my page loading with 2 errors.. Instead i want my page to load first clean without invoking at Validator, so i create another action say DummyAction1, which redirects to Customer.jsp ... But Customer.jsp is fetching labels using <s:text ... > which are defined in CustomerAction.properties , and which is not invoked yet.. So i have to duplicate my same label keys in DummyAction1.properties and CustomerAction.properties.

Is this kind of duplication approach common in Struts2? How to get rid of? It is creating problem for every form, 1 for initial display, 1 after validation.. Is defining global properties only solution? I dont understand the use of Actionname.properties at first place, what Struts2 is trying to achieve when we have to duplicate keys in 2 different actions???Or i may be missing avery basic concept...correct me..
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Putting messages into an action-specific properties file is only one of several places messages can be store. As detailed in the localization docs you can keep shared messages in a package.properties file anywhere in the classpath, a superclass property file, or an application-wide property file.

The reason validation is being invoked immediately is because you're executing the action. If you example the default "workflow" interceptor configuration you'll see that it skips validation for a small set of action methods, including input(). If you don't want a validation failure to take you to the input page you need to use some mechanism to bypass the validation.
 
k pruthi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Putting messages into an action-specific properties file is only one of several places messages can be store. As detailed in the localization docs you can keep shared messages in a package.properties file anywhere in the classpath, a superclass property file, or an application-wide property file.

The reason validation is being invoked immediately is because you're executing the action. If you example the default "workflow" interceptor configuration you'll see that it skips validation for a small set of action methods, including input(). If you don't want a validation failure to take you to the input page you need to use some mechanism to bypass the validation.



Thanks i got the internationalization part and included everything in global..

Regarding validation problem, i want validation on an Action and dont want to skip that.. Here is scenario, let me explain again -it must be common problem for struts

Form1 -> Click Continue-> Action 1 invoked and validation done- > if all passed fwd to Form 2 -> On form 2 if i want to change language->i have to re-invoke Action 1 with request_locate = es -> Now validator is invoked again and expecting Form1 values to be posted again-> as Form1 fields are not there with this repost of action->it is redirecting to previous form (form1 ) with validation errors...
Please tell me how to solve this
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic