Get space information in XWork Module

Hello guys!

Is it possible to get space information (like spaceKey) inside an XWork Action class?

I do have the following

<xwork name="macrodialogaction" key="macrodialogaction">
		<package name="editor" extends="default" namespace="/plugins/macro">
			<default-interceptor-ref name="defaultStack" />
			<action name="editor"
					class="app.server.actions.MacroEditorAction">
				<result name="success" type="velocity">/templates/macro-editor/macro-editor.vm</result>
				<result name="error" type="velocity">/templates/macro-editor/error.vm</result>
			</action>
		</package>
	</xwork>

and my MacroEditorAction signature follows
public class MacroEditorAction extends ConfluenceActionSupport implements PageAware.
Is it possible to access the spaceKey where the action is being loaded in the MacroEditorAction?

Thanks in advance!
Luis

Dear Luis,

as you implement PageAware I would assume that you could use getPage().getSpace().getSpaceKey().

Kind regards

Andreas

Hello @andreas1,
Thanks for your response.

I’m sorry for the dumb question but given that I’m implementing PageAware, I have to override the getPage method. In this case, what should I write in getPage function?

The default is

@Override
public AbstractPage getPage() { return null; }

which obviously causes an error if I somewhere in the code write getPage().getSpaceKey().
How do I pass the page to the my MacroEditorAction class?

Thanks!

Dear Luis,

I never tried in myself but doesn’t this article help? https://developer.atlassian.com/server/confluence/adding-a-custom-action-to-confluence/

Kind regards

Andreas