cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevecam <stephen.came...@geometryit.com>
Subject flowscript error using sendPageandWait in loop.
Date Thu, 06 Dec 2007 06:08:46 GMT

Hello,

I am trying to use flowscript and jxtemplates from withing Apache Lenya.

I have an error that I'm hoping someone can explain.

I want to prompt a user with a list of options to select from. If there are
no selections made I want to present the same page again. The list of
options to select from is passed to the cocoon.sendPageAndWait routine and
the page renders (via JXTemplateTransformer) correctly. However if no
selections are made and the page is redisplayed a second time I get an error
as below:

.
.
.
Caused by: org.apache.cocoon.generation.JXTemplateGenerator$JXTException:
java.lang.NullPointerException
	at <jx:choose> -
file:/C:/Tomcat5.0/webapps/lenya/lenya/pubs/TLP/content/authoring/INDIVIDUAL/IDV-DIAGNOSTICS/idv-select-occupation/idv-select-qualification/index_en.xml:1:1
	at <map:serialize type="xml"> -
file:/C:/Tomcat5.0/webapps/lenya/lenya/pubs/TLP/doctypes.xmap:62:36
	at <map:transform> -
file:/C:/Tomcat5.0/webapps/lenya/lenya/pubs/TLP/doctypes.xmap:57:49
	at <map:transform type="jx"> -
file:/C:/Tomcat5.0/webapps/lenya/lenya/pubs/TLP/doctypes.xmap:56:36
	at <map:generate> -
file:/C:/Tomcat5.0/webapps/lenya/lenya/pubs/TLP/doctypes.xmap:54:104
	at
org.apache.cocoon.generation.JXTemplateGenerator.execute(JXTemplateGenerator.java:2795)
	at
org.apache.cocoon.generation.JXTemplateGenerator.performGeneration(JXTemplateGenerator.java:2498)
	at
org.apache.cocoon.generation.JXTemplateGenerator.access$1200(JXTemplateGenerator.java:119)
	at
org.apache.cocoon.generation.JXTemplateGenerator$TransformerAdapter$TemplateConsumer.endDocument(JXTemplateGenerator.java:2267)
	at
org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLPipe.java:56)
	at
org.apache.cocoon.components.sax.XMLTeePipe.endDocument(XMLTeePipe.java:71)
	at
org.apache.cocoon.components.sax.XMLByteStreamInterpreter.parse(XMLByteStreamInterpreter.java:83)
	at
org.apache.cocoon.components.sax.XMLByteStreamInterpreter.deserialize(XMLByteStreamInterpreter.java:73)
	at
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:331)
	at
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:780)
	at
org.apache.cocoon.components.source.impl.SitemapSource.toSAX(SitemapSource.java:413)
	... 118 more
Caused by: java.lang.NullPointerException
	at
org.apache.commons.jexl.parser.ASTSizeFunction.sizeOf(ASTSizeFunction.java:77)
	at
org.apache.commons.jexl.parser.ASTSizeMethod.execute(ASTSizeMethod.java:51)
	at
org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:68)
	at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:50)
	at org.apache.commons.jexl.parser.ASTEQNode.value(ASTEQNode.java:48)
	at
org.apache.commons.jexl.parser.ASTExpression.value(ASTExpression.java:47)
	at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:86)
	at
org.apache.cocoon.generation.JXTemplateGenerator.getValue(JXTemplateGenerator.java:793)
	at
org.apache.cocoon.generation.JXTemplateGenerator.execute(JXTemplateGenerator.java:2793)
	... 128 more

This is strange as my pipeline is as follows:

 51     <!-- parametrized doctype matcher -->
 52    <!-- pattern="{rendertype}/{area}/{doctype}/{document-path}" -->
 53     <map:match pattern="*/*/*/**.xml">
 54       <map:generate 
src="{content-dir:{page-envelope:publication-id},{2}}/{4}.xml"
label="content"/>
55 <!-- ASC added jxtemplate transform -->
56        <map:transform type="jx" /> 
57        <map:transform src="xslt/{3}2xhtml.xsl">
58          <map:parameter name="rendertype" value="{1}"/>
59          <map:parameter name="nodeid"
value="{page-envelope:document-node-id}"/>
60          <map:parameter name="language"
value="{page-envelope:document-language}"/>
61        </map:transform>
62        <map:serialize type="xml"/>
63      </map:match>

The error seems to indicate a problem in the serialization at line 62 and in
a jxtemplate generation rather than a transformation step.

The generation step is reading the following page (ie index_en.xml):

<?xml version="1.0" encoding="UTF-8"?>

<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
      xmlns:xhtml="http://www.w3.org/1999/xhtml" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      xmlns:dcterms="http://purl.org/dc/terms/"
      xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
>

<xhtml:html>
<lenya:meta>
        <dc:title>dctitle</dc:title>
        <dc:creator>Brett Walker</dc:creator>
        <dc:subject>Choose an occupation</dc:subject>
        <dc:description>Abstract that can be used on an overview
page</dc:description>
        <dc:publisher>Geometry</dc:publisher>
        <dc:contributor/>
        <dc:date>Wed Nov 28 16:42:57 EST 2007</dc:date>
        <dc:type/>
        <dc:format/>
        <dc:identifier/>
        <dc:source/>
        <dc:language>en</dc:language>
        <dc:relation/>
        <dc:coverage/>
        <dc:rights>dcrights</dc:rights>
</lenya:meta>

<xhtml:head>
<xhtml:title>Default Publication</xhtml:title>
<xhtml:meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</xhtml:head>
<xhtml:body>
<xhtml:h1>Choose Occupations</xhtml:h1>

   <form action="idv-select-occupation/idv-select-qualification.html"
method="POST">
    <input type="hidden" name="continuation-id"
value="${cocoon.continuation.id}"/>
    <jx:choose>
      <jx:when test="${occupations.size() == 0}">
        <xhtml:p>There are no occupations.</xhtml:p>
      </jx:when>
      <jx:otherwise>
         <xhtml:div class="page_explanation">Select occupations for which
you would like to discover skills, training and job
opportunities</xhtml:div>
          <jx:forEach var="occupation" items="${occupations}">
            <xhtml:div class="title_row">
                <xhtml:div class="select_check"><xhtml:input type="checkbox"
name="${occupation.OCCUPATION_ID}"/></xhtml:div>
                <xhtml:div class="descr_fold">
                  <xhtml:a
onclick="hideContent('descr_${occupation.OCCUPATION_ID}','descr_${occupation.OCCUPATION_ID}_FoldImage');">
                    <xhtml:img
id='descr_${occupation.OCCUPATION_ID}_FoldImage'
src="/lenya/tlp/live/images/minus.jpg" />
                  </xhtml:a>
                </xhtml:div>                
                <xhtml:div class="title">${occupation.TITLE}</xhtml:div>     
      
            </xhtml:div>
            <xhtml:div class="descr_row"
id="descr_${occupation.OCCUPATION_ID}">
               <xhtml:div
class="descr">${occupation.JOB_DESCRIPTION}</xhtml:div>            
            </xhtml:div>
          </jx:forEach>
      </jx:otherwise>
    </jx:choose>
    <input type="submit"/>
    </form>  

</xhtml:body>
</xhtml:html>
</jx:template>

There is a jx:choose tag in this file which made me think for a while that
the occupations List object that is being tested for size was the problem as
this is being generated in the flowscript from a database query using the
JDBi database interface library as per the simple database access demo.
However, this object is not 'undefined' after the call of sendPageAndWait
the second time and removing the database dependancy doesn't fix the
problem.

My flowscript is as follows:

function do_occupation_diagnostic()
{
    //get the user selected occupations
    var selected_occs = new java.util.ArrayList();
    //var occ_list = dao.occupation.getAll();
    var occ_list = new java.util.ArrayList();
    occ_list.add({OCCUPATION_ID: 1, JOB_DESCRIPTION: 'value 1'});
    occ_list.add({OCCUPATION_ID: 2, JOB_DESCRIPTION: 'value 2'});
    while(true){
    	 // Call the view to allow user to select occupations of interest
      
cocoon.sendPageAndWait("INDIVIDUAL/IDV-DIAGNOSTICS/idv-select-occupation.jx",{
occupations: occ_list });     
       for(var params = cocoon.request.getParameterNames();
params.hasNext();){
          var occ_id = params.next();
          if(cocoon.request.getParameterValues(occ_id)[0] == "on"){
             selected_occs.add(dao.occupation.get(occ_id));
          }
       }
       if(selected_occs.size()>0) break;
    }
}

So, I think my initial diagnosis is incorrect and the jx:choose tag is
getting through the transformation step and into the serialization step in
the pipeline. 

Thanks for any insights.

Steve Cameron
Developer 
Geometry (www.geometryit.com)
-- 
View this message in context: http://www.nabble.com/flowscript-error-using-sendPageandWait-in-loop.-tf4954237.html#a14186912
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message