On 16 July 2011 19:51, Franklin, Matthew B. <[email protected]> wrote: > You can also autowire in the user service and get the current user from there.
Ahhh... yes. I'm definitely showing my rusty Java/Spring skills here. Thanks for the pointer, I'm now well on my way again. Ross > > > > Sent via a mobile device. Please excuse typos or brevity. > > -----Original Message----- > From: Ross Gardler [mailto:[email protected]] > Sent: Saturday, July 16, 2011 08:11 AM Eastern Standard Time > To: [email protected] > Subject: Getting users for widget > > I finally found some airport/travel time to work on the Wookie > integration again. I'm almost there, but not quite. > > I need to be able to get at the user from > w3CWidgetRenderer.render(RegionWidget) > > public String render(RegionWidget item) { > Widget widget = item.getWidget(); > if(!WIDGET_TYPE.equals(widget.getType())) { > throw new NotSupportedException("Invalid widget type > passed to renderer: " + widget.getType()); > } > // FIXME: got to find the user and context > // the user is held in the page object, do we have a refernece > to it from here? > Widget contextualizedWidget = widgetService.getWidget(null, > null, widget); > String url = contextualizedWidget == null ? null : > contextualizedWidget.getUrl(); > return String.format(IFRAME_MARKUP, WIDGET_TYPE, item.getId(), url); > } > > As the comment indicates the user is stored in the page object: > > Page -> Regions -> RegionWidget > > The Page object is available in the JSP and I could pass in the user from > there: > > <portal:render-widget regionWidget="${regionWidget}" > user="${${defaultPage.owner.id}}"/> > > Another option is to change the unidirectional one-to-many mapping of > Region -> RegionWidgets and Page -> RegionWidgets to biderectional > mappings. > > A third option would be... (that's a question ;-) > > Ross > > > -- > Ross Gardler (@rgardler) > Programme Leader (Open Development) > OpenDirective http://opendirective.com > -- Ross Gardler (@rgardler) Programme Leader (Open Development) OpenDirective http://opendirective.com
