6 Replies Latest reply: Apr 20, 2012 1:31 PM by Nick Graves RSS

Syntaxhighlighter component

Bernard Labno Master

Hi I've just developed Syntaxhighlighter component.

 

Currently it's in version 4.X but I can port it to RF 3.X after positive community feedback.

 

Demo, download and subversion address are here.

  • 1. Re: Syntaxhighlighter component
    Bernard Labno Master

    Currently theme and language can't be changed via ajax request.

    Technically to change them I need to add apropriate JavaScript and CSS files (calculated accordingly to theme and language value).

    Currently it's done like this: before render view phase renderer calculates which scripts need to be included and calls UIViewRoot.addComponentResource.

    Problem is that i don't know how to instruct JSF to include new scripts in partial response.

  • 2. Re: Syntaxhighlighter component
    Nick Graves Newbie

    Good afternoon Bernard.

     

    I have added the Syntaxhighlighter jar to my web application (Rich Faces 4.1 Final, Glassfish 3.1) and I am receiving a null pointer exception when I access the page with my Syntaxhighlighter tag.  Here is the contents of my error:

     

    #|2012-04-04T13:25:08.699-0700|SEVERE|glassfish3.1.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=27;_ThreadName=Thread-2;|Error Rendering View[/protected/transaction/View.xhtml]

    java.lang.NullPointerException

              at org.richfaces.renderkit.html.SyntaxHighlighterRenderer.getRenderableHighlightValue(SyntaxHighlighterRenderer.java:229)

              at org.richfaces.renderkit.html.SyntaxHighlighterRenderer.getOptions(SyntaxHighlighterRenderer.java:214)

              at org.richfaces.renderkit.html.SyntaxHighlighterRenderer.doEncodeEnd(SyntaxHighlighterRenderer.java:152)

              at org.richfaces.renderkit.RendererBase.encodeEnd(RendererBase.java:175)

              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)

              at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)

              at org.richfaces.renderkit.html.TogglePanelItemRenderer.doEncodeChildren(TogglePanelItemRenderer.java:136)

              at org.richfaces.renderkit.html.TabRenderer.doEncodeChildren(TabRenderer.java:107)

              at org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:157)

              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)

              at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)

              at org.richfaces.renderkit.html.TogglePanelRenderer.doEncodeChildren(TogglePanelRenderer.java:127)

              at org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:157)

              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)

              at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)

              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)

              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)

              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)

              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)

              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)

              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)

              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

              at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

              at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

              at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

              at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

              at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

              at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

              at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

              at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

              at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

              at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

              at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

              at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

              at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

              at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

              at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

              at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

              at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

              at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

              at java.lang.Thread.run(Thread.java:662)

    |#]

     

    Any thoughts on the issue?  Any help is greatly appreciated.

    Thank you.

    Nick G.

  • 3. Re: Syntaxhighlighter component
    Bernard Labno Master

    Looks like value bound to your "highlight" attribute contains null. Can you show your facelet and backing bean?

  • 4. Re: Syntaxhighlighter component
    Nick Graves Newbie

    Thank you for the response Bernard.  I didn't realize the highlight attribute was required.  I have added it, but the my output is displaying as plain xml.  Here is the markup from the page.  My managed bean method (srcDocs) is obtaining the xml from a JPA entity.

     

    <h:form>

                    <rich:tabPanel rendered="true" id="tabPan1" immediate="true" switchType="client">

                        <rich:tab header="Source Document" id="tab1" rendered="true">

                            <syn:syntaxhighlighter id="syn1" theme="default" language="xml" highlight="2" >

                                <h:outputText value="#{transactionController.srcDocs()}"/>

                            </syn:syntaxhighlighter>

                        </rich:tab>

                        <rich:tab header="Destination Document" id="tab2" rendered="true">

                           <syn:syntaxhighlighter id="syn2" theme="default" language="xml" highlight="2">

                                <h:outputText value="#{transactionController.srcDocs()}"/>

                            </syn:syntaxhighlighter>

                        </rich:tab>

                    </rich:tabPanel>

                </h:form>

  • 5. Re: Syntaxhighlighter component
    Nick Graves Newbie

    I guess I should say that I am not exactly sure how to implement this tag properly....

     

    Nick G.

  • 6. Re: Syntaxhighlighter component
    Nick Graves Newbie

    Any thoughts on this one Bernard. My app is still displaying plain XML in the syn tabs.

     

    Nick