stevecam wrote: > > Small point of clarification to my first post, I am talking about > Javascript Flow (i.e. Flowscript), see *** below. > > > Andreas Hartmann wrote: >> >> Jörn Nettingsmeier schrieb: >>> stevecam wrote: >>>> I want to make use of Flowscript and JXTemplates from Lenya. >>>> >>>> My requirement is to create pages that incorporate data from a >>>> database into >>>> tables and allow users to select rows in the tables, their selection >>>> in turn >>>> affecting what they see on the next page. Flowscript seems to be a >>>> simple >>>> means to acheive this. >>>> >>>> Also, I want to make use of the JDBi javascript database interface >>>> library >>>> in the Cocoon "Easy SQL database access" demo in the forms block. >>>> >>>> My task now is to find the best way to make use of these means in >>>> Lenya. >>>> There is some information available on how to use CForms from Lenya >>>> but no >>>> good example of Javaflow and JXTemplates. >> >> *** I should have said Javascript flow (Flowscript) and JXTemplates here! >> >>>> Specifically I want to generate the page body (that would normally >>>> come from >>>> an index_en.xml file (or other language version of it)) via a >>>> JXTemplate and >>>> to have a Flowscript use (call) a modified Lenya pipeline to aggregate >>>> the >>>> body with my sites standard header, footer, breadcrumb. >>>> I presume that for the Lenya menu highlighting and breadcrumb >>>> functionality >>>> to work then the page must be one in the Lenya sitetree. >> >> That's true, but in your case the page would only be a placeholder for >> the content which is generated dynamically by the usecase or resource >> type module sitemap (whatever approach you choose). >> >>>> I'll have a go at this now and add to this thread with my results, but >>>> if >>>> anyone has already implemented such a thing I'd be happy for some help. >>> >>> if you need flow, you should implement it as a usecase. >>> in lenya 2.0, there is a document type called "usecasedocument", which >>> allows you to disguise a usecase (which normally has a view that's >>> orthogonal to documents) as a plain document, which you can include in >>> your navigation menu and handle it as if it were just another xhtml doc. >>> perhaps andreas can chime in with more details here? >> >> http://lenya.apache.org/docs/modules/usecasedocument/index.html >> >>> alternatively, you could create a custom doctype that will just contain >>> a database query and a link to a special xslt that renders it to the >>> desired xhtml output. i've done that for accessing an xml database, and >>> it worked ok. i'd be glad to help out, but i only know lenya 2.0... >> >> I'd also use a resource type rather than a usecase because >> >> - it is a read-only operation >> - custom flow is required >> >> I guess I'd start with a resource type module (there's a tutorial in the >> documentation) and add the stuff from the "Easy SQL database access" >> tutorial in the module sitemap. >> >> -- Andreas >> >> >> -- >> Andreas Hartmann, CTO >> BeCompany GmbH >> http://www.becompany.ch >> Tel.: +41 (0) 43 818 57 01 >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > >
I've implemented a partial solution to my requirement but it does not seem to be fully functional, so I'm now looking at the creation of a new resource type (document_type) 'jxtemplate'. I've followed the instructions in the tutorial but have one problem that I cannot solve. When creating a new page from the menu (using the "New JXTemplate" option I've added), the new page has the default type of 'xhtml' rather that 'jxtemplate'. This kind of problem is mentioned in the tutorial (see 'Resource type matcher') and I've checked what I have done but cannot see an error. It seems to be partly working as my new default jxtemplate.xml sample file is used but the wrong stylesheet selection is made. By using a resource-type I think things are simplified a little as follows: (1)Create entry points for the Flowscript/Continuations to take over page generation from the pipeline. (2)Get the dynamic data from the database into javascript objects and then pass control back to the pipeline. (3)For my 'jxtemplate' resource type, generate the content with a different pipeline than the default xhtml resource type. These steps are described in more detail as below; (1)Create entry points for the Flowscript/Continuations. I add to the publication-sitemap.xml the following. <!-- add components for JXTemplate use --> <map:components> <map:generators default="file"> <map:generator label="content" logger="sitemap.generator.jx" name="jx" pool-grow="2" pool-max="16" pool-min="2" src="org.apache.cocoon.generation.JXTemplateGenerator"/> </map:generators> <map:transformers default="xslt"> <map:transformer logger="sitemap.transformer.jx" name="jx" pool-grow="2" pool-max="16" pool-min="2" src="org.apache.cocoon.transformation.JXTemplateTransformer"/> <map:transformer logger="forms" name="forms" src="org.apache.cocoon.forms.transformation.FormsTemplateTransformer"/> </map:transformers> </map:components> <!-- reference flowscript --> <map:flow language="javascript"> <map:script src="flow/application_flow.js"/> <map:script src="flow/jdbi.js"/> </map:flow> <!-- enable continuations --> <map:pipeline> <!-- Continue a scenario. The continuation id is passed in the URL (typically used for GET requests) --> <map:match pattern="**/*.continue"> <map:call continuation="{1}"> <map:parameter name="publication_id" value="{page-envelope:publication-id}"/> <map:parameter name="area" value="{page-envelope:area}"/> <map:parameter name="document_type" value="{page-envelope:document-type}"/> <map:parameter name="document_url" value="{page-envelope:document-url}"/> </map:call> </map:match> <!-- Continue a scenario. The continuation id is passed as a request parameter (typically used for POST request) --> <map:call continuation="{request-param:continuation-id}"> <map:parameter name="publication_id" value="{page-envelope:publication-id}"/> <map:parameter name="area" value="{page-envelope:area}"/> <map:parameter name="document_type" value="{page-envelope:document-type}"/> <map:parameter name="document_url" value="{page-envelope:document-url}"/> </map:call> </map:match> --> </map:pipeline> <!-- create an flowscript entry point --> <map:match pattern="*/**/FIRST.html"> <map:call function="do_first_page"> <map:parameter name="publication_id" value="{page-envelope:publication-id}"/> <map:parameter name="area" value="{page-envelope:area}"/> <map:parameter name="document_type" value="{page-envelope:document-type}"/> <map:parameter name="document_url" value="{page-envelope:document-url}"/> </map:call> </map:match> (2)Get the dynamic data into javascript objects and return control to pipeline In my javascript I have the do_first_page function as follows: function do_first_page() { //get a list of occupations var list = dao.occupation.getAll(); //return control to lenya page creation pipeline cocoon.sendPage("lenyabody-view/"+cocoon.parameters["publication_id"]+"/"+ cocoon.parameters["area"] +"/"+cocoon.parameters["document_type"]+"/"+ cocoon.parameters["document_url"], { occupations: list }); } (3) Generate my 'jxtemplate' resource type (document type) content. The page body content is generated in the aggregate as below: <!-- This is the pipeline that builds the page. It aggregates all the navigational elements (breadcrumb, tabs, menu) with the actual content of the document. --> <map:pipeline> <!-- /lenyabody-{rendertype}/{publication-id}/{area}/{doctype}/{url} --> <map:match pattern="lenyabody-*/*/*/*/**"> <map:aggregate element="cmsbody"> <map:part src="cocoon://navigation/{2}/{3}/breadcrumb/{5}.xml"/> <map:part src="cocoon://navigation/{2}/{3}/tabs/{5}.xml"/> <map:part src="cocoon://navigation/{2}/{3}/menu/{5}.xml"/> <map:part src="cocoon://navigation/{2}/{3}/search/{5}.xml"/> <map:part src="cocoon:/lenya-document-{1}/{3}/{4}/{page-envelope:document-path}"/> </map:aggregate> The last 'map:part' line calls another 'mounted' pipeline in the doctypes.xmp file and this is where I need to add my jxtemplate rendering pipeline. The standard pipeline is as follows: <!-- parametrized doctype matcher --> <!-- pattern="{rendertype}/{area}/{doctype}/{document-path}" --> <map:match pattern="*/*/*/**.xml"> <map:generate src="{content-dir:{page-envelope:publication-id},{2}}/{4}.xml"/> <map:transform src="xslt/{3}2xhtml.xsl"> <map:parameter name="rendertype" value="{1}"/> <map:parameter name="nodeid" value="{page-envelope:document-node-id}"/> <map:parameter name="language" value="{page-envelope:document-language}"/> </map:transform> <map:serialize type="xml"/> </map:match> I have not test this part yet but I think the modification needed is: <!-- parametrized doctype matcher --> <!-- pattern="{rendertype}/{area}/{doctype}/{document-path}" --> <map:match pattern="*/*/*/**.xml"> <map:select> <map:when test="{3}='jxtemplate'"> <map:generate type="jx" src="{content-dir:{page-envelope:publication-id},{2}}/{4}.xml"/> </map:when> <map:otherwise> <map:generate src="{content-dir:{page-envelope:publication-id},{2}}/{4}.xml"/> </map:otherwise> </map:select> <map:transform src="xslt/{3}2xhtml.xsl"> <map:parameter name="rendertype" value="{1}"/> <map:parameter name="nodeid" value="{page-envelope:document-node-id}"/> <map:parameter name="language" value="{page-envelope:document-language}"/> </map:transform> <map:serialize type="xml"/> </map:match> So finally if I can get my resource-type (doctype) set up correctly I should be able to test all this out. I'm presuming I can move between pages using flowscript and Lenya will handle all the menu-highlighting and breadcrumb for me (I hope). -- View this message in context: http://www.nabble.com/Using-Flowscript-and-JXTemplates-in-Lenya-tf4894710.html#a14102407 Sent from the Lenya - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]