dbarra / xdocreport

Automatically exported from code.google.com/p/xdocreport
1 stars 0 forks source link

dynamic image inside for each loop #255

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I want to put dynamic image inside for each loop.

How can I achieve this?

Thanks,
Priyanka

Original issue reported on code.google.com by davepriy...@gmail.com on 7 May 2013 at 6:48

GoogleCodeExporter commented 8 years ago
Hi Priyanka,

Yes it's possible. You manage that like loop for text field (see 
https://code.google.com/p/xdocreport/wiki/DocxReportingJavaMainListFieldAnywhere
) Replace ${developer.name} by your dynamic image (see 
https://code.google.com/p/xdocreport/wiki/DocxReportingJavaMainDynamicImage)

Yoiu can find sample in the samples zip (ex: 
DocxProjectWithFreemarkerAndImageList)

Regards Angelo

Original comment by angelo.z...@gmail.com on 7 May 2013 at 7:32

GoogleCodeExporter commented 8 years ago
Hello Angelo,

Thanks for your help.

I have try in the same way how it is specified in example.But it is not
working for me.Return type of photo fields in my model is byte[].

This is how I have added it.
List clientAuthorisedPersonList =
UtilDAO.getClientStaffMasterDAO().findAuthorisedByClientId(instance.getClientId(
));
fieldsMetadata.addFieldAsList("clientAuthorisedPersonList.photo");
fieldsMetadata.addFieldAsImage("photo", "clientAuthorisedPersonList.photo");

Original comment by davepriy...@gmail.com on 8 May 2013 at 6:57

GoogleCodeExporter commented 8 years ago
What do you mean with "not working"? 

Please attach your dox+java code.

Regards Angelo

Original comment by angelo.z...@gmail.com on 8 May 2013 at 8:13

GoogleCodeExporter commented 8 years ago
Hello,

Please find attached java document and docx file.

I am getting  Invocation of method 'registerImage' in  class
fr.opensagres.xdocreport.document.docx.images.DocxImageRegistry threw
exception fr.opensagres.xdocreport.core.XDocReportException: Image provider
for field [photo] cannot be null! exception though I have image stored for
person.

In DTO return type of getPhoto() method is byte[].

Original comment by davepriy...@gmail.com on 8 May 2013 at 12:38

GoogleCodeExporter commented 8 years ago
Hi,

I cannot find your attached files?

Original comment by angelo.z...@gmail.com on 8 May 2013 at 1:26

GoogleCodeExporter commented 8 years ago
Hello,

I am attaching files again.

Thanks,
Priyanka

Original comment by davepriy...@gmail.com on 9 May 2013 at 6:46

Attachments:

GoogleCodeExporter commented 8 years ago
I think your problem is that you use custom #foreach (in my sample I loop for a 
table)
and I use fielsmetadata to set the photo as list. In your case you use 
#foreach, so you must not set it ad list in the metadata. So you must remove 
line :

--------------------------------------------------------------------------------
----
fieldsMetadata.addFieldAsList("clientAuthorisedPersonList.photo");
--------------------------------------------------------------------------------
----

Regards Angelo

Original comment by angelo.z...@gmail.com on 9 May 2013 at 7:25

GoogleCodeExporter commented 8 years ago
Hello Angelo,

I have removed that line but still image is not coming in generated output.

Do I have to keep below line?

fieldsMetadata.addFieldAsImage("photo", "clientAuthorisedPersonList.photo");

Also how can I replace photo from list?I have simply put list of object in
context.

context.put("clientAuthorisedPerson", clientAuthorisedPersonList);

Original comment by davepriy...@gmail.com on 9 May 2013 at 10:11

GoogleCodeExporter commented 8 years ago
Hi,

Have you tried to set a breakpoint debug in your getter getPhoto? If it works, 
are you sure that it doesn't return not null (for each item)?

Regards Angelo

Original comment by angelo.z...@gmail.com on 9 May 2013 at 11:29

GoogleCodeExporter commented 8 years ago
Hello Angelo,

Yes It is not returning null value.In my data model return type of
getPhoto() method is byte[]..Is it creating any problem or this will work
with byte[]?

Original comment by davepriy...@gmail.com on 9 May 2013 at 11:38

GoogleCodeExporter commented 8 years ago
So you tell me that 

1) your getPhoto is called with velocity engine
2) yout getPhoto doesn't return null.
3) you are using 1.0.0

and it doesn't work.

If it that I will study the problem.

Regards Angelo

Original comment by angelo.z...@gmail.com on 9 May 2013 at 11:51

GoogleCodeExporter commented 8 years ago
wait a minute.

Your mapping with image should be like this :

----------------------------------------------------------
fieldsMetadata.addFieldAsImage("photo", "c.photo");
----------------------------------------------------------

Original comment by angelo.z...@gmail.com on 9 May 2013 at 11:54

GoogleCodeExporter commented 8 years ago
Hello Angelo,

It works perfectly.

Thanks for your time....:)

Original comment by davepriy...@gmail.com on 9 May 2013 at 12:58

GoogleCodeExporter commented 8 years ago
Ok that's cool, I close this issue.

Original comment by angelo.z...@gmail.com on 9 May 2013 at 12:59

GoogleCodeExporter commented 8 years ago
ok

Original comment by davepriy...@gmail.com on 9 May 2013 at 1:01

GoogleCodeExporter commented 8 years ago
cleanup

Original comment by pascal.leclercq on 10 Oct 2014 at 7:37