Hi Hans, Your suggestion is very helpful. Thanks again
Hao >===== Original Message From Tag Libraries Users List <[EMAIL PROTECTED]> ===== >Hao Ding wrote: >> Hi, >> >> I have not got an idea to solve the problem below. Can anybody give me a hand? >> >> Regards, >> Hao >> >> >>>===== Original Message From Tag Libraries Users List >> >> <[EMAIL PROTECTED]> ===== >> I have a JSP page that initially uses scriptlets, now I am going to transfer >> it using JSTL tags >> >> 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" /> >> >> <% >> int idx = report.getId(); >> mm.LData ld = cate.getLData(idx); >> %> >> >> How to translate the Java code into EL using JSTL core library? >> >> Any help will be very much appreciated. > >The first part is easy: The "${report.id}" EL expression corresponds >to the "report.getId()" Java code. But there's no support for calling >methods with arguments in the EL, so you need to change things a >bit to do it all with JSTL and the EL. One way is to change the >CateBean so that it has a getter method that returns an array of >all data instead of (or in addition to) the method that returns >one item given a key, i.e. add this method: > > public LData[] getLData() {...} > > >You can then replace all of the above with this: > > <jsp:useBean id="cate" scope="session" class="mm.CateBean" /> > <jsp:useBean id="report" scope="page" class="mm.ReportBean" /> > > <c:set var="ld" value="${cate[report.id]}" /> > >The "ld" variable is then available in other EL expressions, and >as a page scope attribute to custom actions etc. > >Hans >-- >Hans Bergsten [EMAIL PROTECTED] >Gefion Software http://www.gefionsoftware.com >JavaServer Pages http://TheJSPBook.com > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>