Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Nesting struts tags

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can somebody tell me if there is another way to get this line of code to work properly? I get an 'equal sign expected error' because I try to 'nest' strut tags.
<logic:equal name="changeItem" property="productName" value="<bean:write name="changeItemProduct" property="productName" /> ">
I have two arrays, and I need to be able to check if the 2 properties in the two beans are equal so I could continue on with the iteration. If not, it should skip.
Thanks!
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't nest JSP custom tags inside custom tag attributes. The only way you can do what you're trying here is to either use a Java scriptlet along the following linesor to use a helper JavaBean which has references to your changeItem and changeItemProduct beans and exposes a boolean property.
Both solutions are, IMHO, unsatisfactory. The underlying problem is that the Struts logic tag library is not quite flexible enough, in particular, it does not implement a full-featured expression language.
Fortunately, these days we have a much superior alternative to the Struts logic tags: the JSP Standard Tag Library (JSTL). This is a standard library sanctioned by the JCP, has been much better conceived, and includes a simple expression language that will be part of the core platform in the next JSP version (2.0).Have fun,
- Peter
 
Bianca Deloso
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
I ran into an error wile trying to use:

Here's the error:


Here's my code in jsp (javascript):

What am I doing wrong? Thanks! Any help would be greatly appreciated! :-)

[reformatted by moderator]
[ October 24, 2003: Message edited by: Junilu Lacar ]
 
Marshal
Posts: 15627
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Bianca Deloso:
<jsp:useBean id="changeItemProduct" type="com.hp.adm.changeItem.ChangeItemProduct"/>
<logic:iterate id="changeItemProduct" name="changeItemProducts">
What am I doing wrong? Thanks! Any help would be greatly appreciated! :-)


The "changeItemProduct" is the duplicate definition.
This is the same type of error you'd get in this code:

The solution is to change one of the id's.
[ October 24, 2003: Message edited by: Junilu Lacar ]
 
What are your superhero powers? Go ahead and try them on this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic