Class: Lapillus::Fragment

Inherits:
Container show all
Defined in:
lib/lapillus/containers.rb

Direct Known Subclasses

SingleView

Instance Attribute Summary

Attributes inherited from Container

#components

Attributes inherited from Component

#behaviours, #identifier, #model, #property, #visible

Instance Method Summary collapse

Methods inherited from Container

#[], #add, add_component, #component, fileuploadfield, image, label, listview, panel, password_textfield, #post, textarea, textfield

Methods inherited from Component

#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage

Constructor Details

#initialize(id, fragment_id, model = nil) ⇒ Fragment

Returns a new instance of Fragment.



171
172
173
174
# File 'lib/lapillus/containers.rb', line 171

def initialize(id, fragment_id, model=nil)
  super(id, model)
  @fragment_id = fragment_id
end

Instance Method Details

#render_container(container_element) ⇒ Object



176
177
178
179
180
181
182
183
# File 'lib/lapillus/containers.rb', line 176

def render_container(container_element)
  root_node=container_element.root
  fragment = REXML::XPath.first( root_node, "//*[@lapillus:id=\"#{@fragment_id}\"]" )
  raise "Fragment with identifier "+@fragment_id+" not found!" if fragment == nil 
  new_element = REXML::Element.new(container_element)   
  render_children(fragment, new_element)
  return new_element
end