[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglibs-user
Subject:    RE: FWD: need help about translating scriptlets into JSTL EL
From:       Hao Ding <hdi12 () it ! canterbury ! ac ! nz>
Date:       2002-06-25 2:18:04
[Download RAW message or body]

Hi Shawn,

Thank you again for your very valueable help.  I have happily solve the 
problem.

Regards,
Hao

>===== Original Message From Tag Libraries Users List 
<taglibs-user@jakarta.apache.org> =====
>On Tue, 25 Jun 2002, Hao Ding wrote:
>
>> Hi,
>>
>> I have not got an idea to solve the problem below. Can anybody give me
>> a hand?
>
>Hi Hao.  Sorry for the delay.
>
>> The initial code is
>>
>> <%@ page import="mm.*" %>
>> <jsp:useBean id="cate" scope="session" class="mm.CateBean" />
>> <jsp:useBean id="report" scope="page" class="mm.ReportBean" />
>
>This code can stand if your goal is really to create the objects in a JSP
>page.  If you instead want to retrieve the objects as exposed by a
>servlet, you need no analogue to this code in a page that uses JSTL; no
>preparation is necessary to use a scoped variable (though we have talked
>about adding a <declare> tag in future versions of JSP or JSTL to improve
>data typing, much along the lines of Perl's 'use strict').
>
>> <%
>> int idx = report.getId();
>> mm.LData ld = cate.getLData(idx);
>> %>
>>
>> How to translate the Java code into EL using JSTL core library?
>
>The first is straightforward; you may simply say '${report.id}' to
>retrieve the result of the invocation to report.getId().  The latter is
>trickier; JSTL's expression language isn't intended for method access.  If
>you must pass a value to a method, you may do any of the following things,
>some of which are better than others:
>
> - continue to use a scriptlet
> - write a custom tag
> - provide the logic through a bean, where the parameter is set (using
>   perhaps the <c:set target="..." property="..." /> tag) as a bean
>   property, and the result is later retrieved from another bean property.
>
>Hope that helps,
>
>--
>Shawn Bayern
>"JSTL in Action"   http://www.jstlbook.com
>(coming in July 2002 from Manning Publications)
>
>
>--
>To unsubscribe, e-mail:   
<mailto:taglibs-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
<mailto:taglibs-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic