Olaru Mircea
Olaru Mircea

Reputation: 2620

Get query in controller

I have these two versions of getting the query in my controller class,

prePromptModifyContract method:

this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey())

and

this.getFirstQuery()

There is a strange mélange in here, my query is added as an attribute to the Data Provider class together with the temp table. In processReport method the query is executed but the range is set only in the controller, so ... what is the exact flow and how the controller gets a reference to the query using the above highlighted lines?

And one more thing, what's the difference between the aforementioned method calls? They work both at the moment but is there any reason I should use one over the other?

Upvotes: 0

Views: 1770

Answers (1)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

The second question first, the methods should give the same result, except for some error testing, so prefer getFirstQuery!

How to see that? Read the code:

protected final Query getFirstQuery()
{
    Query firstQuery;
    Map   queryContractsMap = this.getReportContract().parmQueryContracts();
    str   firstQueryKey = this.getFirstQueryContractKey();    
    if (queryContractsMap && firstQueryKey && queryContractsMap.exists(firstQueryKey))
        firstQuery = queryContractsMap.lookup(firstQueryKey);
    return firstQuery;
}

I am not sure what you mean by the first question, the exact flow.

But, as a user, you can change the query in the prompt. The query in processReport should be the one provided provided by the user.

The query in prePromptModifyContract is the saved query from the last run of the job (or the initial query, if never run). You have the option to change some ranges or whatever, before the user sees the query.

Upvotes: 1

Related Questions