Kbase 15821: Using request-attribute to change a SmartQuery at Runtime
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Using request-attribute to change a SmartQuery at Runtime
INTRODUCTION
============
This knowledgebase entry describes one way to have
information the user enters into a SmartViewer at runtime
determine and change the WHERE clause of a SmartQuery.
PROCEDURAL APPROACH
===================
Consider the following example:
A SmartWindow contains a SmartQuery for orders and a
SmartViewer which displays order information. The
SmartWindow also contains a SmartViewer which contains two
fields which represent order date range. This SmartViewer
also contains a button, which when chosen will open the
query for only those orders whose order dates fall within
the date range entered by the user.
The above can be accomplished with the following steps:
1) Create a SmartViewer which contains two fill-in fields,
fr-date and to-date and a button, chg-query.
The trigger code for choosing the button will set
attributes for the two dates and will re-open the
SmartQuery.
ON CHOOSE OF chg-query DO:
RUN set-attribute-list
(INPUT "FROM-DATE=" + fr-date:screen-value +
",TO-DATE=" + to-date:screen-value).
RUN notify IN THIS-PROCEDURE
('open-query, DATELINK-TARGET':U).
END.
DATELINK is the user-defined link between this SmartViewer
and the SmartQuery which is where the open-query needs to
be run to re-open the query with the new criteria (order date
range) the user has entered.
2) Create a freeform SmartQuery which contains the
following OPEN_QUERY trigger code:
def var fr-date like order.order-date.
def var to-date like order.order-date.
RUN request-attribute IN adm-broker-hdl
(INPUT THIS-PROCEDURE,
INPUT "DATELINK-SOURCE",
INPUT "FROM-DATE").
fr-date = DATE(RETURN-VALUE).
RUN request-attribute IN adm-broker-hdl
(INPUT THIS-PROCEDURE,
INPUT "DATELINK-SOURCE",
INPUT "TO-DATE").
to-date = DATE(RETURN-VALUE).
OPEN QUERY Query-Main FOR EACH Order WHERE
Order.Order-Date >= fr-date AND
Order.Order-Date <= to-date NO-LOCK.
The request-attribute method procedure gets the
attributes set from the link establised to the SmartViewer.
The attributes are then used to open the query for the
date range entered by the user.
3) A user-defined link needs to be set up in the
SmartWindow with the following steps:
a) Go into SmartLinks and choose Add to add a link
b) Choose the SmartViewer that contain the date range as
the link source
c) Click on New and type in DATELINK as the New Link Type
d) Choose the SmartQuery as the link target
When run, the user will have the ability to enter an order
date range and only those orders that fall within that date
range will be available to navigate through in the SmartQuery.
REFERENCES TO WRITTEN DOCUMENTATION
===================================
Progress Version 8 User Interface Builder Developer's Guide
Progress Software Technical Support Note # 15821