Looking for information of how to loop through a composition list in a GroupTable

Hello,

I’m not sure what to search the Developer’s Manual for, but this is what I need to do:

I’m using ExportDisplay to create a document of a Screen for printing. I didn’t see a way to do this more elegantly, so I’m gathering all the data from the Screen and creating a display to feed to the Browser using ByteArrayDataProvider.

In a browse screen, I created a button for printing the selected instance. In the Controller, I’m calling:

Job job = jobsTable.getSingleSelected();

Then I’m extracting the data using something similar to:

String client = job.getClient().getClientName();

But then I have a Composition table that I need to loop through called Notes.

I tried:

List notes = job.getNotes();

I set this to type List because that’s what the error suggestion provided as the type.

Then I tried to extract the data the following way:

for (Object note : notes) {
noteType = note.getNoteType();
}

But this isn’t an option to select.

I’m just looking for a way to do this, and wasn’t successful in searching the Developer’s Manual.

Thanks for any help you can provide!

Hi!

For exporting data from tables you can use Excel action. How it works you can see in Sampler: link.

If you need to export more complex data, I can suggest you take a look at Report add-on.
Report add-on in the marketplace and documentation.

I’m afraid that might not work for what I need to accomplish, well, the Excel action, anyway, as the requirement is to print the entire Job form screen, including the Tax Form Details entries from the Composition.

I had attempted to work with the Report add-on from the marketplace, but it’s producing errors when attempting to select a Template. Given the tight deadline I’m on, and the fact that the print requirement needs to be a table action button from the Jobs Browse screen, this is what I had to do, actually manually selecting all the data from the saved Job and composition tables.

Is there a way to do this? I just need to pull the composition fields by looping through them.

Thanks in advance!

In fact, I think the main issue that I’m facing is that this is on the Job Browse screen, which includes the jobsDc data container, but the job.getNotes() expression pulls a detached object (TaxFormDetails data). There’s got to be a way to get this information from the job instance.

When I run:

List notes = job.getNotes();
for (Object note : notes) {
html = html.concat(note);
}

And then pass that data to the ByteArrayDataProvider, the output lists:

com.company.hermes.entity.Note-85 [detached]

When you concat an entity object then the toString() method is invoked, which is overridden in BaseGenericIdEntity, so you see given output.
If you want to show in the output some fields which are provided by View in the data container, you need to get them manually, like note.getName() and so on.

Thank you for replying…

But you’re hitting on the issue I’m experiencing. note.getNoteType() (or anything really) isn’t an option.

06%20AM

The following is how I’m setting the notes list, because I wasn’t sure how else to get it:

04%20AM

I needed to loop through that list of notes, and initially tried the following:

46%20PM

Doing it this way (despite the obvious issue with incompatible types), I DID have the option to get the data as it’s recognized as being of the Note class…

46%20PM

But, the incompatible types thing is an issue, so I can’t do it that way. And now we’ve come full circle. There has got to be a way to get this data.

Thanks in advance for looking into this for me!

Hi,

You should define the list of notes as: List<Note> instead of just List (line 146). This way the compiler understands what you mean and will accept that code snippet.

IntelliJ also wants to give you that hint (see the light bulb icon). You can either click on it or use ALT+ENTER.

Cheers
Mario

1 Like

Thank you SO MUCH, Mario! I’m so happy there was such a simple solution. This is a big thing I’m learning (syntax and procedures) still. You are appreciated!