Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

pagelocator

SteveK May 28, 2015

Atlassian Dev newbie here.

I'm trying to write my first Confluence Servlet Filter module. I want to be able to look up a page within my Filter code using the PageLocator classes. Currently, I have things hardcoded to get my feet wet. I'm certain the space and title exist, but getPage() always throws NullPointerException. I also tried the IDPageLocater – I'm certain the pageID I'm using exists.

DefaultPageManager pageManager = new DefaultPageManager();
TitleAndSpaceKeyPageLocator pageLocator = new TitleAndSpaceKeyPageLocator(pageManager, "~admin","Test Page 1");
//IdPageLocator pageLocator = new IdPageLocator(pageManager, 1474562);
Page page = pageLocator.getPage(); //always throws NullPointerException

Any suggestions are appreciated.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Username May 28, 2015

Why not use the PageManager module?

private final PageManager pm; // init pm in the constructor 
Page p = pm.getPage(context.getSpaceKey(), context.getPageContext().getPageTitle());

 

will get you the current page your macro is executing in now, for example.

Have a look here 

SteveK May 28, 2015

I tried using PageManager earlier with the same result. I wasn't using Construction-based injection (https://developer.atlassian.com/confdev/confluence-plugin-guide/writing-confluence-plugins/accessing-confluence-components-from-plugin-modules). Thanks for leading me to the answer.

TAGS
AUG Leaders

Atlassian Community Events