cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yahoo <hansheinrichbr...@yahoo.de>
Subject Re: Jexl in embedded Pipeline
Date Fri, 14 Mar 2014 05:13:56 GMT
I found what I want todo. It's not  Jexl it's the VelocityEngine I need.
Here is the example from spring mail.

    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
             message.setTo(user.getEmailAddress());
             message.setFrom("webmaster@csonth.gov.uk");/// could be parameterized.../
             Map model = new HashMap();
             model.put("user", user);
             String text = VelocityEngineUtils.mergeTemplateIntoString(
                velocityEngine, "com/dns/registration-confirmation.vm", model);
             message.setText(text, true);


In my case the text comes from an inline Cocoon Pipeline.
I could first import the template use the Velocity Engine and then give 
it to the Pipeline.
or is there possibility to make the job done by the pipeline .

Am 13.03.2014 19:34, schrieb gelo1234:
> I don't know about the attachments but a clean Cocoon3 extension for 
> sending emails you can find here:
>
> https://github.com/alveolo/butterfly/blob/master/cocoon/src/test/java/org/alveolo/butterfly/test/cocoon/email/MailSerializerTest.java
>
> Greetings,
> Greg
>
>
> 2014-03-13 15:02 GMT+01:00 Piratenvisier <hansheinrichbraun@yahoo.de 
> <mailto:hansheinrichbraun@yahoo.de>>:
>
>     An application like this I use already.
>     Thorsten Scherler made this email Application for me.
>     The important point: I want to send an email and the Email Text
>     and the attachements are produced by cocoon pipelines.
>     This a an important part of my cocoon 2.10 application which I
>     wanted to transfer to 3.0
>
>     Am 13.03.2014 14:23, schrieb gelo1234:
>>     I got lost with your explanation :) It's a kind of awkward thing
>>     to me that you are actually trying to do with that code.
>>
>>
>>     Why not making it clean:
>>
>>     1. First you need a String-Template match to serialize the
>>     Hibernate bean -> output XML with final values
>>
>>     <map:match  pattern="hibernate/bean">
>>              <map:generate  src="bean.xml"  type="stringtemplate"  />
>>              <map:serialize  type="xml"  />
>>     </map:match>
>>     where bean.xml is your [input]
>>
>>     You can now feed angebot bean data into hibernate/bean pipe above
>>     (to get it serialized):
>>     <map:match  pattern="hibernate/{id}">
>>              <controller:call  controller="rest-controller"  select="BeanController">
>>                <map:parameter  name="id"  value="{map:id}"  />
>>              </controller:call>
>>     </map:match>
>>
>>
>>     @RESTController
>>     public  class  BeanController  implements  Get  {
>>
>>          @SitemapParameter
>>          private  String  id;
>>
>>          @RequestParameter
>>          private  String  name;
>>        
>>          // through injection or other way
>>
>>          HibernateDAO dao;
>>
>>           public  RestResponse  doGet()  throws  Exception  {
>>              Map<String,  Object>  data=  new  HashMap<String,  Object>();
>>              data.put("angebot",  dao.getAngebotBean(id));
>>              data.put("name",  this.name);
>>
>>              return  new  Page("servlet:/hibernate/bean",  data);
>>          }
>>     }
>>     At this point you got your Hibernate bean serialized (into XML data).
>>
>>     2. Second you can go for XSLT Transformer and transform XML into
>>     anything you want
>>
>>     You don't need any JEXL here.
>>
>>
>>     Greetings,
>>     Greg
>>
>>
>>
>>
>>     2014-03-13 13:30 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>     <mailto:hansheinrichbraun@yahoo.de>>:
>>
>>         I used the EmailPlainPipe from the distribution:
>>           byte[] bytes = (byte[]) parameters.get("input");
>>                 XMLGenerator generator = new XMLGenerator(bytes);
>>                 this.addComponent(generator);
>>                 byte[] xsl = (byte[]) parameters.get("xsl");
>>                 Source xslSource = new StreamSource(new
>>         ByteArrayInputStream(xsl));
>>                 XSLTTransformer transformer = new XSLTTransformer(
>>                         xslSource, new Date().getTime());
>>                 // pass all parameter to the xslTransformer
>>         transformer.setParameters(parameters);
>>                 this.addComponent(transformer);
>>         this.addComponent(TextSerializer.createPlainSerializer());
>>                 super.setup(outputStream, parameters);
>>         where input is:
>>         <?xml version="1.0" encoding="UTF-8"?>
>>         <angebot>
>>           <id>$name$$angebot.id <http://angebot.id>$</id>
>>          <anganz>$angebot.anganz$</anganz>
>>         <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>>         </angebot>
>>         xsl is the identity
>>         angebot is a Hibernate Bean.
>>         how do feed the pipeline with this Bean that it is used  by
>>         Jexl to resolve the input String.
>>
>>
>>         Am 13.03.2014 12:55, schrieb gelo1234:
>>>         With servlet-sitemaps Jexl can be used within any pipeline
>>>         as {jexl:.....} value.
>>>
>>>         Please show example of your embedded pipeline ?
>>>
>>>         Greetings,
>>>         Greg
>>>
>>>
>>>         2014-03-13 11:09 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>>         <mailto:hansheinrichbraun@yahoo.de>>:
>>>
>>>             How can I use Jexl in an embadded Pipline ?
>>>
>>>             ---------------------------------------------------------------------
>>>             To unsubscribe, e-mail:
>>>             users-unsubscribe@cocoon.apache.org
>>>             <mailto:users-unsubscribe@cocoon.apache.org>
>>>             For additional commands, e-mail:
>>>             users-help@cocoon.apache.org
>>>             <mailto:users-help@cocoon.apache.org>
>>>
>>>
>>
>>
>
>


Mime
View raw message