struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: bean:define vs c:set
Date Thu, 29 Jul 2004 16:24:56 GMT
You are correct that <c:set> does not create a scripting variable, so
you can't use the specified identifier in a scriptlet.  The question,
though, is why are you still using a scriptlet expression?  Why not
use an EL expression instead?

  <pg:pager maxPageItems="${pageItems}"/>

or, to avoid needing to do the <c:set> in the first place:

  <pg:pager maxPageItems="${optionsForm.pagItems}"/>


The appropriate conversions will happen for you automatically.

Craig


On Thu, 29 Jul 2004 17:24:35 +0200, Kris Barnhoorn <kris@biassweb.be> wrote:
> Hi,
> 
> First of all I'd like to thank the contributors of this mailinglist. I'm
> using struts for over 1.5 years now and i always found answers in
> archives.
> 
> In this mailinglist and in the contrib/el there is often suggested that
> the best way to prepare for smooth transition to JSP 2.0 is to use el
> tags now and once the application runs on a container that supports JSP
> 2.0 just change the links to the tags in web.xml.
> 
> Well found an inconvenience in the fact that the define tag was not
> ported.
> 
> I have a value in a request variable that specifies who many page items
> should be displayed on the page.
> But because the pager tag hasn't el capabilities i had to use the define
> tag like:
> 
> <bean:define id="pageItems" name="optionsForm" property="pageItems"
> type="java.lang.Integer"/>
> 
> <pg:pager
>         maxPageItems="<%=pageItems.intValue()%>">
> 
> //items
> </pg:pager>
> 
> In the el way it should be like:
> 
> <c:set var="pageItems" value="${optionsForm.pageItems}"/>
> 
> <pg:pager
>         maxPageItems="<%=pageItems.intValue()%>">
> 
> //items
> </pg:pager>
> 
> --> but the var pageItems can't be use in scriptlet (not in c or c_rt)
> 
> So I guess is there a way to work around this without declaring the
> pageItems like this?
> 
> <% Integer pageItems =
> ((com.mycompany.foo.struts.OptionsForm)request.getAttribute("optionsForm
> ")).getItems();%>
> 
> Thank you
> Kris.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message