Skip to main content
1-Visitor
September 23, 2014
Question

return value for string wrong(java api)

  • September 23, 2014
  • 1 reply
  • 2407 views

Hi

I´m trying to retrieve an value from a class and returning a string value in to another class.

The return value is not a string it´s returning the class name and an object id.

Class IBAHandler

public class IBAHandler {
public String s;
public String obj;

public String IBAHandler() throws WTException {
//this.changeOrder = co;
wt.fc.ReferenceFactory rf = new wt.fc.ReferenceFactory();
wt.fc.WTReference ref = rf.getReference("VR:wt.change2.WTChangeOrder2:9049460");

wt.fc.Persistable obj = ref.getObject();

String s = obj;

return s;
}

Class RetriveHandler

if (workshops != null) {

IBAHandler workshops = new IBAHandler();

this.workshops=s;

} else {

workshops="Workshops not set";

}

(return workshops: ext.itt.www.productService.IBAHandler@231ef93)

Regards

1 reply

12-Amethyst
September 23, 2014

Hi Ann,

workshops is the name of the variable of IBAHandler type not String type.

So, if you print workshop you will get the fully qualified package name along with the hashcode.

Its a fundamental java property.

If you want to get the value of the String s of IBAHandler.

Then print workshop.s insted of only workshop.Better if you use getter method to access the variable.

Thanks,

Kaushik

1-Visitor
September 23, 2014

Hi

Thanks, I´m new, so I´m probably missing the basics. Right now it´s try and error.

I have tried with your suggestion and get/set method, but received only an null value.

I´ll try again, never give up never surrender

Thanks again

12-Amethyst
September 24, 2014

Hello,

What is your objective actually ?

You want to pass the Change Order name ?

I am not sure how your code is running cause it should give you class cast exception in following lines.

wt.fc.Persistable obj = ref.getObject();

String s = obj;

Thanks,

Kaushik