[xwiki-devs] How to get space name(s) when I execute macro in java?
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use. -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Try to inject DocumentAccessBridge: https://github.com/xwiki/xwiki-platform/blob/a28f5d4f98b5011e59fd0781ea608de... 2016-04-13 11:21 GMT+02:00 abtv <[email protected]>:
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project
You have this information in the TransformationContext by walking the XDOM upward and finding a location metadata Thanks -Vincent
On 13 Apr 2016, at 11:21, abtv <[email protected]> wrote:
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac...
On 13 Apr 2016, at 12:05, Vincent Massol <[email protected]> wrote:
You have this information in the TransformationContext by walking the XDOM upward and finding a location metadata
It’s called “source” actually, see https://github.com/xwiki/xwiki-rendering/blob/7cac6e9dc68d6334deaf947cc15d8c... Example code to do this: https://github.com/xwiki/xwiki-rendering/blob/9fbb0423b93290463f2d27ae6be2fe... Thanks -Vincent
Thanks -Vincent
On 13 Apr 2016, at 11:21, abtv <[email protected]> wrote:
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac...
It depends you want the current space or the space where the document calling the macro is located. They could be different in case of include for example. On Wed, Apr 13, 2016 at 12:10 PM, Vincent Massol <[email protected]> wrote:
On 13 Apr 2016, at 12:05, Vincent Massol <[email protected]> wrote:
You have this information in the TransformationContext by walking the XDOM upward and finding a location metadata
It’s called “source” actually, see https://github.com/xwiki/xwiki-rendering/blob/7cac6e9dc68d6334deaf947cc15d8c...
Example code to do this: https://github.com/xwiki/xwiki-rendering/blob/9fbb0423b93290463f2d27ae6be2fe...
Thanks -Vincent
Thanks -Vincent
On 13 Apr 2016, at 11:21, abtv <[email protected]> wrote:
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac...
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On 13 Apr 2016, at 12:12, Thomas Mortagne <[email protected]> wrote:
It depends you want the current space or the space where the document calling the macro is located. They could be different in case of include for example.
Indeed. I was answering to: " I don't have access to the space name on which the macro is called.” Thanks -Vincent
On Wed, Apr 13, 2016 at 12:10 PM, Vincent Massol <[email protected]> wrote:
On 13 Apr 2016, at 12:05, Vincent Massol <[email protected]> wrote:
You have this information in the TransformationContext by walking the XDOM upward and finding a location metadata
It’s called “source” actually, see https://github.com/xwiki/xwiki-rendering/blob/7cac6e9dc68d6334deaf947cc15d8c...
Example code to do this: https://github.com/xwiki/xwiki-rendering/blob/9fbb0423b93290463f2d27ae6be2fe...
Thanks -Vincent
Thanks -Vincent
On 13 Apr 2016, at 11:21, abtv <[email protected]> wrote:
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac...
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On 13 Apr 2016, at 12:10, Vincent Massol <[email protected]> wrote:
On 13 Apr 2016, at 12:05, Vincent Massol <[email protected]> wrote:
You have this information in the TransformationContext by walking the XDOM upward and finding a location metadata
It’s called “source” actually, see https://github.com/xwiki/xwiki-rendering/blob/7cac6e9dc68d6334deaf947cc15d8c...
Example code to do this: https://github.com/xwiki/xwiki-rendering/blob/9fbb0423b93290463f2d27ae6be2fe...
I’ve documented it quickly at: http://rendering.xwiki.org/xwiki/bin/view/Main/ExtendingMacro#HFindingtheloc... Hope it helps Thanks -Vincent
Thanks -Vincent
Thanks -Vincent
On 13 Apr 2016, at 11:21, abtv <[email protected]> wrote:
I extended AbstractMacro with my class. When I execute macro with `execute` function I don't have access to the space name on which the macro is called. I would like to customize output depending on the current space. All I need is just space name as a string. How to get space name inside `execute` function? I suppose it can be some dependency injection, but I'm don't know what to use.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-space-name-s-when-I-execute-mac...
participants (4)
-
abtv -
Guillaume Delhumeau -
Thomas Mortagne -
Vincent Massol