Re: Apache Velocity : Verify if all substitutions are made
Stefan Großhauser <[email protected]> Wed, 14 Jun 2023 08:27:30 +0200
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
------------MIME-3096871516-1795696037-delim Content-Type: multipart/alternative; boundary="=-LvuEBtIXEl6WZRYORaMe" --=-LvuEBtIXEl6WZRYORaMe Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello=2C isn=27t the =22strict mode=22 already what you want=3F https=3A//velocity=2Eapache=2Eorg/engine/devel/user-guide=2Ehtml=23strict-r= endering-mode best regards Stefan Von=3A Debraj Manna =3Csubharaj=2Emanna=40gmail=2Ecom=3E=20 An=3A =3Cuser=40velocity=2Eapache=2Eorg=3E=20 Gesendet=3A 13=2E06=2E2023 11=3A38=20 Betreff=3A Apache Velocity =3A Verify if all substitutions are made=20= Can someone let me know how I can verify a velocity context against a=20 template=3F Basically=2C I want to throw some error if all variables are no= t=20 substituted in the velocity template=2E=20 =20 For example=2C let=27s say I have a velocity template=2C card=2Evm=20 =20 =C2=A0card =7B=20 =C2=A0 =C2=A0type=3A CREDIT=20 =C2=A0 =C2=A0company=3A VISA=20 =C2=A0 =C2=A0name=3A =22=24=7BfirstName=7D =24=7BlastName=7D=22=20 =C2=A0=7D=20 =20 The substitution is done like below=20 =20 VelocityEngine velocityEngine =3D new VelocityEngine=28=29=3B=20 velocityEngine=2Einit=28=29=3B=20 =20 Template t =3D velocityEngine=2EgetTemplate=28=22card=2Evm=22=29=3B=20 =20 VelocityContext context =3D new VelocityContext=28=29=3B=20 context=2Eput=28=22firstName=22=2C =22tuk=22=29=3B=20 StringWriter writer =3D new StringWriter=28=29=3B=20 t=2Emerge=28 context=2C writer =29=3B=20 =20 In this case=2C I want to throw some error specifying that lastName is not= =20 replaced in template=2E=20 =20 Does velocity provide anything for this=3F=20 =20 JETZT NEWSLETTER ABONNIEREN=3A https=3A//hammerbacher=2Ecom/newsletter-anme= ldung/ Hammerbacher GmbH Registergericht N=C3=BCrnberg HRB 10908Gesch=C3=A4ftsf= =C3=BChrer Bernhard Hammerbacher=2C Ursula Hammerbacher=2C Christoph Hammer= bacher=2C Andreas Hammerbacher =20 =09Hausanschrift Daimlerstra=C3=9Fe 4-6 D 92318 Neumarkt =09Telefon +49=280=299181 2592-0 =09Telefax +49=280=299181 2592-28 =09E-Mail info=40hammerbacher=2Ecom www=2Ehammerbacher=2Ecom =20 Haftungsausschluss / Disclaimer=20 Die Informationen=2C die in dieser Kommunikation enthalten sind=2C sind aus= schlie=C3=9Flich und allein f=C3=BCr den Empf=C3=A4nger bestimmt=2E Die Ver= wendung durch Dritte ist untersagt=2E Die Firma Hammerbacher GmbH ist nur f= =C3=BCr die von ihr eingegeben Informationen verantwortlich=2C jedoch nicht= f=C3=BCr die einwandfreie =C3=9Cbertragung oder im Zusammenhang mit der=20= =C3=9Cbertragung oder dem Empfang eingetretene Ver=C3=A4nderungen oder Verz= =C3=B6gerungen=2E Diese E-Mail enth=C3=A4lt vetrtrauliche und/oder rechtlic= h gesch=C3=BCtzte Informationen=2E Wenn Sie nicht der richtige Adressat sin= d oder diese E-Mail irrt=C3=BCmlich erhalten haben=2C informieren Sie bitte= sofort den Absender und vernichten Sie diese E-Mail=2E Das unerlaubte Kopi= eren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet=2E=20 --=-LvuEBtIXEl6WZRYORaMe Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable =3Chtml=3E=3Chead=3E=3C/head=3E=3Cbody=3E=3Cdiv=3E=3Cbr=3E=3C/div=3E=3Cdiv= =3EHello=2C=3C/div=3E=3Cdiv=3E=3Cbr=3E=3C/div=3E=3Cdiv=3Eisn=27t the =22str= ict mode=22 already what you want=3F=3C/div=3E=3Cdiv=3E=3Cbr=3E=3C/div=3E= =3Cdiv=3Ehttps=3A//velocity=2Eapache=2Eorg/engine/devel/user-guide=2Ehtml= =23strict-rendering-mode=3Cbr=3E=3C/div=3E=3Cdiv=3E=3Cbr=3E=3C/div=3E=3Cdiv= =3Ebest regards=3Cbr=3E=3C/div=3E=3Cbr=3EStefan=3Cbr=3E=3Cbr=3E=3Cbr=3E=3Cb= r=3E=3Cdiv=3E=3Cstrong=3E Von=3A =3C/strong=3E =20 Debraj Manna =26lt=3Bsubharaj=2Emanna=40gmail=2Ecom=26gt=3B =3Cbr=3E =3Cstrong=3E An=3A =3C/strong=3E =20 =26lt=3Buser=40velocity=2Eapache=2Eorg=26gt=3B =3Cbr=3E =3Cstrong=3E Gesendet=3A =20 =3C/strong=3E 13=2E06=2E2023 11=3A38 =3Cbr=3E =3Cstrong=3E Betreff=3A =3C/strong=3E =20 Apache Velocity =3A Verify if all substitutions are made =3Cbr=3E=3Cbr=3E=3Cblockquote class=3D=22mcntmori=22 style=3D=22margin=3A0= 0 0 =2E8ex=3Bborder-left=3A1px solid =23CCC=3Bpadding-left=3A1ex=3B=22=3EC= an someone let me know how I can verify a velocity context against a =3Cbr=3Etemplate=3F Basically=2C I want to throw some error if all variable= s are not =3Cbr=3Esubstituted in the velocity template=2E =3Cbr=3E =3Cbr=3EFor example=2C let=27s say I have a velocity template=2C card=2Evm= =3Cbr=3E =3Cbr=3E =26nbsp=3Bcard =7B =3Cbr=3E =26nbsp=3B =26nbsp=3Btype=3A CREDIT =3Cbr=3E =26nbsp=3B =26nbsp=3Bcompany=3A VISA =3Cbr=3E =26nbsp=3B =26nbsp=3Bname=3A =22=24=7BfirstName=7D =24=7BlastName= =7D=22 =3Cbr=3E =26nbsp=3B=7D =3Cbr=3E =3Cbr=3EThe substitution is done like below =3Cbr=3E =3Cbr=3EVelocityEngine velocityEngine =3D new VelocityEngine=28=29=3B =3Cbr=3EvelocityEngine=2Einit=28=29=3B =3Cbr=3E =3Cbr=3ETemplate t =3D velocityEngine=2EgetTemplate=28=22card=2Evm=22=29=3B= =3Cbr=3E =3Cbr=3EVelocityContext context =3D new VelocityContext=28=29=3B =3Cbr=3Econtext=2Eput=28=22firstName=22=2C =22tuk=22=29=3B =3Cbr=3EStringWriter writer =3D new StringWriter=28=29=3B =3Cbr=3Et=2Emerge=28 context=2C writer =29=3B =3Cbr=3E =3Cbr=3EIn this case=2C I want to throw some error specifying that lastName= is not =3Cbr=3Ereplaced in template=2E =3Cbr=3E =3Cbr=3EDoes velocity provide anything for this=3F =3Cbr=3E=3C/blockquote=3E=3C/div=3E= =3CBR /=3E =3CBR /=3E =3Cbr=3E=3Cdiv style=3D=22font-family=3A Arial=3B=22=3E=3Cfont size=3D=221= =22=3E=3Cb=3E=3Cbr=3EJETZT NEWSLETTER ABONNIEREN=3A =3Ca href=3D=22https=3A= //hammerbacher=2Ecom/newsletter-anmeldung/=22 target=3D=22=5Fblank=22=3Ehtt= ps=3A//hammerbacher=2Ecom/newsletter-anmeldung/=3Cbr=3E=3Cbr=3E=3C/a=3E=3C/= b=3E=3C/font=3E=3Cimg src=3D=22cid=3A80df252d=2E5233de5c=2Epng=2E30f6e647= =22=3E=3Cbr=3E=3Cdiv=3E=3Cfont color=3D=22=23808080=22=3E=3Cfont size=3D=22= 2=22=3E=3Cu=3E=3Cfont size=3D=221=22=3EHammerbacher GmbH Registergericht N= =C3=BCrnberg HRB 10908=3C/font=3E=3C/u=3E=3C/font=3E=3C/font=3E=3C/div=3E= =3Cdiv=3E=3Cfont color=3D=22=23808080=22=3E=3Cfont size=3D=222=22=3E=3Cu=3E= =3Cfont size=3D=221=22=3EGesch=C3=A4ftsf=C3=BChrer Bernhard Hammerbacher=2C= Ursula Hammerbacher=2C Christoph Hammerbacher=2C Andreas Hammerbacher=3C/f= ont=3E=3C/u=3E=3C/font=3E=3C/font=3E=3Cfont color=3D=22=23808080=22=3E=3Cfo= nt size=3D=222=22=3E=3Cu=3E =3C/u=3E=3C/font=3E=3C/font=3E =3C/div=3E=3Ctable style=3D=22width=3A 620px=3B height=3A 32px=3B text-alig= n=3A left=3B=22 cellspacing=3D=220=22 cellpadding=3D=220=22 border=3D=220= =22=3E =3Ctbody=3E =3Ctr=3E =3Ctd style=3D=22width=3A 25=25=3B font-family=3A Arial=3B=22=3E=3Csmall=3E= =3Csmall=3E=3Cspan style=3D=22color=3A rgb=28204=2C 0=2C 0=29=3B=22=3E=3Csp= an style=3D=22color=3A rgb=28255=2C 0=2C 0=29=3B=22=3EHausanschrift=3C/span= =3E=3Cbr=3E=3C/span=3E=3C/small=3E=3C/small=3E=3Csmall=3E=3Csmall=3E=3Cspan= style=3D=22color=3A rgb=28102=2C 102=2C 102=29=3B=22=3E=3Cfont color=3D=22= =23808080=22=3EDaimlerstra=C3=9Fe 4-6=3Cbr=3E=3C/font=3E=3Cfont color=3D=22= =23808080=22=3ED 92318 Neumarkt=3C/font=3E=3C/span=3E=3C/small=3E=3C/small=3E=3C/td=3E =3Ctd style=3D=22width=3A 20=25=3B font-family=3A Arial=3B=22=3E=3Csmall=3E= =3Csmall=3E=3Cspan style=3D=22color=3A rgb=28255=2C 0=2C 0=29=3B=22=3ETelef= on=3Cbr=3E=3C/span=3E=3C/small=3E=3C/small=3E=3Csmall=3E=3Csmall=3E=3Cfont= color=3D=22=23808080=22=3E+49=280=299181=3Cbr=3E2592-0=3C/font=3E=3C/small= =3E=3C/small=3E=3C/td=3E =3Ctd style=3D=22width=3A 20=25=3B font-family=3A Arial=3B=22=3E=3Csmall=3E= =3Csmall=3E=3Cspan style=3D=22color=3A rgb=28204=2C 0=2C 0=29=3B=22=3E=3Csp= an style=3D=22color=3A rgb=28255=2C 0=2C 0=29=3B=22=3ETelefax=3C/span=3E=3C= br=3E=3C/span=3E=3C/small=3E=3C/small=3E=3Csmall=3E=3Csmall=3E=3Cfont color= =3D=22=23808080=22=3E+49=280=299181=3Cbr=3E2592-28=3C/font=3E=3C/small=3E= =3C/small=3E=3C/td=3E =3Ctd style=3D=22width=3A 30=25=3B font-family=3A Arial=3B=22=3E=3Csmall=3E= =3Csmall=3E=3Cspan style=3D=22color=3A rgb=28204=2C 0=2C 0=29=3B=22=3E=3Csp= an style=3D=22color=3A rgb=28255=2C 0=2C 0=29=3B=22=3EE-Mail=3C/span=3E=3Cb= r=3E=3C/span=3E=3C/small=3E=3C/small=3E=3Csmall=3E=3Csmall=3E=3Cspan style= =3D=22color=3A rgb=28102=2C 102=2C 102=29=3B=22=3E=3Ca href=3D=22mailto=3Ai= nfo=40hammerbacher=2Ecom=22=3E=3Cspan style=3D=22color=3A rgb=28102=2C 102= =2C 102=29=3B=22=3E=3Cfont color=3D=22=23808080=22=3Einfo=40hammerbacher=2E= com=3C/font=3E=3C/span=3E=3C/a=3E=3Cbr=3E=3Ca href=3D=22https=3A//www=2Eham= merbacher=2Ecom/=22=3E=3Cfont color=3D=22=23808080=22=3Ewww=2Ehammerbacher= =2Ecom=3C/font=3E=3C/a=3E=3Cbr=3E=3C/span=3E=3C/small=3E=3C/small=3E=3C/td= =3E=3C/tr=3E=3C/tbody=3E=3C/table=3E=3Cp=3E =3Cbr=3E=3Cspan style=3D=22font-family=3A arial=3B=22=3E=3Cfont size=3D=221= =22=3EHaftungsausschluss / Disclaimer =3Cbr=3E=3Cfont color=3D=22=23808080=22=3EDie Informationen=2C d= ie in dieser Kommunikation enthalten sind=2C sind ausschlie=C3=9Flich und a= llein f=C3=BCr den Empf=C3=A4nger bestimmt=2E Die Verwendung durch Dritte i= st untersagt=2E Die Firma Hammerbacher GmbH ist nur f=C3=BCr die von ihr ei= ngegeben Informationen verantwortlich=2C jedoch nicht f=C3=BCr die einwandf= reie =C3=9Cbertragung oder im Zusammenhang mit der =C3=9Cbertragung oder de= m Empfang eingetretene Ver=C3=A4nderungen oder Verz=C3=B6gerungen=2E Diese E-Mail enth=C3=A4lt vetrtrauliche und/oder rechtlich gesch=C3=BCtzte= Informationen=2E Wenn Sie nicht der richtige Adressat sind oder diese E-Ma= il irrt=C3=BCmlich erhalten haben=2C informieren Sie bitte sofort den Abse= nder und vernichten Sie diese E-Mail=2E Das unerlaubte Kopieren sowie die u= nbefugte Weitergabe dieser Mail ist nicht gestattet=2E =3C/font=3E=3C/font=3E=3C/span=3E=3C/p=3E=3C/br=3E=3Cdiv=3E=3CBR /=3E =3C/body=3E=3C/html=3E --=-LvuEBtIXEl6WZRYORaMe-- ------------MIME-3096871516-1795696037-delim--