Page 1 of 1
Any way to pass a working list
Posted: Fri Feb 08, 2013 8:33 pm
by cklee
I'm working on a demo with RDMLX. I have written a program for a form view to search for some records and store in a working list. I have also written a 'detail' program for another form view. I have used SharedState to pass the key of the selected record from the 'search' program to the 'detail' program and it works fine to display the record details. I would like to have a 'next' and a 'prev' command on the 'detail' form view. However, I cannot get the key of the next record in the list. Does anyone know a way to pass a working list from the 'search' program to the 'detail' program.
Many thanks for advice.
Re: Any way to pass a working list
Posted: Wed Feb 13, 2013 8:48 am
by MarkDuignan
Make a VL reusable called MYLIST (say) that contains the working list definition and MthRoutines to add an entry, get an entry and to clear the list. You might also define a property that returns the current entry count.
Declare MYLIST in both your other formviews with scope(*application). You should now have a single working list that is shared between both formviews.
Note that the list content will only exist (persist) within a single user interaction (this is standard web programming). If you need it to persist between interactions then you need to save it somewhere and reload it on the next interaction. If you needed to do that add this as ‘invisible’ logic to MYLIST so that no form view using MYLIST needs to know this happens – to them the list is just persistent.
You may not need to do any of that - the way that one RDMLX LongRange form view switches (transfers) control to another is usually via the SwitchRequest method
http://www.longrangemobile.com/docs/lan ... ropert.htm.
This method has a SwitchRequestOBJECT parameter that allows you to pass an object reference into the target form view.
http://www.longrangemobile.com/docs/lan ... ropert.htm
Shipped examples LREX0065 and LREX0065A demonstrate this. They only pass
Define_Com Class(#prim_alph) Name(#LogicalParm) Reference(*Dynamic)
which is only a simple alpha string - but you can equally do this:
Define_Com Class(#MYLIST) Name(#LogicalParm) Reference(*Dynamic)
Where MYLIST is a compound object containing properties, methods, working lists, etc.
Re: Any way to pass a working list
Posted: Wed Mar 06, 2013 2:23 pm
by cklee
When I click an item on the search result, the 'search' form is requested again to execute the logic to pass control to the 'detail' form. However, the object content has already gone before I can use the SwitchRequestOBJECT parameter.
Re: Any way to pass a working list
Posted: Wed Mar 06, 2013 3:31 pm
by Mark_Dale
The way I would make a list available to various forms is to save it as SharedState variables:
This method seems to work ok for short lists
* Save a list to shared state
Mthroutine Name(SaveList)
#uEntry := 0
Selectlist Named(#LstInc)
#uEntry += 1
#Com_Owner.Set_SharedStateNum Variablename(LRDMCT02_uInNumber + #uEntry.AsString) Value(#uInNumber)
#uText := #uInDtTime.AsString
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uInDtTime + #uEntry.AsString) Value(#uText)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uInType + #uEntry.AsString) Value(#uInType)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uInStatus + #uEntry.AsString) Value(#uInStatus)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uInDesc + #uEntry.AsString) Value(#uInDesc)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uForeName + #uEntry.AsString) Value(#uForename)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uLastName + #uEntry.AsString) Value(#uLastName)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uAddress + #uEntry.AsString) Value(#uAddress)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uZip + #uEntry.AsString) Value(#uZip)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uCity + #uEntry.AsString) Value(#uCity)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uPhone + #uEntry.AsString) Value(#uPhone)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uEMail + #uEntry.AsString) Value(#uEmail)
#Com_Owner.Set_SharedState Variablename(LRDMCT02_uCellPhon + #uEntry.AsString) Value(#uCellPhon)
#Com_Owner.Set_SharedStateNum Variablename(LRDMCT02_uLatitude + #uEntry.AsString) Value(#ulatitude)
#Com_Owner.Set_SharedStateNum Variablename(LRDMCT02_uLongitude + #uEntry.AsString) Value(#ulongitud)
#Com_Owner.Set_SharedStateNum Variablename(LRDMCT02_uAltitude + #uEntry.AsString) Value(#ualtitude)
Endselect
#Com_Owner.Set_SharedStateNum Variablename(LRDMCT02_IncCnt) Value(#uEntry)
Endroutine
*Load a list from shared state
Mthroutine Name(LoadList)
Clr_List Named(#LstInc)
#Com_Owner.Get_SharedStateNum Variablename(LRDMCT02_IncCnt) Value(#uIncCnt)
* Get the incident "records" from saved state values which include the incidents the user has added during this session
Begin_Loop Using(#uEntry) To(#uIncCnt)
#Com_Owner.Get_SharedStateNum Variablename(LRDMCT02_uInNumber + #uEntry.AsString) Value(#uInNumber)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uInDtTime + #uEntry.AsString) Value(#uText)
#uInDtTime := #uText.AsDateTime
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uInType + #uEntry.AsString) Value(#uInType)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uInStatus + #uEntry.AsString) Value(#uInStatus)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uInDesc + #uEntry.AsString) Value(#uInDesc)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uForeName + #uEntry.AsString) Value(#uForename)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uLastName + #uEntry.AsString) Value(#uLastName)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uAddress + #uEntry.AsString) Value(#uAddress)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uZip + #uEntry.AsString) Value(#uZip)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uCity + #uEntry.AsString) Value(#uCity)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uPhone + #uEntry.AsString) Value(#uPhone)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uEMail + #uEntry.AsString) Value(#uEMail)
#Com_Owner.Get_SharedState Variablename(LRDMCT02_uCellPhon + #uEntry.AsString) Value(#uCellPhon)
#Com_Owner.Get_SharedStateNum Variablename(LRDMCT02_uLatitude + #uEntry.AsString) Value(#ulatitude)
#Com_Owner.Get_SharedStateNum Variablename(LRDMCT02_uLongitude + #uEntry.AsString) Value(#ulongitud)
#Com_Owner.Get_SharedStateNum Variablename(LRDMCT02_uAltitude + #uEntry.AsString) Value(#ualtitude)
Add_Entry To_List(#LstInc)
End_Loop
Endroutine
Re: Any way to pass a working list
Posted: Mon Nov 11, 2013 7:17 pm
by GILLETTD
Hi,
By single user interaction do you actually mean handling several events on the same form? I am losing my class data defined as scope(*application) after re-submitting a form to execute a different event
cheers,
Dominique
Re: Any way to pass a working list
Posted: Tue Nov 12, 2013 8:55 am
by MarkDuignan
In LongRange RPG sessions are stateful and remember data between interactions.
In LongRange RDMLX (LANSA) sessions are stateless – so their state data ceases to exist between every client interaction - this is like all LANSA web style programming. When using LANSA you need to save your state data between interactions.
Using the SharedState approach described previously in this topic is okay for small amounts of data – but because the shared state data is send back on forth between the client and the server for every interaction you can easily consume too much of this resource and slow you App down.
It’s better just to keep a data access ‘key’ in the SharedState and keep the rest of your state data in a data base or file.
This topic discusses this in more detail and it contains a generic LANSA solution for saving state provide by Greg Sippel (towards the end) -
http://longrange.lansa.com.au/viewtopic.php?f=11&t=159
In RPG you can use the EZI_GetStateVar and EZISaveStateVar procedures shipped in your EZISERVICE layer – which provide permanent long term state data persistence (eg: for user preferences, system settings, etc).