Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 60204 invoked from network); 7 Nov 2005 05:44:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Nov 2005 05:44:33 -0000 Received: (qmail 88901 invoked by uid 500); 7 Nov 2005 05:44:29 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 87960 invoked by uid 500); 7 Nov 2005 05:44:27 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 87947 invoked by uid 99); 7 Nov 2005 05:44:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Nov 2005 21:44:27 -0800 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=RCVD_IN_BL_SPAMCOP_NET,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of dion.gillard@gmail.com designates 66.249.82.207 as permitted sender) Received: from [66.249.82.207] (HELO xproxy.gmail.com) (66.249.82.207) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Nov 2005 21:44:20 -0800 Received: by xproxy.gmail.com with SMTP id s14so337114wxc for ; Sun, 06 Nov 2005 21:44:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dqw52seWsbCUcZtQO1DS15vFheXPmwHo6vkAUr9+C+XptDV0JbbtYRdDrTytEo4oZCu3nujk0h5/0Hi+hjgj0ZlQFy0a+SdRNpEeWKNrdQWL5svC//GZrFXV2FtMB35jOMUb/prvJe/dfVBmvWFCD4pK41IBPtXV65rncQUo3aM= Received: by 10.11.120.9 with SMTP id s9mr60541cwc; Sun, 06 Nov 2005 21:44:05 -0800 (PST) Received: by 10.11.122.36 with HTTP; Sun, 6 Nov 2005 21:44:05 -0800 (PST) Message-ID: Date: Mon, 7 Nov 2005 16:44:05 +1100 From: Dion Gillard To: Jakarta Commons Users List Subject: Re: [jexl] how to implement variable replacement in expressions In-Reply-To: <339d66100511062121q6e6e258ma428ab6098b328ee@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <339d66100511032042v5a1452e3n1b4ef92e32f085c5@mail.gmail.com> <339d66100511062121q6e6e258ma428ab6098b328ee@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Nope, the JEXL syntax hasn't changed. I'm guessing they: a) Based their code on something else, possbly Jelly, or b) Never tested it.... On 11/7/05, sean liu wrote: > Thanks a lot for your helps, Dion. > I have some confusion about jexl. > In OReilly book "Jakarta Commons Cookbook", there is a chapter called > "Templating" in which there is the following code snippets: > > import org.apache.commons.jexl.Expression; > > import org.apache.commons.jexl.ExpressionFactory; > > import org.apache.commons.jexl.JexlContext; > > import org.apache.commons.jexl.JexlHelper; > > > > Opera opera =3D new Opera( ); > opera.setName("The Magic Flute"); > opera.setComposer("Mozart"); > opera.setYear(1791); > > > > String expr =3D > > "${opera.name } was composed by ${opera.composer} = in " + > > "${opera.year}."; > > > *Expression e =3D ExpressionFactory.createExpression( expr );* > *JexlContext jc =3D JexlHelper.createContext( );* > *jc.getVars( ).put("opera", opera);* > *String message =3D (String) e.evaluate(jc);* > > > System.out.println( message ); > > I don't know why these code ssnippets doesn't work.Have the jexl > expression syntax changed? > > On 11/4/05, Dion Gillard wrote: > > > > On 11/3/05, sean liu wrote: > > > Hi guys: > > > I want to use jexl to implement variable replacement in expressions. = For > > > example: > > > expression: "Hello: ${person.name < > > http://person.name/>}, your age is ${ > > > > Try with the following Expression in double quotes: > > 'Hello ' + person.name + ' + '/>, your age is > > ' + person.age > > > > > > > person.age}!" > > > public class Person { > > > private String name; > > > private int age; > > > //setters,getters > > > } > > > i use the following codes: > > > Person person =3D new Person(); > > > person.setName(sean); > > > person.setAge(26); > > > > > > Expression e =3D ExpressionFactory.createExpression(expression); > > > > > > JexlContext jc =3D JexlHelper.createContext(); > > > > > > jc.getVars().put("person", person); > > > > > > message =3D (String) e.evaluate(jc); > > > > > > System.out.println(message); > > > > > > It doesn't work.I dont know what's wrong with expression. I have neve= r > > used > > > jexl before, so if anyone can give me some help, thanks a lot! > > > > > > > > > > > > -- > > http://www.multitask.com.au/people/dion/ > > "You are going to let the fear of poverty govern your life and your > > reward will be that you will eat, but you will not live." - George > > Bernard Shaw > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > > > > > -- http://www.multitask.com.au/people/dion/ "You are going to let the fear of poverty govern your life and your reward will be that you will eat, but you will not live." - George Bernard Shaw --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org