bean:define calls PageContext.setAttribute(), which does return an error if the attribute already exists.
http://java.sun.com/j2ee/j2sdkee/techdocs/api/javax/servlet/jsp/PageContext.html#setAttribute(java.lang.String, java.lang.Object, int) The options seem to be A) Extend bean:define so that it can remove a bean first. B) Create a new tag to remove a bean if it exists (e.g. bean:undefine) C) Use a scriptlet D) Change the ItemList template so that you can pass the name of the item list as a Tiles attribute I'd go with D :) -- Ted Husted, Husted dot Com, Fairport NY USA. -- Building Java web applications with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Joćo Guilherme Del Valle wrote: > > Hi, > > I want to replace a bean. But bean:define does not work the way I thought. > I“d like to do something like this: > > --- > Check the new items: > <bean:define id="items" name="recentItems" toScope="request" /> > <tiles:insert page="ItemList.jsp"/> > > Check the most popular: > <bean:define id="items" name="mostPopularItems" toScope="request" /> > <tiles:insert page="ItemList.jsp"/> > --- > > The page "ItemList.jsp" looks for a bean called "items" and prints it. > But this code gives me a compilation error, "variable items already > defined". I know this could be solved with the following scriptlet: > --- > <% request.setAttribute("items", request.getAttribute("mostLoanedItems") ); > %> > --- > But I have an application with 35 pages and it“s scriptlet-free. I wouldn“t > like to put one because of these. In resume, there are other solutions, but > any ideia of an elegant one? > > Joćo. > > Joao Guilherme Del Valle > [EMAIL PROTECTED] > Visionnaire Informįtica SA > http://www.visionnaire.com.br > Tel/Fax: +55 41 373-7400 r: 217 > > -- > 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]>