dev@jsftemplating.java.net

Re: JSFTemplating: SyntaxException in parsing

From: Anissa Lam <Anissa.Lam_at_Sun.COM>
Date: Sat, 04 Nov 2006 09:12:30 -0800

Hi Ken,
Thanks. Issue has been filed:
https://jsftemplating.dev.java.net/issues/show_bug.cgi?id=5
I should have realized the space is the cause, i knew i used this
function many times before and don't have the problem. It was a puzzle
to me yesterday since i haven't updated the project and wondering why
the function doesn't work anymore.

thanks
Anissa.

Ken Paulsen wrote:
>
> Hi Anissa,
>
> It is a bug. I see the problem... basically, it skips comments and
> white space after the opening parenthesis in "if ( ..." and the '#'
> character is a comment. I will change this to be more smart. Can you
> please file a bug?
>
> In the mean time, you should be able to do:
>
> if ($attribute{flag}) { doSomething() }
>
> Replace "attribute" with "pageSession"; "session"; or whatever you need...
>
> OR, you can do:
>
> if ("#{flag}") { doSomething() }
>
> OR even:
>
> if (condition="#{flag}") { doSomething() }
>
> FYI, the "if" functionality is implemented as a handler with a single
> input value called "condition". Using it w/o quotes or a parameter
> name is a convenience feature.
>
> Thanks!
>
> Ken
>
> Anissa Lam wrote:
>> Hi,
>> I am getting a parsing error when testing a condition using if() handler.
>>
>> *if ( !** #{flag}){ doSomething() }
>> *
>> is fine.
>>
>> But if i do not have the '!', i get an exception.
>> * if ( #{flag}){ doSomething() }
>> *
>> Here is the exception i got, and i have attached the .jsf file. Did
>> i do something illegal ? or is this a bug in jsftemplating ? I also
>> attached the test.jsf i ave.
>>
>> thanks
>> Anissa.
>>
>> [#|2006-11-03T15:27:57.728-0800|SEVERE|sun-appserver-ee9.1|javax.enterprise.system.container.web|_ThreadID=13;_ThreadName=httpWorkerThread-8080-0;_RequestID=90a839d0-b762-40eb-9e8f-6af0041804bd;|StandardWrapperValve[FacesServlet]:
>> PWC1406: Servlet.service() for servlet FacesServlet threw exception
>> com.sun.jsftemplating.layout.SyntaxException: Encountered unmatched
>> '}' when parsing handlers for 'command' event.
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader$EventParserCommand.process(TemplateReader.java:762)
>> at
>> com.sun.jsftemplating.layout.template.BaseProcessingContext.beginSpecial(BaseProcessingContext.java:122)
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader$LayoutComponentContext.beginSpecial(TemplateReader.java:723)
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader.process(TemplateReader.java:262)
>> at
>> com.sun.jsftemplating.layout.template.BaseProcessingContext.beginComponent(BaseProcessingContext.java:82)
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader.process(TemplateReader.java:268)
>> at
>> com.sun.jsftemplating.layout.template.BaseProcessingContext.beginComponent(BaseProcessingContext.java:82)
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader.process(TemplateReader.java:268)
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader.readLayoutDefinition(TemplateReader.java:156)
>> at
>> com.sun.jsftemplating.layout.template.TemplateReader.read(TemplateReader.java:114)
>> at
>> com.sun.jsftemplating.layout.template.TemplateLayoutDefinitionManager.getLayoutDefinition(TemplateLayoutDefinitionManager.java:167)
>> at
>> com.sun.jsftemplating.layout.LayoutDefinitionManager.getLayoutDefinition(LayoutDefinitionManager.java:123)
>> at
>> com.sun.jsftemplating.layout.LayoutViewRoot.getLayoutDefinition(LayoutViewRoot.java:227)
>> at
>> com.sun.jsftemplating.layout.LayoutViewHandler.createView(LayoutViewHandler.java:142)
>> at
>> com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:201)
>> at
>> com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
>> at
>> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
>> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
>> at com.sun.webui.jsf.util.UploadFilter.doFilter(Unknown Source)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:216)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
>> at
>> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:255)
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
>> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556)
>> at
>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1029)
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556)
>> at
>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1029)
>> at
>> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:249)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.processNonBlocked(DefaultProcessorTask.java:549)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:332)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:254)
>> at
>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:205)
>> at
>> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
>> at
>> com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadImpl.java:103)
>> |#]
>>
>>
>> ------------------------------------------------------------------------
>>
>> <sun:page>
>> <!beforeCreate
>> setPageSessionAttribute(key="flag" value="#{true}")
>> />
>> <sun:button>
>> <!command
>> if( #{flag}){
>> println(value="!!! Ok ");
>> }
>> />
>> </sun:button>
>>
>> </sun:page>
>>