def render(self):
     relation_id = self.relation.id
     if self.relation.linkage.relation.cardinality.id == 'ONE_TO_MANY':
         multi_selection = 'true'
     else:
         multi_selection = 'false'
     i = ScopedMarkup()
     i.script('var objectPicker = new p2.ObjectPicker(\'%s\', \'%s\', %s, \'%s\');' % (
         self.relation_source.id,
         relation_id,
         multi_selection,
         self.collection_id
     ))
     i.html('<div style="position: relative">')
     a = 0
     query = super(ObjectPicker, self).query()
     for (setobject, linked) in query:
         alternation = (a % 2 == 0) and 'even' or 'odd'
         a += 1
         id = generate_random_identifier()
         i.html("""
                <div style="position:absolute; z-index:10000;">
                     <input id="%s" value="%s" type="checkbox" />
                </div>
                """ % (id, setobject.id))
         subform = self.call_subform(self.collection_id ,setobject.id, linked, alternation)
         subform = subform.replace(r'\"', r'\\\"')
         i.html(subform)
         i.html('</div>')
         i.script('objectPicker.registerCheckbox($(\'#%s\'), %s)' % (id, linked)) 
     html = i.render()
     return html
 def render(self):
     id = self.generate_random_identifier()
     i = ScopedMarkup()
     i.html('<div class="p2-span" id="%s" data-span-type="%s" data-field-identifier="%s" data-span-identifier="%s" style="%s">' % (
         id,
         self.context.span_type,
         self.context.field_identifier,
         self.context.span_identifier,
         self.context.css
     ))
     i.script('var info = $.parseJSON(%s);' % i.literal(self.context.get_info()))
     if self.source_id != None:
         i.script('var sourceId = \'%s\';' % self.source_id)
     else:
         i.script('var sourceId = null;')
     i.script('$(\'#%s\').data(\'data-object\', new p2.Span.Alphanumeric($(\'#%s\'), sourceId, \'%s\', info));' % (id, id, self.application_url()))
     i.html('</div>')
     html = i.render()
     return html