Package org.jboss.seam.wiki.core.plugin

Examples of org.jboss.seam.wiki.core.plugin.WikiPluginMacro


                parser.setRenderer(new NullWikiTextRenderer() {
                    @Override
                    public String renderMacro(WikiTextMacro macro) {

                        if (macro.getName().equals("lastModifiedDocuments")) {
                            WikiPluginMacro pluginMacro = PluginRegistry.instance().createWikiPluginMacro(macro);
                            LastModifiedDocumentsPreferences lmdPrefs =
                                    Preferences.instance().get(LastModifiedDocumentsPreferences.class, pluginMacro);
                            assert lmdPrefs.getDocumentTitleLength().equals(60l);
                        }
View Full Code Here


                parser.setRenderer(new NullWikiTextRenderer() {
                    @Override
                    public String renderMacro(WikiTextMacro macro) {

                        if (macro.getName().equals("lastModifiedDocuments")) {
                            WikiPluginMacro pluginMacro = PluginRegistry.instance().createWikiPluginMacro(macro);
                            LastModifiedDocumentsPreferences lmdPrefs =
                                    Preferences.instance().get(LastModifiedDocumentsPreferences.class, pluginMacro);
                            assert lmdPrefs.getDocumentTitleLength().equals(66l);
                        }
View Full Code Here

            log.warn("macros are not reentrant, duplicate macro on page stack: " + wikiTextMacro);
            return null;
        }

        // Check if the wikiTextMacro actually is registered, we don't build unknown macros
        WikiPluginMacro pluginMacro = PluginRegistry.instance().createWikiPluginMacro(wikiTextMacro);
        if (pluginMacro == null) {
            log.info("macro is not bound in plugin registry: " + wikiTextMacro);
            getPageMacroStack().pop();
            return null;
        }

        // Check if we can find the template to include for this wikiTextMacro
        String macroIncludePath = getMacroIncludePath(pluginMacro);
        if (macroIncludePath == null) {
            getPageMacroStack().pop();
            return null;
        }

        // Before we build the nested components, set the WikiMacro instance in the PAGE context under a
        // unique name, so we can use a VariableMapper later and alias this as 'currentMacro'
        String macroPageVariableName = pluginMacro.getPageVariableName();
        log.debug("setting WikiMacro instance in PAGE context as variable named: " + macroPageVariableName);
        Contexts.getPageContext().set(macroPageVariableName, pluginMacro);

        // Whoever wants to do something before we finally build the XHTML template
        log.debug("firing VIEW_BUILD macro event");
        Events.instance().raiseEvent(pluginMacro.getCallbackEventName(WikiPluginMacro.CallbackEvent.VIEW_BUILD), pluginMacro);

        // This is where the magic happens... the UIWikiFormattedText component should have one child after that, a UIMacro
        includeMacroFacelet(pluginMacro, macroIncludePath, context, parent);

        // Now get the identifier of the newly created UIMacro instance and set it for future use
        Object macroId = parent.getAttributes().get(UIMacro.NEXT_MACRO);
        if (macroId != null) {
            pluginMacro.setClientId(macroId.toString());
            parent.getAttributes().remove(UIMacro.NEXT_MACRO);
        } else {
            // Best guess based wikiTextMacro renderer, needed during reRendering when we don't build the child
            // - only then is NEXT_MACRO set by the MacroComponentHandler
            macroId =
                    parent.getChildren().get(
                            parent.getChildCount() - 1
                    ).getClientId(context.getFacesContext());
            pluginMacro.setClientId(macroId.toString());
        }

        // Put an optional CSS include in the header of the wiki document we are rendering in.
        // (This needs to happen after the clientId is set, as CSS resource path rendering needs to
        // know if it occurs in a JSF request (clientId present) or not.
View Full Code Here

            }

            @Override
            public String renderMacro(WikiTextMacro macro) {

                WikiPluginMacro pluginMacroWithTemplate = macrosWithTemplateByPosition.get(macro.getPosition());
                if (pluginMacroWithTemplate == null) {
                    log.debug("macro does not have an XHTML template/include, skipping: " + macro);
                    return "";
                }

                log.debug("firing BEFORE_VIEW_RENDER macro event");
                Events.instance().raiseEvent(
                    pluginMacroWithTemplate.getCallbackEventName(WikiPluginMacro.CallbackEvent.BEFORE_VIEW_RENDER),
                        pluginMacroWithTemplate
                );

                log.debug("preparing include rendering for macro: " + pluginMacroWithTemplate);
                UIComponent child = findComponent( pluginMacroWithTemplate.getClientId() );
                log.debug("JSF child client identifier: " + child.getClientId(getFacesContext()));
                ResponseWriter originalResponseWriter = getFacesContext().getResponseWriter();
                StringWriter stringWriter = new StringWriter();
                ResponseWriter tempResponseWriter = originalResponseWriter
                        .cloneWithWriter(stringWriter);
                getFacesContext().setResponseWriter(tempResponseWriter);

                try {
                    log.debug("rendering template of macro: " + pluginMacroWithTemplate);
                    JSF.renderChild(getFacesContext(), child);

                    log.debug("firing AFTER_VIEW_RENDER macro event");
                    Events.instance().raiseEvent(
                        pluginMacroWithTemplate.getCallbackEventName(WikiPluginMacro.CallbackEvent.AFTER_VIEW_RENDER),
                        pluginMacroWithTemplate
                    );
                }
                catch (Exception ex) {
                    throw new RuntimeException(ex);
View Full Code Here

            }

            @Override
            public String renderMacro(WikiTextMacro macro) {

                WikiPluginMacro pluginMacroWithTemplate = macrosWithTemplateByPosition.get(macro.getPosition());
                if (pluginMacroWithTemplate == null) {
                    log.debug("macro does not have an XHTML template/include, skipping: " + macro);
                    return "";
                }

                log.debug("firing BEFORE_VIEW_RENDER macro event");
                Events.instance().raiseEvent(
                    pluginMacroWithTemplate.getCallbackEventName(WikiPluginMacro.CallbackEvent.BEFORE_VIEW_RENDER),
                        pluginMacroWithTemplate
                );

                log.debug("preparing include rendering for macro: " + pluginMacroWithTemplate);
                UIComponent child = findComponent( pluginMacroWithTemplate.getClientId() );
                log.debug("JSF child client identifier: " + child.getClientId(getFacesContext()));
                ResponseWriter originalResponseWriter = getFacesContext().getResponseWriter();
                StringWriter stringWriter = new StringWriter();
                ResponseWriter tempResponseWriter = originalResponseWriter
                        .cloneWithWriter(stringWriter);
                getFacesContext().setResponseWriter(tempResponseWriter);

                try {
                    log.debug("rendering template of macro: " + pluginMacroWithTemplate);
                    JSF.renderChild(getFacesContext(), child);

                    log.debug("firing AFTER_VIEW_RENDER macro event");
                    Events.instance().raiseEvent(
                        pluginMacroWithTemplate.getCallbackEventName(WikiPluginMacro.CallbackEvent.AFTER_VIEW_RENDER),
                        pluginMacroWithTemplate
                    );
                }
                catch (Exception ex) {
                    throw new RuntimeException(ex);
View Full Code Here

TOP

Related Classes of org.jboss.seam.wiki.core.plugin.WikiPluginMacro

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.