27
SAP AG 2005, Title of Presentation / Speaker Name / 1 Introduction to UI elements Putting data on the screen: Context binding Controlling the behaviour of UI elements using context binding Using a basic composite UI element Contents: UI Elements

UI Elements

  • Upload
    phani

  • View
    227

  • Download
    2

Embed Size (px)

DESCRIPTION

webdynpro ui

Citation preview

  • UI ElementsIntroduction to UI elementsPutting data on the screen: Context bindingControlling the behaviour of UI elements using context bindingUsing a basic composite UI elementContents:

  • What is a UI element?A UI element is any graphical entity that occupies a position within a view layout.Label UI ElementTextView UI ElementInputField UI ElementGroup UI Element

  • How are UI elements arranged?All view layouts are composed from a hierarchy of UI elements.The root node is always of type TransparentContainer, and is always called RootUIElementContainer. You cannot change this, it is hard coded!Hard coded RootUIElementContainer

  • UI Element categoriesVarious categories of UI elements are supportedOfficeControlGantt, NetworkInteractiveFormBusinessGraphics, GeoMapBI Application FrameMessageAreaEach UI element object is represented as an abstract class that is independent of any client presentation layer.

  • Using the View EditorChoose Change from the context menu of a view

  • View Editor The Layout view will be selected by default3a. UI elements can be added by drag and drop from the toolbar3b. In the hierarchical representation - UI elements can also be added by selecting Insert Element via context menuProperties of the UI elements can be changedChoose Change from the context menu of a view

  • Context Binding (1)Context Binding is the association of a UI element property with a node or attribute in a view controllers context.The UI element property then uses the context node or attribute as it data source. If the UI element property can be updated by the user, then new value replaces the value in the context.UI LayoutAutomatic data transport

  • Context Binding (2)Context Binding decouples the UI element object from the application coding.ImplementationNavigation PlugsStandard Hook MethodsInstance MethodsActionsApplication CodingUI LayoutAutomatic data transport

  • Context Binding (3)In order to control the behaviour of UI elements, you should manipulate the context nodes or attributes to which the UI elements are bound.ImplementationNavigation PlugsStandard Hook MethodsInstance MethodsActionsUpdatesUI LayoutAutomatic data transport

  • Putting data on the screen (1)1) Declare context attribute

  • Putting data on the screen (2)1) Declare context attribute2) Create UI element on layout

  • Putting data on the screen (3)1) Declare context attribute2) Create UI element on layout3) Bind UI element to context attribute

  • Putting data on the screen (4)1) Declare context attribute2) Create UI element on layout3) Bind UI element to context attribute

  • Putting data on the screen (5)The order of attributes within a node has no influence on the order in which the data they hold is displayed.The binding between a UI element and a context attribute is a two-way relationship:Data from the context is transported to the client during screen renderingData entered by the user is transported back to the context when the HTTP round-trip is processed.Notice that all the arrows are double headed!

  • Setting the UI element behaviourA hard coded UI element property value gives the UI element a fixed behaviour.This arrangement does not lend itself to good UI design and should be avoided!Since the value for the readOnly property is hard coded and not flexibleThe corresponding input field will always be open for input.

  • Controlling UI element behaviour (1)By creating a new attribute, you can control the property of one or more UI elements.A new attribute has been created that is of the correct data type to control the readOnly attribute3.The value of the attribute can be set by default or in a appropriate method accessing the attribute during runtime For the UI element are according data types available. The readOnly UI element property can be controlled by an attribute of type WDY_BOOLEAN ('X' == True, ' == False)

  • Controlling UI element behaviour (2)Binding UI element properties to suitable context attributes is a very much better, and more flexible technique for UI design.The readOnly property can now be bound to a boolean context attribute.The input field will now only be open for input if the context attribute is set to == true.

  • Test Page for UI ElementsThe Test WD application wdr_test_ui_elements allows you to investigate and checkout the function of the available UI elements.

    UI element appearancePossible UI EventsAvailable Properties

  • Introduction to Composite UI Elements (1)A composite UI element is any UI element that requires child UI elements. Examples: The Table and Tree UI elements.Rendered table UI elementsRendered tree UI element

  • Introduction to Composite UI Elements (2)Child UI Elements. The TableColumn elements are also composite UI elements.Composite UI elements are incapable of displaying information on their own.They must have child UI elements in order to function correctly.hierarchical representation of a Table UI elementComposite Table UI Element.

  • The Table UI elementEach TableColumn UI Element has a Caption and TextView UI element as its children.The Table is an example of a composite UI element.A Tables child elements are also composite.Composite TableColumn UI Element.hierarchical representation of a Table UI element

  • Binding a Table UI element to the contextView layoutThe UI elements making up a Table hierarchy require several context bindings in order to function correctly.The Table UI element must have its dataSource property bound to a context node of cardinality 0..n or 1..n

  • Binding TableColumn UI elements to the contextView layoutEach context attribute is a potential candidate for becoming a TableColumn.TableColumn UI elements must be bound to child attributes of the same node to which the parent Table UI element is bound.

  • Defining child UI elements for a TableColumnView layoutOptional column header (Caption UI element)Mandatory table cell editor UI elementA TableColumn UI element must have a UI element nominated to act as the table cell editor. The column header caption is optional.

  • Table row selectionEach element in the node collection becomes a table rowRuntime dataView layoutSelecting a row on the screen causes the nodes lead selection to be altered

  • Selecting multiple rows from a tableDefine the nodes selection cardinalityView layoutA nodes selection cardinality controls how many elements may be selected simultaneously within the element collection. 0..1 is the default.

  • UI Elements: Unit SummaryYou should now be able to:The UI element conceptHow to put data on the screen through context bindingControl the behaviour of UI elements using context bindingThe use of a basic composite UI element

    Does that mean all UI elements are visible on the screen? No! There are certain UI elements that are not visible on the screen, such as the TransparentContainer or the ViewUIElementContainer. Nonetheless, these UI elements occupy a position in the UI element hierarchy just like any other visible UI element.Is a UI element then just some HTML to represent an input field or a drop down list or a checkbox or something like that? No, not necessarily! Web Dynpro has been designed to operate with any form-based user interface. This is most probably going to be a standard browser, but it could also be a Pocket PC or a Blackberry in a future release.All subsequent UI elements added to a view layout are hierarchically subordinate to the UI element called RootUIElementContainer.There are numerous user interface elements available for designing the user interface of a Web Dynpro application.All available user interface elements are divided into categories and can be selected using buttons in the view designer.Simple Standard elements are: Button, Caption, CheckBox, CheckBoxGroup, DropDownByIndex, DropDownByKey, FileDownload, FileUpload, HorizontalGutter, IFrame, Image, InputField, InvisibleElement, Label, LintToAction, LinkToURL, ProgressIndicator, RadioButton, RadioButtonGroupByIndex, RadioButtonGroupByKey, TextEdit, TextView, TimedTrigger, ViewContainerUIElementComplex Standard elements are: DateNavigator, PhaseIndicator, RoadMap, TabStrip, Table, TreeContainer Standard Elements are: Group, ScrollContainer, TransparentContainer, Tray

    View Editor The View Editor is a Web Dynpro specific tool that allows you to edit a view layout. The View Editor is only available when you are editing a view controller. It will not appear when you edit a custom controller because these controllers have no visual interface.Adding UI elements to the layoutTo add any UI element, drag and drop it from the toolbar on the left hand side of the View Editor.Adding a new UI element in the hierarchical representation is also possible. This can be done from the context menu of an element in the hierarchy, that can have child elements (e.g. a Transparent Container element, a Group element). Positioning of the UI elements is done by changing the element hierarchy.

    UI elements properties The Properties tab displays all properties of a given UI element. If a UI element support events, the supported client-side events chosen from a drop down list in the property tab (onAction). To handle these client-side events, previously defined Actions have to be associated with each of the events. Once a UI element property is bound to a context node or attribute, the context data is used to supply a value to the UI element property. If the UI element property is one that the user can update (e.g. the value property of an InputField UI element), then the context is automatically updated with new value during the next round trip.Almost all the properties of a UI element can be bound either to a context node or attribute.A binding relationship can only exist between the context and UI elements of the same view controller.A Web Dynpro view controller has been constructed in such a way that it is normally possible to have full control over the appearance of the screen layout, without ever needing direct access the UI element objects.Any property over which you wish to have programmatic control should be bound to an appropriate context node or attribute.Putting data on the screen In order for a UI element to display any data, at the very least, its value property must be bound to an appropriate context node or attribute (there are very few UI elements that do not have a value property HorizontalGutter for instance).The following steps are the minimum requirement for putting some data on the screen:Create a node or attribute in the view controllers context that will contain the data. It is not important whether this is a mapped context node or not.Putting data on the screen In order for a UI element to display any data, at the very least, its value property must be bound to an appropriate context node or attribute (there are very few UI elements that do not have a value property HorizontalGutter for instance).The following steps are the minimum requirement for putting some data on the screen:Create a node or attribute in the view controllers context that will contain the data. It is not important whether this a mapped context node or not.Create the UI element on your view layout.Putting data on the screen In order for a UI element to display any data, at the very least, its value property must be bound to an appropriate context node or attribute (there are very few UI elements that do not have a value property HorizontalGutter for instance).The following steps are the minimum requirement for putting some data on the screen:Create a node or attribute in the view controllers context that will contain the data. It is not important whether this a mapped context node or not.Create the UI element on your view layout.Display the UI elements properties by clicking on the UI element itself in the view layout, and then select the Properties view. Here, you will see a in the column Binding yellow icons with a empty cycle against any UI element property that requires a context binding. Assign the required binding by clicking on this button. A pop-up window will be displayed showing the view controllers context. Select an appropriate node or attribute and then this value will be transferred back to the Properties view. The empty cycle will now be a replaced with a green tick icon, and the context path will be displayed in the field. The UI element on the view layout will now also display the context path of the node or attribute to which it is bound.The complete binding relationship The establishment of a binding relationship instructs the Web Dynpro screen renderer to obtain the value for UI element property from the context node or attribute to which it is bound. Context binding is not limited to simply supplying and InputField, say, with a value. A UI elements value property is just one of the many properties that can be supplied with data through a binding relationship. This is the mechanism by which a view controller can adjust the appearance and behaviour of its view layout without ever needing to access the UI element objects themselves.Ordering of fields on the screen As can be seen from the graphic above, there is no requirement to have the UI elements in the same order as the context attributes to which they are boundContext binding is a two-way relationship! Once a binding relationship has been declared, the data in the bound nodes and attributes is transported automatically to the corresponding UI elements. After the user has interacted with the screen and initiated an HTTP round-trip, the new or modified data in the UI elements is transported back to the same nodes and attributes in the view controllers context. By the time the Web Dynpro Framework hands controller over to your action handler, the context already holds the updated information. This two-way transport process is entirely automatic, and requires no action on the part of the application developer. All you need to do is declare a binding relationship.UI Element properties The value of a UI element property can either be hard coded, or it can be bound to a context attribute of a suitable data type. The graphic above illustrates this principle for the readOnly property, but can be applied to almost all properties of a UI element.Changing hard coded UI element property values If you need to change the value of a UI element property value that has been hard coded at design time, this can be done at runtime by placing coding in the view controllers wdDoModifyView() method. But this type of architecture is considered a poor design and should be avoided!Creating context attributes for controlling UI element properties In order to programmatically control the behaviour of a UI element, you should create a context attribute that is of the same data type as the property you wish to control. Your WDDOINIT or action handler methods can then modify the value of the context attribute and control the behaviour of the UI element, without ever needing to access the UI element object itself.The setting of the attribute values will be discussed in a following chapter.Controlling a UI element property Once the context attribute has been created, it must be bound to the appropriate property of the UI element. In this case, the readOnly property of an InputField UI element has been bound to a boolean value attribute. Now the WDDOINIT method, or one of your action handlers, can manipulate the context attribute. This technique gives you programmatic control over any bindable UI element property, and allows you to control the appearance of the view layout without any need to access the UI element objects themselves.Composite UI elementsCertain UI elements are displayed on the screen as aggregations of simpler, more basic, UI elements. The Table UI element is a good example here.Without the subordinate, or child UI elements, a composite UI element is not capable of displaying any information.Composite UI elements such as Group and Tray have a mandatory Caption child UI element, but beyond that, their structure is entirely user defined.Composite UI elements such as Table and Tree however, require a slightly more complex child structure.Composite UI elements Certain UI elements are displayed on the screen as aggregations of simpler, more basic, UI elements. The Table UI element is a good example here. Notice in the graphic, that the Table UI element acts as a parent for several TableColumn UI elements; each of which acts as the parent for a Caption and TextView UI element.Without the subordinate, or child UI elements, a composite UI element is not capable of displaying any information.

    Table UI Element The Table UI element allows the two-dimensional display of data in cells arranged in rows and columns. The UI element consists of an optional header area, zero or more rows, and footer area. The element at the lead selection in the context node becomes the highlighted row when displayed on the screen. The Table UI element must contain at least one TableColumn UI element. The caption appearing at the top of the table (in this case Flights) is optional.TableColumn UI Elements TableColumn UI elements must be bound to the attributes of the node to which the parent Table UI element is bound. Any node attribute of a simple data type is a candidate for becoming a table column. TableColumn UI elements are composite UI elements! This means that they must have child UI elements in order to function correctly.Child UI elements of a TableColumn In order to present information to the user, a TableColumn UI element must have a child UI element that will act as the cell editor. In order to decide which UI element to use, ask yourself this question: Within which type of UI element do I want the column data to appear? The answer to this question then determines how this user interacts with the data in that one column. Dont think that because the name of this role contains the word editor that the user can necessarily change the data. If you select some sort of display only UI element such as a TextView, then the user will not be able to modify the data the UI element you chose does not allow it! If on the other hand, you chose an InputField to be the table cell editor, then all the cells appearing in that column would, by default, be open for input. The caption appearing as the column header is optional, but if defined, will always be of type Caption.Table row selection and the effect on a nodes lead selection Any time you click on a table row on the rendered screen, an HTTP round trip is initiated. This round trip will cause the lead selection of the corresponding context node to which this table is bound to be adjusted. In the graphic above, the node collection contains two elements, and the user has clicked on the second table row. This corresponds to element 2 of node FLIGHTS, and the lead selection of this node is altered to reflect the users selection. There will be as many rows in the table as there are elements in the node collection. You can also define a Web Dynpro Action and associate it with the Tables onLeadSelect event. Now, not only will the node collections lead selection element be adjusted when the user clicks on a table, but your action handler will also be invoked.Multiple selection of rows from a table Before a user is permitted to select multiple rows from a table (by holding down shift, and clicking on the required rows), the context node to which the Table UI element is bound must have a selection cardinality of either 0..n or 1..n. The default selection cardinality setting for any context node is 0..1, meaning that zero or one elements may be selected at any one time.Finding the context nodes with multiple element selections Each node provides the method GET_SELECTED_ELEMENTS which returns all selected elements in an internal table (type WDR_CONTEXT_ELEMENT_SET). Note: A line of a table in a view which is selected with the lead selection will be only part of the result of the method GET_SELECTED_ELEMENTS if the parameter INCLUDING_LEAD_SELECTION of the method is set to true.