Hi James, I think you need to figure out why $bo->getValue("id_number") is returning an empty value. Is that method something you've written in Java code?
-Ken > -----Original Message----- > From: James Mancz [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 14, 2005 2:05 PM > To: inline@perl.org > Subject: Inline Java and casting from Object to String > > Hi > > I'm trying to use Inline-Java 0.50, and I am having a problem. > > I have a class instantiated, the class has a method that > returns an Object. > In Java, I'd have to cast the Object to a String: > > String id = (String) bo.getValue("id_number"); > > In Perl, I would do something such as this: > > my $id = $bo->getValue("id_number"); > > However, this always leaves $id empty. > > So, I've tried the 'cast' function. > > If I try (i.e. cast the object): > > my $id = cast('java.lang.String', $bo)->getValue("id_number"); > > I get the error: > > Can't cast a Generic to a java.lang.String > > And if I try (i.e. cast the result): > > my $id = cast('java.lang.String', $bo->getValue("id_number")); > > I get the error: > > Type casting can only be used on Java objects. Use > 'coerce' instead. > > But the documentation around coerce suggests that isn't what I need. > > What am I doing wrong here? > > Thanks, > James > >