Package org.apache.wiki

Examples of org.apache.wiki.WikiContext


                if( m_iterator.hasNext() )
                {
                    Attachment  att = (Attachment) m_iterator.next();

                    WikiContext context = (WikiContext)m_wikiContext.clone();
                    context.setPage( att );
                    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
                                              context,
                                              PageContext.REQUEST_SCOPE );

                    pageContext.setAttribute( getId(), att );
View Full Code Here


        if( m_iterator != null && m_iterator.hasNext() )
        {
            Attachment att = (Attachment) m_iterator.next();

            WikiContext context = (WikiContext)m_wikiContext.clone();
            context.setPage( att );
            pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
                                      context,
                                      PageContext.REQUEST_SCOPE );

            pageContext.setAttribute( getId(), att );
View Full Code Here

    /** {@inheritDoc} */
    public final int doWikiStartTag()
        throws IOException
    {
        WikiEngine engine = m_wikiContext.getEngine();
        WikiContext ctx;
       
        if( m_pageName == null )
        {
            ctx = m_wikiContext;
        }
        else
        {
            ctx = (WikiContext)m_wikiContext.clone();
            ctx.setPage( engine.getPage(m_pageName) );
        }

        Integer vernew = (Integer) pageContext.getAttribute( ATTR_NEWVERSION,
                                                             PageContext.REQUEST_SCOPE );
        Integer verold = (Integer) pageContext.getAttribute( ATTR_OLDVERSION,
                                                             PageContext.REQUEST_SCOPE );

        log.info("Request diff between version "+verold+" and "+vernew);

        if( ctx.getPage() != null )
        {
            JspWriter out = pageContext.getOut();

            String diff = engine.getDiff( ctx,
                                          vernew.intValue(),
View Full Code Here

    private void buildContext()
    {
        //
        //  Build a clone of the current context
        //
        WikiContext context = (WikiContext)m_wikiContext.clone();
       
        Object o = m_iterator.next();
       
        if( o instanceof WikiPage )
            context.setPage( (WikiPage)o );

        //
        //  Push it to the iterator stack, and set the id.
        //
        pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
View Full Code Here

           
            // Create a wiki context for the result
            WikiEngine engine = m_wikiContext.getEngine();
            HttpServletRequest request = m_wikiContext.getHttpRequest();
            Command command = PageCommand.VIEW.targetedCommand( r.getPage() );
            WikiContext context = new WikiContext( engine, request, command );
           
            // Stash it in the page context
            pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
                                      context,
                                      PageContext.REQUEST_SCOPE );
View Full Code Here

    public final int doAfterBody()
        throws JspException
    {
        try
        {
            WikiContext context = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT,
                                                                          PageContext.REQUEST_SCOPE );

            //
            //  Because the TranslateTag should not affect any of the real page attributes
            //  we have to make a clone here.
            //
           
            context = context.deepClone();
           
            //
            //  Get the page data.
            //
            BodyContent bc = getBodyContent();
            String wikiText = bc.getString();
            bc.clearBody();

            if( wikiText != null )
            {
                wikiText = wikiText.trim();
           
                String result = context.getEngine().textToHTML( context, wikiText );

                getPreviousOut().write( result );
            }
        }
        catch( Exception e )
View Full Code Here

                m_iterator = versions.iterator();

                if( m_iterator.hasNext() )
                {
                    WikiContext context = (WikiContext)m_wikiContext.clone();
                    context.setPage( (WikiPage)m_iterator.next() );
                    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
                                              context,
                                              PageContext.REQUEST_SCOPE );
                    pageContext.setAttribute( getId(),
                                              context.getPage() );
                }
                else
                {
                    return SKIP_BODY;
                }
View Full Code Here

            }
        }

        if( m_iterator != null && m_iterator.hasNext() )
        {
            WikiContext context = (WikiContext)m_wikiContext.clone();
            context.setPage( (WikiPage)m_iterator.next() );
            pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
                                      context,
                                      PageContext.REQUEST_SCOPE );
            pageContext.setAttribute( getId(),
                                      context.getPage() );
            return EVAL_BODY_BUFFERED;
        }

        return SKIP_BODY;
    }
View Full Code Here

    }

    public void testShowCountsBasic() throws Exception
    {
        WikiPage page1 = testEngine.getPage( "TestPage01" );
        WikiContext context1 = new WikiContext( testEngine, page1 );
        WikiPage page2 = testEngine.getPage( "TestPage02" );
        WikiContext context2 = new WikiContext( testEngine, page2 );

        // generate counts:
        testEngine.getHTML( context1, page1 );
        testEngine.getHTML( context2, page2 );
        testEngine.getHTML( context2, page2 );

        // mind the double \n in the following string:
        String pageViewPageContent = "[{PageViewPlugin show='list''\n\n* {1} ({2} views)\n}]";
        testEngine.saveText( "PageViews", pageViewPageContent );

        WikiPage pageviews = testEngine.getPage( "PageViews" );
        WikiContext contextPV = new WikiContext( testEngine, pageviews );

        String result = testEngine.getHTML( contextPV, pageviews );
//        System.out.println( result );

        assertTrue( result.contains( "Test Page 01 (2 views)" ) );
View Full Code Here

    public void testShowCountsExclude() throws Exception
    {
        testEngine.saveText( "TestPageExcluded", "this is test page that should be excluded [{PageViewPlugin}]" );

        WikiPage page1 = testEngine.getPage( "TestPage01" );
        WikiContext context1 = new WikiContext( testEngine, page1 );
        WikiPage page2 = testEngine.getPage( "TestPage02" );
        WikiContext context2 = new WikiContext( testEngine, page2 );

        // generate counts:
        testEngine.getHTML( context1, page1 );
        testEngine.getHTML( context2, page2 );
        testEngine.getHTML( context2, page2 );

        // mind the double \n in the following string:
        String pageViewPageContent = "[{PageViewPlugin show='list' exclude='TestPageExcl*' '\n\n* {1} ({2} views)\n}]";
        testEngine.saveText( "PageViews", pageViewPageContent );

        WikiPage pageviews = testEngine.getPage( "PageViews" );
        WikiContext contextPV = new WikiContext( testEngine, pageviews );

        String result = testEngine.getHTML( contextPV, pageviews );
//        System.out.println( result );

        assertTrue( result.contains( "Test Page 01" ) );
View Full Code Here

TOP

Related Classes of org.apache.wiki.WikiContext

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.