About the Java Listing

Asked 2 years ago, Updated 2 years ago, 31 views

I am making a list to fill out the form.

The flow first defines the form of the business form.
A key and a value corresponding to the field of the business form are then registered (this time the input is in the field of the business form).
After registering the key value several times, add it to the list as one record.
I'd like to repeat this and fill out the form.

public class ReportInfoBuilderBean{
    // Store business form ID here
    private String reportId;
    // I want to store a list of each business form ID here    
    private List <map>reportInfoList; 

    // Setter getter omitted
}

public class ReportInfoBuilder{
    // I will make a record of the business form here
    private List <Object>reportInfoList=newArrayList<Object>();
    private List<Map>recordInfoList=new ArrayList<Map>();
    private Map<String, String>map=new LinkedHashMap<String, String>();
    private ReportInfoBuilderBean reportInfoBuilderBean=new ReportInfoBuilderBean();

    // Add business form (add business form ID)
    public void addReport(String reportId){

        reportInfoBuilderBean.setReportId(reportId);
        recordInfoList = new ArrayList <Map>();

    }
    // Add Key Value
    public void addValue(String reportKey, String value) {

            map.put (reportKey, value);
            System.out.println("map:"+map);

    }
    // Add key value to one record
    public void writeRecord() {

        recordInfoList.add(map);
        map = new LinkedHashMap<String, String>();
        reportInfoBuilderBean.setportInfoList(recordInfoList);
    }
}

At this stage, it looks like this, but at this stage, the recordInfoList is new every time the business form ID is added and changed, so I can't make a list for each business form ID.

However, there is nothing I can do if I lose the recordInfoList=newArrayList<Map>(); method.

I would like to create a list for each business form ID.

Example)

Add ReportA
map.put(A, Test 1);
map.put(B, test 2);
map.put(C, test 3);
reportInfoList.add(map);
map.put(D, test 4);
map.put(E, test 5);
reportInfoList.add(map);
Added ReportB
map.put (BA, test 2_1);
map.put (BB, test 2_2);
map.put(BC, test 2_3);
reportInfoList.add(map);
map.put(BD, test 2_4);
map.put(BE, test 2_5);
reportInfoList.add(map);

So
ReportA and

with two records: Tests 1-3 and Tests 4-5

I would like to create a ReportB with two records: Tests 2-1-2_3 and Tests 2-4-2_5.
What should I do?

I thought I could put it in Bean and call it out, but as I said before, I can't do it well because of the timing of initialization.
Please tell me who it is.

java

2022-09-30 16:50

1 Answers

Why don't you just create a Report class and new an instance of the Report class for each ReportA, ReportB...


2022-09-30 16:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.