Class: UU::OS::GVC::UxmlFragment

Inherits:
Component show all
Defined in:
uu_os_gvc-0.28.16/lib/uu/os/gvc/uxmlfragment.rb

Overview

Uxmlfragment component. This component is meant for creating dynamic views by supplying fragments of UXML (can contain other gvc components, but is restrictive for other uxml elements, see documentation). Documentation at: ues:UNI-BT:UES.DOC/EDITOR_V1/uu.os.gvc.uxmlfragment

Instance Attribute Summary (collapse)

Attributes inherited from Component

#attributes, #code, #component_type, #form, #height, #id, #name, #width

Method Summary

Methods inherited from Component

#add_message, #focus, #messages

Instance Attribute Details

- (Object) data

Use this to set a fragment of UXML code (only String) you want to render. The UXML has to be valid and contain only allowed elements (see ues:UNI-BT:UES.DOC/EDITOR_V1/uu.os.gvc.uxmlfragment). The UXML doesnt need to have one root element containing everything - this the only exception to what should a well-formed XML look like. You can retrieve the UXML back using this accessor but only within the scope of the same event in which the UXML was set. When handling another event in your controller, you wont be able to retrieve UXML from previous events, because for traffic-saving reasons its not being sent as a part of the controller's viewmodel. If you wish to keep the state of your UXML between events it is advised not to entirely circumvent this limitation by manually putting your UXML back into the viewmodel as a custom attribute (anti-pattern!), but rather to use a templating engine (erb and the like) to keep the bulk of the uxml as a template - a stateless resource that then understandably doesnt need to be a part of the viewmodel and keep only the necessary pieces of data, that define the state and populate the template, in the viewmodel.

Examples:

# Basic usage example:
# Construct an UXML snippet with hello world and informing about current time in bold text
uxml = "<core:text>Hello world! </core:text><core:text bold=\"true\">Current time is: #{Time.now}</core:text>"

# Set the UXML to a fragment component
fragment_component = view.get_components_by_code('fragment')[0]
fragment_component.data = uxml #Done! Now you should see your UXML hello world text rendered in the browser as HTML.


26
27
28
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/uxmlfragment.rb', line 26

def data
  @data
end

- (Object) data_uri (readonly)

Attribute containing uri of the fragment component's datasource (should be valid UXML). It can be set only by editing the containing sheet's content.



30
31
32
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/uxmlfragment.rb', line 30

def data_uri
  @data_uri
end