From commons-user-return-14154-apmail-jakarta-commons-user-archive=jakarta.apache.org@jakarta.apache.org Fri Nov 04 10:07:36 2005 Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 69388 invoked from network); 4 Nov 2005 10:07:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Nov 2005 10:07:35 -0000 Received: (qmail 80907 invoked by uid 500); 4 Nov 2005 10:07:30 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 80755 invoked by uid 500); 4 Nov 2005 10:07:29 -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 80742 invoked by uid 99); 4 Nov 2005 10:07:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Nov 2005 02:07:29 -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.206 as permitted sender) Received: from [66.249.82.206] (HELO xproxy.gmail.com) (66.249.82.206) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Nov 2005 02:07:23 -0800 Received: by xproxy.gmail.com with SMTP id t14so796398wxc for ; Fri, 04 Nov 2005 02:07:07 -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=eGFDN6JPoLuVojQ7jKDu1RJMBAJ1jPWKGKvawJsZBlb9R6e5Mrh1IK3dtrDPRjfFGsI1vYMOwPP/9zDNFc0RwShnZBQVAmyOa15pDj3fy9rWrHvQ9HBrJqRBmJ5ttTPMEspPL3ev/DmAHt2OKRgainxzRMzNm4pSfzrrEq7fWWU= Received: by 10.11.88.16 with SMTP id l16mr24910cwb; Fri, 04 Nov 2005 02:07:07 -0800 (PST) Received: by 10.11.122.36 with HTTP; Fri, 4 Nov 2005 02:07:07 -0800 (PST) Message-ID: Date: Fri, 4 Nov 2005 02:07:07 -0800 From: Dion Gillard To: Jakarta Commons Users List Subject: Re: [jexl] how to implement variable replacement in expressions In-Reply-To: <339d66100511032042v5a1452e3n1b4ef92e32f085c5@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> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 }, 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 never u= sed > 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