Pawan Kalyan

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

Recent posts by Pawan Kalyan

I cant do bean.getDateOfBirth() becasue i am using this code in a common method to get values from bean and to set those values on other bean which have same variable names and types using reflection. thats why i was trying to see if there is any other way to get a property value of a java bean in Object or Calendar value if the property type is Calendar.

I hope i didnt confuse you and understand my condition.

Please Let me know if there is any other way.
9 years ago
using System.out.println(value) to see what was in that value.
9 years ago
I am trying to do

Then i get the following error

java.lang.String incompatible with java.util.Calendar

And when i looked into BeanUtils API, it says that using BeanUtils.getProperty or BeanUtils.getSimpleProperty() will return the value in String format thats why when i type cast the value to Calendar it throws a run time error.
9 years ago

I am unable to get the value of a property inside a bean which is of type Calendar in Calendar format.

I am currently using BeanUtils (org.apache.commons.beanutils.PropertyUtils) to get the property value but it returns the value as string, which i am unable to type cast to Calendar.

If i print out the value then it looks something like,


Is there a way i can get the value in Calendar format or convert the above string into calendar format ?

9 years ago
because i have getter and setter methods for that variable and i guess BeanUtils does work on getter methods but not sure if does expect the method names in a particular way like first letter should be in lower case or 2nd letter should be lower case etc etc..
9 years ago
are there any rules or specifications to name java class variables which are compatible for BeanUtils.getProperty like the first x number of letters should be in lower case etc etc.. ?
9 years ago
PropertyUtils is from org.apache.commons.beanutils.PropertyUtils. I have the variable name as iPANCardNumber and there are a bunch of beans with variable names similar to iPANCardNumber and i cant change the case of all those variables.

Hope that helps.
9 years ago
Hi ,

I am trying to use reflection to get a property value from a bean using and is working fine for most of the variables.

but i am getting a run time error for few variables like etc.

Exception in thread "main" java.lang.NoSuchMethodException: Unknown property 'iPANCardNumber' on class 'class com.Person'

I was wondering if PropertyUtils doesnt like the variables with firs letter in lowercase and the next letter in upper case and wanted to get some help in this regard.

Please let me know if anyone needs more info regarding my problem and appreciate your help here.
9 years ago
No, i am trying to write a custom class which will override BeanUtils.populate() and write my own login to take care of the Map to Bean copy so that no matter what will the case of the starting letter of the key in the map my populate() method will copy the keys/values to the bean so that i dont have to deal with duplicate or second map to handle the scenario.

Sorry my scenario looks like a small deal but its different here. I am storing the map and its been used somewhere else too thats the reason i am not willing to format the case of the map keys and i cant use 2 maps as my service prodived might add/remove few variables in their response and its makes a lot of effort to change it in 2 places.

Anyways thanks for your inputs, i am looking at something else to overwrite Beanutils.populate and see if that works so that it can be a perfect solution.
Yeah, i can do that but it has impact to other consumers of my service that they need to modify the way they can extract the map contents and all my consumers need to know that they have to use a key string starting with lower case when they are extracting contents from the map and that raised a question that its not the efficient way to manipulate the xml response by altering it case and storing it in a map so i was looking if there is any other way to override the BeanUtils.populate functionality and write my own class on top of it so that it will take care of all the case sensitivity issue and dont worry about altering the case of the map key string while extracting the xml response and save it in the map.

You are correct Paul, i am getting an xml from a different service which always gives me properties beginning with upper case and i am converting the xml to a hashmap and then trying to copy it over a bean. I am not sure if i can format the xml response to change the first char to upper case as its involves some permissions so i was trying to see if there is any other way i can copy my map contents over a bean with my situation.

I am having a problem with populating a Java Bean( with 4 fields) contents from a map which has 4 key, value pairs while using apache BeanUtils.populate(bean,map) that when my map has a key with upper case string then my bean is not getting populated and i guess its because of Java reflection that BeanUtils.populate() uses and expectes the first letter of every map key should begin with a lower case letter and i am wondering if there is any fix for my problem.

Here is the sample code

And when i say

i get null. But when the map key starts with lower case then the value is copied from the map to bean using BeanUtils.populate().

How can i copy the map contents to my bean if the keys in the map start with upper case and i cant change that as my service is providing the xml in that format and i am converting the xml to HashMap and then using that to copy the contents to a bean.

Appreciate your suggestion and guidance.
Hi All,

I have been using Struts 2 JSON client validation for a long time in IE and it works fine but when i open firefox browser it pops me a javascript popup with error message like "Could not validate: form_name" where name is my form variable.

Here's the code.

JSP Code:

struts.xml code:

validation.xml code:

Can someone help me in dealing with JSON validation in Firefox without any java script pop up messages

Pawan Kalyan
12 years ago