From wiki.ginstr.com
Jump to: navigation, search

Nfc image query

Widget performs query action to database when NFC is scanned.
Widget is represented by NFC scan symbol.
After scan data is filled to widgets on screen if any selected.

Widget id, ${gbamID}:

nfcImageQuery

Back to GBAM widgets table

Datatypes

Value is stored from widget to database as text datatype.

Predefined user data

PreLoaded

Properties panel

User will configure this data in properties panels of selected widget:

GENERAL
VALIDATIONS
    <columnText required="true|false"></columnText>
<columnText>
    <len>null|>=0|<=10000</len>
</columnText>
  • "unique", check uniqueness when widget gets saved into db, having "is part of database" checked, add to configuration.xml:
    <columnText unique="true|false"></columnText>
ACTION
  • "widgets to load", ${listOfDbWidgets}, list of comma separated ${widgetID} widget id's. All widgets on screen which have checkbox "is part of database", user can change selection.
ACTION MESSAGES
DATABASE
  • "is part of database", checkbox option by default is set as checked. When checked database column is created for this widget.
  • "additional ginstr web column settings":
  • "align text", radio button options with values: "left", "middle", "right", add to configuration.xml:
<columnText>
    <horizontalAlignment>left|center|right</horizontalAlignment>
</columnText>
  • "list of allowed values" array with list of allowed values, add to configuration.xml:
<columnText>
  <valuesList>
    <value>val1</value>
    <value>val2</value>
  </valuesList>
</columnText>
  • "pattern", add to configuration.xml:
<columnText>
    <pattern errorMessage="invalidTextTableValue">[0-9A-Z]{3}</pattern>
</columnText>
  • "related unique columns", add to configuration.xml:
<columnText>
    <uniqueInsideList>
        <reference>
          <table>refTableId1</table>
          <column>refColumnField1</column>
        </reference>
        <reference>
          <table>refTableId2</table>
          <column>refColumnField2</column>
        </reference>
    </uniqueInsideList>
</columnText>

Code snippets

GBAM Code Variables

Variables which are used in code snippet below but not defined in user modifiable inputs.

  • ${widgetID}
  • ${tableName}
  • ${variableToWidgetList} = ${[gn:act_getVariableToWidget]|@variable/${widgetID},@+id/${widgetID}];} - repeats as many times as is the number of widgets with "is part of database" checked, last repetition does not have ";" , except widget@+id/${widgetID}_input
  • ${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent} = ${[gn:act_reloadAutoFilledWidgets]|[@+id/${dateTimeWidgetAsSortKey}];} - it should only exist if Timestamp widget is added to screen
  • ${listOfWidgetIdsExceptQueryKey} - all widgets on screen which have checkbox "is part of database", except GnEditText node android:id=@+id/${widgetID}_input of buttonQuery widget which is used as key.
  • ${listofVariableIds} - comma separated list of @variable/${widgetID}. Represents all variables (related to widgets) which have checkbox "is part of database", except @variable/${widgetID}_input
  • ${listOfDbColumnIds} - comma separated list of ${columnName} column names. Represents all widgets/variables which have checkbox "is part of database", except @+id/${widgetID}_input
  • ${keyDbColumn} - column name of GnEditText node widget which used as key

Common widget code

<com.ginstr.widgets.GnTextView
    android:id="@+id/${widgetID}_label"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/${widgetID}"
    gn:style="@style/nfcImageQuery_label"/>
	
<com.ginstr.widgets.GnEditText
    android:id="@+id/${widgetID}_input"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    gn:dataType="text"
    gn:s_sourceType="nfc"
	gn:act_setOnNfc="
	[gn:act_if]|[[gn:act_hasTableRights]|[${tableName}!=R]--
          [gn:act_toast]|[@string/${$noReadRightsToast}];
          [gn:act_break]|[]],
	[gn:act_if]|[[gn:act_validateScreen]|[@+id/${widgetID}_input]--::[gn:act_break]|[]],
	[gn:act_cleanWidgets]|[@+id/${listOfWidgetIdsExceptQueryKey}],
	[gn:act_resetVariables]|[@variable/${listOfDbWidgets}],
	${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent},
	[gn:act_setVariable]|[@variable/${widgetID}_input,@+id/${widgetID}_input],
	[gn:act_if]|[[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}_input;${listOfDbColumnIds};${listofVariableIds};@variable/${widgetID}_input]--
		${variableToWidgetList}
	::
		[gn:act_toast]|[@string/$noResultToast]],
	[gn:act_hideKeyboard]|[]"
    gn:style="@style/nfcImageQuery_input"/>
			   
<ImageView
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	gn:style="@style/nfcImageQuery_image" />

strings.xml

Lines to be added for each language.

<string name="${widgetID}">${widgetLabel}</string>

queries.xml

Add to queries.xml :

    <query
        id="${widgetID}_input${tableName}" 
        columns="${listOfDbColumnIds}"
        keys="${keyDbColumn}"/>