[xwiki-devs] How to call rendering component ?
Hello, In velocity I was using : $services.rendering.parse(...) $services.rendering.render(...) My question is : how can I inject the component to do that from a java component, specifying the parser/syntax ? I just had a quick look to the tests but they use the componentManager while I preferred to use annotations until now, so I'm a bit lost ... :) Thanks Jeremie -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi, On Sat, Apr 21, 2012 at 10:26 PM, jerem <[email protected]> wrote:
Hello,
In velocity I was using : $services.rendering.parse(...) $services.rendering.render(...)
My question is : how can I inject the component to do that from a java component, specifying the parser/syntax ?
I just had a quick look to the tests but they use the componentManager while I preferred to use annotations until now, so I'm a bit lost ... :)
Actually what you get in $services.rendering is very script oriented and in Java you don't really have a unique entry point. For example to get a parser for syntax xwiki/2.1 to produce a XDOM you can inject the following: @Inject @Named("xwiki/2.1") private Parser xwikiParser; See http://rendering.xwiki.org for more about rendering framework in general.
Thanks Jeremie
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Thanks Thomas ! Meanwhile I tried something like this : ... but I could not test it because my component seems a bit broken right now ... Based on what you said I'm not sure it can work like this. Thanks, Jeremie -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On Mon, Apr 23, 2012 at 12:34 PM, jerem <[email protected]> wrote:
Thanks Thomas !
Meanwhile I tried something like this :
... but I could not test it because my component seems a bit broken right now ... Based on what you said I'm not sure it can work like this.
What are you trying to do ?
Thanks, Jeremie
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
I'm trying to convert HTML content to plain text. The background is that it's used in the Mail Archive app I'm writing, to provide indexable content in mail pages when only html is provided - html content being zipped, it's not indexable. I just convert the html to plain text and store it. Works great from scripting API but now I'm trying to reproduce inside Java component. -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On Mon, Apr 23, 2012 at 1:02 PM, jerem <[email protected]> wrote:
I'm trying to convert HTML content to plain text. The background is that it's used in the Mail Archive app I'm writing, to provide indexable content in mail pages when only html is provided - html content being zipped, it's not indexable. I just convert the html to plain text and store it. Works great from scripting API but now I'm trying to reproduce inside Java component.
In that case it would probably be better to use the StreamParser which does not create a XDOM and directly provide events to the renderer. Here is an example that would probably help you: look at fromHTML in https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... That's what the WYSIWYG use to convert its HTML content to wiki content when saving. In you case instead of a provided wiki syntax you would use "plain/1.0". Note that you can directly use "html/4.01" stream parser instead of executing yourself the HTMLCleaner.
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
That's exactly what I need, many thanks ! :) -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-call-rendering-component-tp7487904p... Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (2)
-
jerem -
Thomas Mortagne