mrc logo mrc logo
  • m-Power m-Power
    What is m-Power?
    Overview Demos Build Process Case Studies Specs Pricing Trial
    m-Power Resources
    Overview How-To Videos Webinars & Podcasts White Papers Fact Sheets
  • Solutions Solutions
    What does m-Power build?
    Overview Database Front-Ends Reporting CRM Systems Business Intelligence Dashboards Inventory Management Mobile Apps ERP Enhancements Modernization Spreadsheets to the web MS Access to the web B2B/Web Portals Scheduling Embedded Analytics Web Forms Workflow Data Exploration Budgeting & Forecasting APIs and Web Services Db2 Web Query Alternative
    Solutions by Industry
    Overview Manufacturing Government Foodservice Software Vendors Logistics & Supply Chain Software Consultants Healthcare
  • Services Services
    Development Services Training Mentoring
  • About About
    Overview Partners Press Releases Careers Events Contact Blog
  • Support Support
    Support Home FAQ Documentation Customer Portal Enhancements Updates Roadmap Techblog
Try m-Power

m-Power Manual

Browse:

  • Home
  • m-Power Administration
  • Change Variable Data Sources
Back to Manual

Change Variable Data Source

 

The data source is the definition of the database connection which includes:

  • IP address
  • DB type
  • DB driver name
  • User and password
  • Special considerations, such as the library list

Multiple data sources can be defined in the global Data Source Configuration file (/mrcjava/WEB-INF/classes/mrc-spring-context.xml). In each dictionary (/mrcjava/WEB-INF/classes/DD/mrc_servlet_config.xml), you can assign a single data source for all applications within that dictionary with the datasource parameter. You can override that default data source selection at the program level by specifying another data source in the application properties file (/mrcjava/WEB-INF/classes/DD/IXXXXXp.xml).

Sometimes, though, as the application designer, you might prefer to set the data source conditionally. An example of that would be a case where you would like to allow the end user to select a company to work in. In these cases, it is possible to present the user with several companies that they may work in. Behind the scenes, the user's company selection will set the data source for the current browser session. The differences in the data source might be minor, different only because of the library list definition, or major, with different IP and DB types. Subsequent applications, then, will use the selected data source instead of a pre-defined one for the current browser session.

In the example above, you can see that despite the thousands of records, the user CROWLEY can only see the 2 companies (or data connections) to which he is assigned. Clicking on the Library name will set the library for the user's session.

Here are the steps to complete this process:

  1. Define your separate data sources.
    1. Define the id parameter as a value that can be derived in the Data Source Selection screen. Use "as400_remote_LIB10" and "as400_remote_LIB20" for example, if choosing between company 10 and 20. The DB prefix such as "as400_remote_" or "as400_local_" is required. The suffix will make it unique to the desired data source.
  2. Configure your Data Dictionary to enable variable data sources.
    1. Copy file mrcdatasource.xml from /mrcjava/mrcclasses/ into the DD directory.
    2. Configure the entry_url with the Data Source Selection screen that you will generate in the next step, such as DD.I00010s.
    3. Define any applications that should be excluded from the variable data source logic, instead of using the default data source connection. Use the applications tag for that purpose, with an app entry for each application to exclude. If you create the Data Source Selection screen in that same Data Dictionary, be sure to exclude that application, or you will cause an infinite loop of redirection.
  3. Add the variable datasource servlet entry to the web.xml.
    1. Edit the web.xml in a text editor from /mrcjava/WEB-INF/ and add the following entry at the end of the file before the </web-app> tag:
      <servlet>
      <servlet-name>SetDataInSession</servlet-name> 
      <servlet-class>SetDataInSession</servlet-class>
      </servlet>
      <servlet-mapping> 
      <servlet-name>SetDataInSession</servlet-name> 
      <url-pattern>/servlet/SetDataInSession</url-pattern> 
      </servlet-mapping>
    2. Once done, make sure to save the file and restart Tomcat.
    3. *Note As the web.xml is a global file, this step only needs to be done the very first time the Variable Datasources is being configured, and does not need to repeated per dictionary. Before adding to the web.xml, make sure this entry does not already exist by doing a search for 'SetDataInSession'.

  4. Create a retrieval application that will serve as the Data Source Selection screen.
    1. This might be built over a file that selects records by user employing the secure_by user technique or it might be a list of the same options available to all users.
    2. Paint the application to include a link on every row like the following to set the data source:
      1. SetDataInSession?data_src=as400_remote_CO1&redirect_url=DD.I00100s
    3. The syntax, including the href tag and the text, might look like this:
        <a href="SetDataInSession?data_src=as400_remote_LIB10&redirect_url=DD.I00100s">Company 10</a>
    4. End User Screen Flow:
      1. mrcSignon (end user authentication, optional)
      2. Data Source Selection (DD.I00010s, for example)
      3. DD.I00100s (application or menu of applications)

If the data source definitions will only be different due to the library list setup, then it will be necessary to configure the applications to avoid hard-coding the data library name in the SQL statement. That is done by setting the tablename_fmt parameter to "1" (Table name only) in the Data Dictionary properties file: mrc_servlet_config.xml. This will instruct the applications to use only the table name in the SQL, not the data library name which was used at development time, allowing the library list to determine which data library to use. If you have any individual applications that should use their data library name in the SQL statement, you can add that parameter at the program level and set it appropriately there.

Created: February 29, 2008 | Modified: July 30, 2019

Search


Browse By Category

Build Process (13)
Starting with m-Power (8)
Retrievals (10)
Reports (15)
Summaries (4)
Maintainers (17)
Graphs (8)
m-Power Data Explorer (4)
General (24)
Calculations (5)
Utilities (9)
m-Power Administration (23)
Security (11)
Freemarker (6)
m-Painter (29)
Form Validation (5)
External Objects & UDFs (12)
Deprecated Documentation (23)
Bootstrap Templates (7)

Popular Tags

Reports m-Painter Data Dictionary mrc-Productivity Series Application Properties Java Tomcat Maintainers Graphs Dropdowns Graphing Report Dates RPG Summaries Freemarker Production Getting Started App Properties Bootstrap Templates Security Bar Graphs Maintainer Admin Retrieval Popular Performance Parameters Video SQL Compiling Retrievals Prompt Screens Advanced Form Validation Build Process Administration Graph Properties External Objects Record Selections Calculations Email Database DB2 Excel

See all tags »

michaels, ross & cole, ltd. (mrc)

Privacy Policy Cookie Policy Cookie Settings Notice at Collection Do Not Sell or Share My Personal Information

mrc (US)

2001 Midwest Road
Suite 310
Oak Brook, IL 60523
630-916-0662

mrc (UK)

Mortlake Business Centre
20 Mortlake High Street
London, SW14 8JN
+44-20-335-59566


© 2024 mrc. All rights reserved.