| Class | WeblogicPortal::Portlet |
| In: |
lib/weblogic_portal/render_portlet.rb
|
| Parent: | Object |
Holds the knowledge needed for outputting the html required to render a portlet.
This class is designed to be used from WeblogicPortal::RenderPortlet.
| id | [R] | |
| options | [R] | |
| portlet | [R] |
Create a Portlet instance.
Arguments:
The id attribute is set from the :label option, if set (which it should be when called from RenderPortlet).
# File lib/weblogic_portal/render_portlet.rb, line 104
104: def initialize view, portlet, options = {}
105: @view = view # we need the view instance for constructing proper urls
106: @portlet = portlet
107: @options = options
108: # some label is required. Should have been set, but ensure it is something
109: @id = options[:label] ||= '_wlponrails'
110: end
will this portlet embed as an iframe, or use ajax?
# File lib/weblogic_portal/render_portlet.rb, line 113
113: def iframe?
114: if options.has_key? :embedded
115: options[:embedded]
116: else
117: config.embedded_default
118: end
119: end
return the portlet url. Constructed by eval’ing portlet_url_template from the Configuration.
# File lib/weblogic_portal/render_portlet.rb, line 123
123: def portlet_url
124: eval config.portlet_url_template
125: end
construct the postback url. This is generally the url back to the page containing the portlets.
# File lib/weblogic_portal/render_portlet.rb, line 129
129: def postback_url
130: @view.url_for :overwrite_params=>{:_nfpb=>'true'}
131: end
Returns the content of the evaluated template file, as defined by either portlet_content_iframe or portlet_content_ajax from the configuration (depending on the value of iframe?)
# File lib/weblogic_portal/render_portlet.rb, line 136
136: def render_template
137: b = binding
138: f = iframe? ? config.portlet_content_iframe : config.portlet_content_ajax
139: template = File.expand_path( f, File.dirname(__FILE__) )
140: ERB.new( File.read( template ), 0, "<>" ).result( b )
141: end