Win a copy of Securing DevOps this week in the Security forum!

Krishan Babbar

Greenhorn
+ Follow
since Aug 30, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Krishan Babbar

I am using Struts2.

I would like to trim the values submitted in any form before validations and before saving in DB.
Is there any inbuilt feature for the same?

Thanks
Krishan Babbar
7 years ago
Hi,

I am using struts2 and annotations for validations.

In my form, when i put following text in any textbox and say validation gets failed then same form display again but the textbox (Where I entered following text) shows wrongly, i mean text box shown with prefilled text "cross script <input type=" and other text (Airplane" type="text" class="txtbox" id="company.name" maxlength="255" />) next to textbox.

"cross script <input type="radio" name="vehicle1" value="Airplane"> Airplane"

Any inbuilt way in struts2 to escape special characters and quotes so that it should not disturbed the form and its values in case of server side error in saving the data in DB?

Thanks
Krishan Babbar
7 years ago
I am using annotations for validations in my struts2 based application. I want to allow the spaces between company name to user. I was trying following expressions but these are not working... Please let me know what symbol should I use in expression for allowing spaces:

@RegexFieldValidator(fieldName = "company.name", expression = Constants.COMPANY_NAME_EXPRESSION , key = "errors.company.name.format", message = "errors.company.name.format"),

where i tried following for COMPANY_NAME_EXPRESSION

String COMPANY_NAME_EXPRESSION = "^([a-zA-Z0-9@_.-
s]+)$"
and
String COMPANY_NAME_EXPRESSION = "^([a-zA-Z0-9@_.-\\\\s]+)$"

Thanks
Krishan Babbar
7 years ago
Hi,

I am using Struts2. I am doing validations using annotations in action class.
I have many forms having same type of fields say zip code.

I am adding validations like below in each action class having zip code field



Now, in case if I need to change the expression for zip code validations, then I need to modify the same in each action class.
I would like to know if there is any way to use java variable or property for expression so that i only need to change at one place (value of variable) and all actions get modified.


I want something like below



Thanks
Krishan Babbar
7 years ago
What you did to resolve locale switching?
7 years ago