richard.milone
11-22-2008, 01:53 AM
I've been getting a significant number of private support questions regarding setting library lists with Valence so in this post I'm going to do a brain dump of everything I know about the subject. Here it goes...
There are two ways to set libraries with Valence.
METHOD 1 (EASY, LESS FLEXIBLE)
The first (and easiest) is to modify the “standard” library list defined in the VALENCE11 server instance. If you look in the configuration of the VALENCE11 Apache server instance you’ll see these lines that set the VALENCE11 library into the library list:
# set the standard library list
SetEnv STD_LIB_LIST "VALENCE11"
PassEnv STD_LIB_LIST
You can add libraries very easily to this standard library list by adding them after VALENCE11 and separate them by a space, like:
# set the standard library list
SetEnv STD_LIB_LIST "VALENCE11 LIB1 LIB2 LIB3"
PassEnv STD_LIB_LIST
Now, any RPG program you develop in Valence will automatically set to this library list. It's important to note that this library list has nothing to do with the environment library list set in the Valence viewport. You will get this library list no matter what environment you choose when logging into Valence.
METHOD 2 (ADVANCED, MORE FLEXIBLE)
The other way to set libraries in Valence is to use the environment library list. Just setting the library list in the environment definition in the viewport will not automatically set that library for every call to an RPG program. Your RPG program needs to explicitly set the library list with the vvUtility_setLibToEnv procedure (see the Valence RPG Toolkit documentation). In order to use the setLibToEnv procedure your RPG program will need to know the session id so it can retrieve your current environment (and the environment's library list) from the Valence viewport's session file. In your front-end Valence program you should add a line of JavaScript to get the session id like this:
var sid =parent.getSid();
You can just specify this line once in the program right after the Ext.onReady statement and then the session id (sid) value will be available globally. Technically, this line just receives the session id into your program from the Valence viewport that was assigned at login. Then wherever you make a call to the RPG program you need to include the sid as a parameter. For example, this is from a program I’m working on today:
// listener: items grid
dsGridOrdLines.on("beforeload", function() {
dsGridOrdLines.baseParams={sid: sid, action: 'getOrdLinList', order: order, type: orderType};
});
Notice that the session id is just being passed as “sid: sid”. This is just saying to pass a variable named sid to your RPG program and give it the value of the session id that you retrieved at the top of the program. You can specify it anywhere but as a convention, if I'm writing a program that needs to use the session id, I always specify it first (and by-the-way I always specify the action second).
Now, in your RPG program you just need to receive the sid and then pass it to the setLibToEnv procedure as follows:
vvSessID=vvHttp_in('sid');
vvUtility_SetLibToEnv(vvSessID);
These lines should be the absolute first operations done by the program. If all goes well, your library list will be set to the environment that you selected when you logged into the Valence viewport.
There are two ways to set libraries with Valence.
METHOD 1 (EASY, LESS FLEXIBLE)
The first (and easiest) is to modify the “standard” library list defined in the VALENCE11 server instance. If you look in the configuration of the VALENCE11 Apache server instance you’ll see these lines that set the VALENCE11 library into the library list:
# set the standard library list
SetEnv STD_LIB_LIST "VALENCE11"
PassEnv STD_LIB_LIST
You can add libraries very easily to this standard library list by adding them after VALENCE11 and separate them by a space, like:
# set the standard library list
SetEnv STD_LIB_LIST "VALENCE11 LIB1 LIB2 LIB3"
PassEnv STD_LIB_LIST
Now, any RPG program you develop in Valence will automatically set to this library list. It's important to note that this library list has nothing to do with the environment library list set in the Valence viewport. You will get this library list no matter what environment you choose when logging into Valence.
METHOD 2 (ADVANCED, MORE FLEXIBLE)
The other way to set libraries in Valence is to use the environment library list. Just setting the library list in the environment definition in the viewport will not automatically set that library for every call to an RPG program. Your RPG program needs to explicitly set the library list with the vvUtility_setLibToEnv procedure (see the Valence RPG Toolkit documentation). In order to use the setLibToEnv procedure your RPG program will need to know the session id so it can retrieve your current environment (and the environment's library list) from the Valence viewport's session file. In your front-end Valence program you should add a line of JavaScript to get the session id like this:
var sid =parent.getSid();
You can just specify this line once in the program right after the Ext.onReady statement and then the session id (sid) value will be available globally. Technically, this line just receives the session id into your program from the Valence viewport that was assigned at login. Then wherever you make a call to the RPG program you need to include the sid as a parameter. For example, this is from a program I’m working on today:
// listener: items grid
dsGridOrdLines.on("beforeload", function() {
dsGridOrdLines.baseParams={sid: sid, action: 'getOrdLinList', order: order, type: orderType};
});
Notice that the session id is just being passed as “sid: sid”. This is just saying to pass a variable named sid to your RPG program and give it the value of the session id that you retrieved at the top of the program. You can specify it anywhere but as a convention, if I'm writing a program that needs to use the session id, I always specify it first (and by-the-way I always specify the action second).
Now, in your RPG program you just need to receive the sid and then pass it to the setLibToEnv procedure as follows:
vvSessID=vvHttp_in('sid');
vvUtility_SetLibToEnv(vvSessID);
These lines should be the absolute first operations done by the program. If all goes well, your library list will be set to the environment that you selected when you logged into the Valence viewport.