Page 1 of 1

Help W/moving a list between server module, command handler, and view

Posted: Sat Feb 06, 2021 4:34 am
by ESODevKJ
EDIT: The problem lies with the fact that my Next_button is on the command handler. When I move next_button to the View, it works fine. However, it creates design issues (among others) if next_button's parent is not the command handler. So the basics of what I'm looking for help with is moving lists back and forth between the View and the command handler.


In the below image, I have 4 fields that have an N in them. When I click next button, I should get a #sys_web.alert that says at least 1 of them needs to be a Y. However, the list isn't read by the by the server module routine flagcheck. I even tried doing it by individual fields, but still doesn't work. Relevant code after image. I'm sure it's something simple/easy that I'm missing, so thank you.

Image

Next button click:

Code: Select all

Evtroutine Handling(#Next_Button.Click)
Inz_List Named(#flags)
#CUDTC01.flagcheck
If Cond('(#CSSTYN *EQ N) *AND (#CSBTYN *EQ N) *AND (#CSPPYN *EQ N) *AND (#CSFBYN *EQ N)')
#sys_web.Alert Caption('Ship to or Bill to has to be a Y')
View code:

Code: Select all

Mthroutine Name(flagcheck)
Define_Com Class(#ESF_MNT_CUHD_CMDHANDLER_svrm.FlagCheck) Name(#flagcheck)
Inz_List Named(#flags)
#flagcheck.Execute Flags(#flags) Flag1(#CSBTyn) Flag2(#CSFBYN) Flag3(#CSPPYN) Flag4(#CSSTYN)
Server module routine:

Code: Select all

Srvroutine Name(FlagCheck) Session(*REQUIRED)
Field_Map For(*INPUT) Field(#csstyn) Parameter_Name(flag1)
Field_Map For(*INPUT) Field(#csbtyn) Parameter_Name(flag2)
Field_Map For(*INPUT) Field(#csppyn) Parameter_Name(flag3)
Field_Map For(*INPUT) Field(#csfbyn) Parameter_Name(flag4)
List_Map For(*INPUT) List(#flags)

Get_Entry Number(1) From_List(#flags)

Re: Help W/moving a list between server module, command handler, and view

Posted: Sat Feb 06, 2021 4:56 am
by lawingo
All your Field_Maps for SRVROUTINE are *INPUT - meaning the routine is just reading the fields and the list. Are the Fields suppose to be output and the list input ? In other words, no variables are returned to the program from that SRVROUTINE.

Best,
Chad
Sherrill Furniture Company

Re: Help W/moving a list between server module, command handler, and view

Posted: Sat Feb 06, 2021 5:52 am
by ESODevKJ
That's a fair point. Unfortunately, when I get to the SRVROUTINE and it gets to "Get_Entry Number(1) From_List(#flags)" it's not reading the list, even though in debug when I click the "create" button at the top, the list is populated. Appreciate the response, thank you for your input ;)

Re: Help W/moving a list between server module, command handler, and view

Posted: Sun Feb 07, 2021 2:26 am
by lawingo
Is your webpage starting a session? It seems your server routine requires a session. If you are testing, try removing the "Session(*REQUIRED)" and see if it works.

Re: Help W/moving a list between server module, command handler, and view

Posted: Tue Feb 09, 2021 5:34 am
by Dino
Not sure if this will apply to your particular case, but if you are trying to move lists between components, defining the list as a collection instead of a normal list, helps a lot. No to much of a complication, you just need to create an object with the elements of the list, the rest is very similar.

You can create a reusable part (object type) like this and lets called it ABCITEM:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_OBJT *listFields #OneItem)
Group_By Name(#OneItem) Fields(#EMPNO #SURNAME)
End_Com
then for example in a web page:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#xDemoTheme)

Define_Com Class(#PRIM_PHBN) Name(#Showinpopup) Caption('Send the list to the view') Displayposition(1) Left(4) Parent(#COM_OWNER) Tabposition(1) Top(8) Width(133)
Define_Com Class(#PRIM_MD.ViewContainer) Name(#ViewContainer) Displayposition(2) Left(87) Parent(#COM_OWNER) Tabposition(2) Top(77)
Define_Com Class(#ABCVIEW) Name(#ABCVIEW) Height(500) Left(183) Parent(#ViewContainer) Width(550)

* Collection of items to be handled as a list
Define_Com Class(#Prim_acol<#ABCITEM>) Name(#ABCList)

Evtroutine Handling(#Com_owner.Initialize)
#com_owner.Load
Endroutine

Mthroutine Name(Load)
* Note that you populate the items in the same way 
#EMPNO #SURNAME := A1111
Add_Entry To_List(#ABCList)
#EMPNO #SURNAME := A22222
Add_Entry To_List(#ABCList)
Endroutine

Evtroutine Handling(#Showinpopup.Click)
* Here you are calling a method in the VIEW and passing the list (or the reference to it)
#ABCVIEW.ShowList( #ABCList )
#ABCVIEW.Show
Endroutine
End_Com
And in the View (ABCVIEW) or other component:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_VIEW) Displayposition(1) Tabposition(1)
Define_Com Class(#PRIM_LIST) Name(#List1) Displayposition(1) Height(377) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(30) Width(655) Columnlines(False) Rowlines(False)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnEMPNO1) Displayposition(1) Parent(#List1) Source(#EMPNO) Columnwidth(97)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnSURNAME1) Displayposition(2) Parent(#List1) Source(#SURNAME) Columnunits(Proportion)

Mthroutine Name(ShowList)
* Here is how you receive the reference (or the list)
Define_Map For(*INPUT) Class(#Prim_acol<#ABCITEM>) Name(#ABCList) Pass(*BY_REFERENCE)

* Note that you read the list in the same way
Clr_List Named(#List1)
Selectlist Named(#ABCList)
Add_Entry To_List(#List1)
Endselect
Endroutine
End_Com