Yes you can. IceCap and IceBreak share the same session in IceBreak. So you can utilize all IceBreak features in the breakout program. An example: If you prompt the user in the HTML page for the shop-number, then you can make an AJAX call back to IceBreak that stores this information in a session variable. But beware of cross-domain issues.
An other approach is to let you website (Share Point Server) store the number in a cookie. Later you can retrieve that cookie in the IceCap breakout program. You need however to run the IceBreak and IceCap from the same domain as your website. Cookies are only available from within the domain where they are created.
Yet another and even more easy possibility is to ask the client for the Shop-number the first time the user is accessing the breakout program for the first time that day – and then let the breakout program create the cookie. Again – IceCap and IceBreak share the same session, so you can do all kind of IceBreak tricks in the IceCap breakout.
With this approach you are centralizing the use and the creation of the cookie to the breakout program. Let me show you how that is done:
A: In your breakout program you need access to the IceBreak features.
You need to bind to the IceBreak service program
And you need to include the header file with the IceBreak prototypes - remember to have ICEBREAK on your library list when you compile your breakout
B: Now you are ready to fill in the action:
Lets assume that your "normal" 5250 ask for the shop-number in a display called DISP0001D. So if display file record DISP0001D are shown we will fill the shop number with the value from the cookie – if that exists, and then bypass the prompt. Otherwise we will actually show DISP0001D and create a new cookie with the value the user enters.
Let se how that code looks:
* ---------------------------------------------------------------------------------------- */
* Copyright [2012] [System & Method A/S] */
* */
* Licensed under the Apache License, Version 2.0 (the "License"); */
* you may not use this file except in compliance with the License. */
* You may obtain a copy of the License at */
* */
* http://www.apache.org/licenses/LICENSE-2.0 */
* */
* Unless required by applicable law or agreed to in writing, software */
* distributed under the License is distributed on an "AS IS" BASIS, */
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
* See the License for the specific language governing permissions and */
* limitations under the License. */
* ---------------------------------------------------------------------------------------- */
* */
* Project . . . : IceBreak */
* Design . . . : Niels Liisberg */
* Function . . : Getting and setting cookies from a breakout program - and also: */
* How to interact with the IceBreak session */
* */
* By Date Task Description */
* -------- ---------- ------- ------------------------------------------------------------ */
* NLI 07.05.2012 0000000 New program - Subproject IceCap */
* ---------------------------------------------------------------------------------------- */
*
* Step1:
* You need to bind with the ICEBREAK bindirectory, so you need
* IceBreak on the library list. Also you need to include
* all the IceBreak prototypes - this is the include
* Also it can not have a default activation groupe so vi use the *CALLER
h debug(*yes)
H DFTACTGRP(*NO)
H ACTGRP(*CALLER)
H bnddir('ICEBREAK')
h bnddir('ICECAPEML')
h BndDir('EXTUTILITY')
/Include qAspHdr,ICECAP
/Include qAspHdr,ICECAPEML
/Include qAspHdr,ICEBREAK
/Include qAspHdr,ExtUtility
* ------------------------------------------------------------- *
* Main Line
* ---------
d pVts s *
d vts ds likeds(vtsDS)
d loc ds likeds(vtLocationDS)
d field ds likeds(vtFieldDS)
d shopno s 5 0 inz
c *entry plist
c parm vts
* ---------------------------------------------------------------------------------------- */
/free
pVts = %addr(vts); // Get the pointer the the virtual IceCap 5250 session
vts.showScreen = *on; // assume we will show screens to come
// Only when the screen id is DISP001D:
// The real logic has to test for valid shopnumbers ( the error line or a valid shop name to arrive)
// othwise this code will loop - but for now and the purpose to show interaction with Cookies - it will do
if vtGetScreen(pVts:1:2:8) = 'DISP001D';
shopNo = num(vtGetValueFor(pVts : 'Shop number'));
if (shopNo > 0);
SetCookie('shopno': %char(shopNo): 10000); // Set the shopnumber and let it live in 10,000 seconds
else;
shopNo = num(GetCookie('shopno'));
if (shopNo > 0); // We have a shop number in a cookie
vtSetFieldNo(pVts:1:%char(shopNo)); // Now enter that in the first input field
vtPressKey(pVts: vtENTER); // And press enter
vts.showScreen = *off; // Now bypass this screen
return;
endif;
endif;
endif;
return;
Re: Share session data between IceBreak and IceCap
Yes you can. IceCap and IceBreak share the same session in IceBreak. So you can utilize all IceBreak features in the breakout program. An example: If you prompt the user in the HTML page for the shop-number, then you can make an AJAX call back to IceBreak that stores this information in a session variable. But beware of cross-domain issues.
An other approach is to let you website (Share Point Server) store the number in a cookie. Later you can retrieve that cookie in the IceCap breakout program. You need however to run the IceBreak and IceCap from the same domain as your website. Cookies are only available from within the domain where they are created.
Yet another and even more easy possibility is to ask the client for the Shop-number the first time the user is accessing the breakout program for the first time that day – and then let the breakout program create the cookie. Again – IceCap and IceBreak share the same session, so you can do all kind of IceBreak tricks in the IceCap breakout.
With this approach you are centralizing the use and the creation of the cookie to the breakout program. Let me show you how that is done:
A: In your breakout program you need access to the IceBreak features.
B: Now you are ready to fill in the action:
Lets assume that your "normal" 5250 ask for the shop-number in a display called DISP0001D. So if display file record DISP0001D are shown we will fill the shop number with the value from the cookie – if that exists, and then bypass the prompt. Otherwise we will actually show DISP0001D and create a new cookie with the value the user enters.
Let se how that code looks:
Best regards,
Niels Liisberg