Module WeblogicPortal::RenderPortlet
In: lib/weblogic_portal/render_portlet.rb

This module mixes in portlet support to ActionView::Base.render so that WebLogic Portal portlet can be rendered in a Rails application. This is the equivalent to the WebLogic Portal’s <render:portalFacet/> JSP tag.

Synopsys

    render :portlet => 'my.portlet', :label =>"_picture", :embedded => false

Render Options

:portlet
The url to the portlet, relative to the portal’s context root.
:label
Optional. Used as a unique id on the page so that ajax methods target the proper containers. Also used as the portlet instance id to uniquely identify this portlet instance (for this user) on the server.

Note: The label must be unique on the page, in order that javascript methods function properly. It should also indicate a unique portlet id for a particlular user, so generally should be unique for the entire project, unless a portlet instance is explicitly desired to be shared on multiple pages.The default scheme uses the controller and action name, plus a per-page counter.

:embedded
Optional. Mode to embed the portlet. Set to false to force ajax-style portlets. Set to true to force embedding the portlet in an ifrmae. The default is to do whatever is likely to work based on the base_url setting (cross-site requests default to iframe). Default can be forced by setting embedded_default in the config.

Methods

Public Instance methods

[Source]

    # File lib/weblogic_portal/render_portlet.rb, line 44
44:       def render( options = {}, old_local_assigns = {}, &block )
45:         if options.is_a?(Hash) && portlet = options.delete(:portlet)
46:           render_wlp_portlet portlet, options
47:         else
48:           render_non_wlp options, old_local_assigns, &block
49:         end
50:       end

[Source]

    # File lib/weblogic_portal/render_portlet.rb, line 54
54:       def render_wlp_portlet( portlet, options )
55:         
56:         config = Configuration.instance
57:         
58:         # if a label is not explicitly given (recommended, but not required), 
59:         # generate a (hopefully) page-unique id for the portlet
60:         # @wlp_unique_counter is incremented for each occurence
61:         # of render_portlet on the page
62:         if options[:label].nil?
63:           @wlp_unique_counter ||= 0
64:           unique_counter = @wlp_unique_counter
65:           options[:label] = eval config.portlet_label_template
66:           @wlp_unique_counter += 1
67:         end
68:         
69:         # output the required javascript tag, but only once per page
70:         out = ''
71:         unless @wlp_not_first_page_render
72:           out << content_tag( :script, '', :type => 'text/javascript', :src => config.async_javascript_url)
73:           @wlp_not_first_page_render = true
74:         end      
75:         
76:         # construct the container object for all the render knowledge
77:         wlp = Portlet.new self, portlet, options 
78:         out << wlp.render_template
79:       end

[Validate]