on 12-07-2006 11:17 AM
Hi,
I am trying to fetch images via Java Api.
Please look at the code below:
A2iValueArray imgs1 = null;
for(int y=0; y<rs1.GetRecordCount(); y++){
imgs1 = rs1.GetValueAt(y,"Product_Image").GetValueArray();
}
It is throwing me a Class cast exception.
I also tried
imgs1 = (A2iValueArray) rs1.GetValueAt(y,"Product_Image").GetValueArray();
but to no avail...
I am using MDM Sp04..
Please guide me...
Thank you for your reply..
I am using the code from that weblog only...
No idea why is it failing....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Walter,
The field is Multi-valued...
I am having the following code with me...
A2iValueArray imgs1 = new A2iValueArray();
for(int y=0; y<rs1.GetRecordCount(); y++){
if(!rs1.GetValueAt(y, "Product_Color").IsNull()){
imgs1 = rs1.GetValueAt(y,"Product_Color").GetValueArray();
int id = imgs1.GetValueAt(0).GetIntValue();
//int id = rs1.GetValueAt(0, "Product_Color").GetIntValue();
String imagePath = catalogCache.GetImagePath("Products", id);//"Thumbnail" ,
wdComponentAPI.getMessageManager().reportWarning("Your image is at: " + CACHE_DIRECTORY + "\" + imagePath);
break;
}
I get a ClasscastException at imgs1 = rs1.GetValueAt(y,"Product_Color").GetValueArray();
Really unable to understand why is Casting reqd in first place?
Any pointers will be appreciated...
Venkat,
I tried it with same output.....
I guess its same thing... if you look at your "var" variable and substitute it with the entire value... your code is completely similar to mine...
Moreover, if val is null or not initialised, it will throw a Null Pointer Exception...
While I am not too sure why is it throwing Classcast Exception...
This Code Worked for me:
try {
A2iResultSet rs1 = catalogData.GetResultSet(search, rsd, null, true, 0);
A2iValueArray imgs1 = new A2iValueArray();
for(int y=0; y<rs1.GetRecordCount(); y++){
if(!rs1.GetValueAt(y, "Images").IsNull()){
imgs1 = rs1.GetValueAt(y,"Images").GetValueArray();
int id = imgs1.GetValueAt(0).GetIntValue();
//int id = rs1.GetValueAt(0, "Product_Color").GetIntValue();
String imagePath = catalogCache.GetImagePath("Products", id);//"Thumbnail" ,
//wdComponentAPI.getMessageManager().reportWarning("Your image is at: " + CACHE_DIRECTORY + "\" + imagePath);
System.out.println("imagePath="+imagePath);
break;
}
}
catalogData.Logout();
} catch (StringException e) {
e.printStackTrace();
}
Posting your program may help troubleshoot.
--
Venkat
Hi,
Go thru this link.
/people/walter.kahn/blog/2005/12/29/mdm-55-api-tips-and-tricks--image-retrieval
Regards,
Sridhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.