wavemaker visual ajax studio 4.0 training basics: livevariables

Click here to load reader

Post on 11-Jan-2016

218 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • WaveMaker Visual AJAX Studio 4.0 TrainingBasics: LiveVariables

    *

    How it WorksWhen you create a LiveVariable, you select a LiveView or LiveTable to base it onYou must also select a database operation for the LiveVariable: Read, Insert, Update or Delete When you create a LiveForm or a DataGrid, you select a LiveVariable to use as the data set

    *

    Bind Components to Data Source

    LiveVariable forms the link between the data source and the LiveForm or DataGrid

    Database

    LiveForm/ DataGrid

    LiveVariable

    LiveForm/ DataGrid

    LiveVariable

    Database

    *

    Create a New LiveVariableOn the Component Tree menu, click New LiveVariable icon

    Properties for the new LiveVariable now appear in the Property Editor

    *

    Name the New LiveVariableType in a name for the name property in the Property EditorThis is the name that appears in the Component Tree and in the Binding dialogs so make the name descriptiveStudio gives the LiveVariable a default name, so this step is optional, but recommended

    *

    Choose a Data SourceSelect a data source from the drop-down menu for the liveSource propertyThis list includes all the LiveTables and LiveViews defined in the project

    *

    LiveTables or LiveViews?When you create a LiveVariable, you must choose a LiveTable or a LiveView as the source for the dataChoose a LiveView when:You need to access fields from a related table orYour LiveTable has a composite primary keyOtherwise, use a LiveTable

    *

    Choose a Data OperationSelect a data operation from the drop-down menu for the operation propertyThis list includes the following database operations:readDatainsertDataupdateDatadeleteData

    *

    Filter the Data (optional)You can filter the data in the specified by the liveSource:specify a filter objectfilter individual fieldsYou can only set up filters when the LiveVariable operation is readDataFilter can be bound to a widget, expression, or service variable

    *

    Filter the liveSource as a Whole

    Use the filter property in the Properties TreeBind to an object of the same type as the LiveVariable

    *

    Filter individual FieldsSelect a filter object in the Properties TreeIndividual fields appear in the Property Editor

    *

    Bind to the FieldYou can bind a filter to one or more fieldsFields marked with an asterisk are complex structures Bind the whole structure to an object of the same type orExpand the structure in the Properties Tree and bind to individual fields

    *

    Other LiveVariable PropertiesautoUpdate: automatically refresh data from databaseignoreCaseChoose: whether to make the results case sensitive or notupdateNow: update the Service Variable (use in design mode)queue: defines a list of Service Variables to execute, in order, after this Variable executes

    *

    LiveVariable Properties for ListsfirstRow: for setting up paging in conjunction with maxResults (ignored if maxResults is not set)maxResults: the number of records that will be returned at runtimedesignMaxResults: the number of records that will be returned when viewing data at design time.orderBy: specify a property to use for ordering the data (you can order in ascending or descending order)

    *

    sourceData PropertyUse of the sourceData property is an advanced topic. It is not needed in most cases.

    *

    Questions?

    *

    Exercises 8Add a Live VariableBind to DataGridFilter based on Search Criteria

    *LiveVariables are a special type of Variable. A LiveVariable can have either a LiveView or a LiveTable as its dataSet. In turn, if you use a LiveVariable as the dataSet for a LiveForm, then you can automatically generate database operations such as read, insert and update.*

    Example firstRow:If a result set has 100 rows and you set maxResults to 10 and firstRow to 11, then you'll get rows 11-20.

    Example syntax for orderby property:asc: propertyNameordesc: propertyNameFor example:asc: actorIddesc: item.company

    The meaning of this property changes based on the LiveVariable's operation:For "readData," sourceData specifies a root object for which we are gathering more data. This is useful for getting additional related objects for a given object. For example, if a LiveVariable is setup to retrieve Customers with Addresses, then by default it returns a list of all Customers, each with the Address related object. However, if sourceData has been set to an existing Customer object, say retrieved by another LiveVariable, then the LiveVariable will return that Customer with that Address related object.

    For the other operations, sourceData specifies the data that will be saved on the server (inserted, updated, or deleted). This is needed only if you are trying to do an insert/update/delete outside a LiveFormotherwise the LiveForm handles these operations correctly for you w/out specifying sourceData