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

Button query

Widget preforms query action to database. Queried data is transferred from database to widgets. If nothing is returned nothing will be set to widgets.

Widget id, ${gbamID}:

buttonQuery

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.
  • "sort key", ${sortByWidgetId} by default it's equal to GnEditText android:id value of buttonQuery widget . User can change it to any widget which have checkbox "is part of database".
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.

  • ${screenLabelGenerated}
  • ${widgetButtonLabelGenerated}
  • ${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
  • ${sortDbColumn} - column name of widget which is defined by user as "sort key"
  • ${keyDbColumn} - column name of GnEditText node widget which used as key

GBAM Code Events

${eventBefore}

${eventAfter}

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/textEditable_label"/>

<com.ginstr.widgets.GnEditText
    android:id="@+id/${widgetID}_input"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    gn:s_hint="@string/${widgetID}Hint"
    gn:dataType="text"
    gn:s_sourceType="input"
    gn:autoAdjustHeight="true"
    gn:style="@style/textEditable_input"/>

<com.ginstr.widgets.GnButton
  android:id="@+id/${widgetID}_button"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  gn:style="@style/buttonQuery_button"
  gn:act_setClick="
      [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_setVariable]|[@variable/${sortByWidgetId},@+id/${sortByWidgetId}],
      ${eventBefore}
      [gn:act_if]|[[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}_input${tableName},,,sortreversetop;${listOfDbColumnIds};${listofVariableIds};@variable/${widgetID}_input,@variable/${sortByWidgetId}]--
          ${variableToWidgetList}
      ::
          [gn:act_toast]|[@string/${$noResultToast}]],
      ${eventAfter}
      [gn:act_hideKeyboard]|[]"
  android:text="@string/${screenLabelGenerated}_${widgetButtonLabelGenerated}"/>

strings.xml

Lines to be added for each language.

<string name="${widgetID}">${widgetLabel}</string>
<string name="${widgetID}Hint">${widgetHint}</string>
<string name="${screenLabelGenerated}_${widgetButtonLabelGenerated}">${widgetButtonLabel}</string>

queries.xml

Add to queries.xml :

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