Zolf
asked on
Java error ClassCastException
Hello there,
what is wrong with this code. I get this error even though I cast it to Long or am I doing something wrong
java.lang.ClassCastExcepti on: java.lang.String cannot be cast to java.lang.Long
cheers
Zolf
what is wrong with this code. I get this error even though I cast it to Long or am I doing something wrong
java.lang.ClassCastExcepti
Users users = new Users();
users.setId((Long)dsRequest.getFieldValue("id"));
cheers
Zolf
Please post the class of which 'dsRequest' is an instance
ASKER
Hi CEHJ,
here you go
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/DSRequest.html
here you go
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/DSRequest.html
Looks pretty straightforward to me - getFieldValue() returns a String which you are trying to cast to Long, which can't happen.
MIght be just me but i don't see a method of that name anywhere
i agree with cehj
getfieldvalue method not found in dsrequest class
getfieldvalue method not found in dsrequest class
ASKER
java.lang.Object getFieldValue(java.lang.Ob ject fieldName)
Returns the value for a particular fieldName.
Returns the value for a particular fieldName.
ASKER
Krakatoa
it returns an Object and takes an Object which I am passing a String and trying to cast it to long
it returns an Object and takes an Object which I am passing a String and trying to cast it to long
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
java.lang.Object getFieldValue(java.lang.ObAnd the link to that method in the supplied javadoc is ..?ject fieldName)
Returns the value for a particular fieldName.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Show us the import statements from your code.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)