3 replies [Last post]
HoSpiTaL_gHoSt
Offline
Joined: 2010-07-02

Hi,

I have a problem when I want to populate my template using an arraylist. It doesn't respond how I expect it to.
This is my template, I marked all the fields between * *:

*rs_personen*

Naam: *naam*
Voornaam: *voornaam*
Geboortedatum: *geboortedatum{renderer=date('dd/MM/yyyy')}*
Gemeente: *gemeente*

*es_personen*

In my Java code I added the following arraylist:


Persoon pers = new Persoon();
pers.setNaam("a");
pers.setVoornaam("b");
pers.setGeboortedatum(myDate);
pers.setGemeente("c");

Persoon pers2 = new Persoon();
pers2.setNaam("d");
pers2.setVoornaam("e");
pers2.setGeboortedatum(myDate2);
pers2.setGemeente("f");

List personen = new ArrayList();
personen.add(pers);
personen.add(pers2);

dpb.addJavaObject(personen);

This works perfectly as it is, the section is rendered twice (because there are 2 persons) with the correct data, but I would like to name the arraylist, because if I have a template with 2 arraylists, I have to be able to distinguish between the two arraylists. So I tried this:

dpb.addJavaObject(personen,"personen"); which should, as far as I understood, refer to rs_personen.

But this is the result I get. I only get this section rendered once, and for each field, 2 Persoon objects get rendered:

Naam: [Persoon@1f6ba0f, Persoon@1313906]
Voornaam: [Persoon@1f6ba0f, Persoon@1313906]
Geboortedatum: 23/01/1986[Persoon@1f6ba0f, Persoon@1313906]
Gemeente: [Persoon@1f6ba0f, Persoon@1313906]

Could anyone tell me how to solve this?
Thanks in advance!

modman
Offline
Joined: 2010-11-25
You've hit a bug

Hello HoSpiTaL_gHoSt.

You've hit a bug in Docmosis to do with naming Java Objects. There are several work-arounds applicable, but the easiest is to add a dummy indirection to your "rs_personen" tag in your template:

*rs_personen.x*

This is expected to be fixed in the next release of Docmosis due out early November.

HoSpiTaL_gHoSt
Offline
Joined: 2010-07-02
Thanks

Thank you! That works really nicely.
I'm glad it's a bug and it wasn't me not understanding something, because I had tried almost everything lol.

admin
Offline
Joined: 2010-09-06
Corrected in Docmosis 2.1.0

Hello HoSpiTaL_gHoSt.

Docmosis 2.1.0 has been released. This now behaves as you expect.