which are all the objects that I can use in User Macro environment??

I need to know if a page is watching... I did something like this to get the favourites pages and generate a list... But I hasn't any object to get isWatching or something....

I know that exists this objects:

$action

$pageManager

etc... :S

I found this code in the decorators.vmd

#set ($pageNotifications = $helper.action.pageNotificationsForUser)

#if ($pageNotifications)

<table class="tableview condensed">

<tr>

<th colspan="2" class="colHeaderLink">$action.getText('page.watches')</th>

</tr>

#foreach ($notification in $pageNotifications)

<tr #alternateRowColors()>

<td class="tableview-action-text">

#contentLink($notification.page)

<!--<a href="$req.contextPath$notification.page.urlPath">$notification.page.title</a>-->

</td>

<td class="tableview-action-icon">

<a href="${req.contextPath}/users/removepagenotification.action?pageId=$notification.page.id"><img src="$staticResourceUrlPrefix/images/icons/watch_cancel_16.gif" height="16" width="16" title="$action.getText('stop.watching.page')"></a>

</td>

</tr>

#end

</table>

#end

can I use something like this in the User macro Environment?????

please help....

2 answers

This widget could not be displayed.

Take this little usermacro as a starter for your further implementation

## @noparams

#set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
   
#set($notificationmanager = $containerContext.getComponent('notificationManager')) 

#set ( $userWatchingSpace = $notificationmanager.isUserWatchingPageOrSpace($action.remoteUser,  $space, null))
#set ( $userWatchingPage = $notificationmanager.isUserWatchingPageOrSpace($action.remoteUser, null, $content))

User is #if(!$userWatchingSpace) not #end watching space.
&lt;br&gt;
User is #if(!$userWatchingPage ) not #end watching page.

The Usermacro available variables can be found here

https://developer.atlassian.com/display/CONFDEV/Confluence+Objects+Accessible+From+Velocity

This widget could not be displayed.

Hi, I can answer the general part of your question :

the usermacros are writtenin Velocity as well, so go searching for "Objects, available in velocity" or "objects available for templates".

Check the "shared usermacros" sourcecodes for further inspiration as well.

So it should be there as well.

Josh

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

151 views 16 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you