Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, this is code which I have written. for this code I need to add a image. So how do it.
Actually I tried in one manner. But its accepting as a string so please help in this.
Java
String units;
for (Object object : list) {
	LiveParam liveParam = new LiveParam();
	Object data[] = (Object[]) object;

	// liveParam.setPramCode(data[0].toString());
	liveParam.setPramDispName(data[0].toString());

	// because of UI use issues i make it this
	double parValue = Double.parseDouble(data[1].toString());

	int iValue = 0;
	units = data[5].toString();
	if ((parValue * 100) % 100 == 0) {
		iValue = (int) parValue;
		if (units.equals("STATUSONOFF")) {
			if (iValue == 0) {
				liveParam.setPramValue("<img src='images/off.gif'/>");
				liveParam.setUnits("OFF");
			} else {
				liveParam.setPramValue("<img src='images/on.gif'/>");
				liveParam.setUnits("ON");

			}
		} else if (units.equals("STATUSYESNO")) {
			if (iValue == 0) {
				liveParam.setPramValue("<img src='image/off.gif'/>");
				liveParam.setUnits("NO");
			} else {
				liveParam.setPramValue("<img src='image/on.gif'/>");
				liveParam.setUnits("YES");
			}
		} else {
			liveParam.setPramValue(iValue+"");
			liveParam.setUnits(units);
		}
	} else {
		liveParam.setPramValue(parValue + "");
		liveParam.setUnits(units);
	}

	

	liveParam.setPramType(data[2].toString());
	liveParam.setTimestamp(Utility.getFormattedTimeStamp(
			(Timestamp) data[3], Constants.DATE_TIME_FORMAT));
	liveParam.setCommunicationMedia(data[4].toString());
	liveparamList.add(liveParam);

}

In the above code I have added images. But its accepting as string. I'll be waiting for your answer
Posted
Updated 1-Feb-12 23:17pm
v6
Comments
Sergey Alexandrovich Kryukov 2-Feb-12 0:34am    
What is the problem?
--SA
Sergey Alexandrovich Kryukov 2-Feb-12 0:38am    
I added the "pre" tag and minor fixed, but code is shifted to right. Please fix it. Make the clear question.
--SA
rohitVasu 2-Feb-12 1:32am    
Hi SAKryukov, if you go through the above code. there i'm setting PramValue as image using HTML tag. But its accepting as a string and i tried to paste o/p which i'm getting.But its not getting paste. So please help me.
rohitVasu 2-Feb-12 1:09am    
Hi SAKryukov, if you go through the above code. there i'm setting PramValue as image. But its accepting as a string and the output that i'm getting is shown in above my question
rohitVasu 2-Feb-12 1:12am    
Hi, i can't able to paste the snapshot of that output.

1 solution

I guess you are not addressing the images right. You are using relative paths, which is often not valid. Try to get the complete, absolute path and try that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900