(→screen.xml) |
(→GENERAL) |
||
Line 27: | Line 27: | ||
=====GENERAL===== | =====GENERAL===== | ||
− | * " | + | * "database column headline", [[GBAMRulesForIDGeneration#.24.7BwidgetLabel.7D|<code>${widgetLabel}</code>]] |
=====VALIDATIONS===== | =====VALIDATIONS===== |
Revision as of 11:42, 20 March 2020
Load record column value
Widget is used to load value from record in database and set it into a widget.
Widget is hidden.
Widget id, ${gbamID}
:
actionLoadRecordColumnValue
Back to GBAM widgets table
Datatypes
Value is stored into compatible widget depending on source of data. Widgets which are not of same datatype should not be shown in the list of targets available to store the information.
If data comes from column which is text
datatype then it should only be possible to store to widget which saves it's data as text
datatype.
Predefined user data
PreLoaded
Properties panel
User will configure this data in properties panels of selected widget:
GENERAL
- "database column headline",
${widgetLabel}
VALIDATIONS
- -
internal validators
- -
ACTION
- "choose query type",
${queryType}
based on query type different queries will be activated. current query types:
- query single result
singleResult
- query sorted result
sortedResult
- query single result
- "value to load",
${widgetValueToLoadColumnId}
widget on screen which value should be loaded - "key", ${queryKey} which can be
@variable/
by default selection selects first widget on screen which has selected "is part of database" to true, theandroid:id
. User can change it to any widget which have checkbox "is part of database" set to true. Value is then copied from widget ${keyWidgetId} to it's variable ${queryKey}. In case that widget is a "variable" then value is copied from variable i.e. Ginstr username - "target widget", widget into which result is stored
${targetWidget}
, which is formed${widgetID}
widget id's. All widgets that are on screen which have checkbox "is part of database", user can change selection. It's a dropdown. - "sort key", visible only if
query sorted result
is selected ${sortByWidgetId} by default selection selects first widget on screen which has selected "is part of database" to true, theandroid:id
. User can change it to any widget which have checkbox "is part of database" set to true. - "clean widgets on no result", cleans widgets that receive result if nothing is returned ${cleanWidgetsOnNoResult}, only if checkbox selected. By default is selected
- "on event" triggers the action in common widget code at specific event. Events are are listed in a dropdown can be:
screen load
widget code is added into root node of the screen in attributegn:act_beforeLoad
as:
gn:act_beforeLoad="[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]" gn:act_set="Common widget code"
Button save
, trigger code:
[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]
- as attribute to Button save widget:
gn:act_set="Common widget code"
- needs to be added to widget Button save at:
- Two options when to execute:
before
, then insert the trigger code after this line${listWidgetToVariable}
in snippet at Button_save#GBAM_Code_Variables:after
, then insert the trigger code after this line[gn:act_resetVariables]|[${listofVariableIds1}];
in snippet at Button_save#GBAM_Code_Variables
Button clean widgets
, trigger code:
[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]
- as attribute to Button clean widgets widget:
gn:act_set="Common widget code"
- Two options when to execute:
before
, then insert the code after this line[gn:act_cleanWidgets]|[${listofWidgetIds}],[gn:act_resetVariables]|[${listofVariableIds}]
in snippet at Button_clean_widgets#GBAM_Code_Variablesafter
, then insert the code after this line[gn:act_cleanWidgets]|[${listofWidgetIds}],[gn:act_resetVariables]|[${listofVariableIds}]
in snippet at Button_clean_widgets#GBAM_Code_Variables
Button query
, trigger code:
- Two options when to execute:
- Two options when to execute:
[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]
- as attribute to Button query widget:
gn:act_set="Common widget code"
before
, then insert the code before this line[gn:act_if]|[[gn:act_rawQueryToWidgets]|[...
in snippet at Button_query#GBAM_Code_Variablesafter
, then insert the code before this line[gn:act_hideKeyboard]|[]
in snippet at Button_query#GBAM_Code_Variables
ACTION MESSAGES
- "on no rights",
${$noReadRightsToast}
DATABASE
- -
Code snippets
GBAM Code Variables
Variables which are used in code snippet below but not defined in user modifiable inputs.
${widgetID}
,{variableId}
is generated based on the${widgetID}
${tableName}
- "target widget",
${targetWidget}
, formed as${widgetID}
widget id's. All widgets on screen which have checkbox "is part of database", user can change selection. ${queryType}
=singleResult
[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}${tableName};${widgetValueToLoadColumnId};@variable/${resultVariable};@variable/${queryKey}]
${querySuccess}=
[gn:act_getVariableToWidget]|[@variable/${resultVariable},@+id/${targetWidget}]
in queries.xml, ${queriesXml}=
<query id="${widgetID}${tableName}" columns="${widgetValueToLoadColumnId}" keys="${keyDbColumn}"/>
${queryType}
=sortedResult
[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}${tableName},,,sortreversetop;${widgetValueToLoadColumnId};@variable/${resultVariable};@variable/${queryKey},@variable/${sortByWidgetId}]
${querySuccess}=
[gn:act_getVariableToWidget]|[@variable/${resultVariable},@+id/${targetWidget}]
in queries.xml, ${queriesXml}=
<query id="${widgetID}${tableName}" columns="${widgetValueToLoadColumnId}" keys="${keyDbColumn},${sortDbColumn}"/>
${cleanWidgetsOnNoResult}
following code for clean is added if checkbox is selected:
[gn:act_resetVariables]|[@variable/${resultVariable}], [gn:act_cleanWidgets]|[@+id/${targetWidget}]
${keyDbColumn}
- column name of widget which links to @variable/${queryKey} which used as key${resultVariable}
, value is stored into variable after query before setting it to widget${targetWidget}
Common widget code
screen.xml
[gn:act_if]|[[gn:act_hasTableRights]|[${tableName}!=R]-- [gn:act_toast]|[@string/${$noReadRightsToast}]; [gn:act_break]|[]], [gn:act_setVariable]|[@variable/${queryKey},${keyWidgetId}], [gn:act_if]|[${queryType}-- ${querySuccess} :: ${cleanWidgetsOnNoResult}]
queries.xml
Add to queries.xml : ${queriesXml}