• 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Cannot use one struts tag within another one?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, friends,
In my jsp page, there is input like this: <input type="text" name="aName" value="<%= myBean.getMyProperty() %>" >
I want to rewrite it with struts tag as following:
<html:text property="aName" value="<bean:write name="myBean" property="myProperty" />" />. But the compiler always complains error. As long as I remove <bean:write> tag, it works. I am wondering can't I use one struts tag within another one?
thanks.
henry
 
Marshal
Posts: 14347
237
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way the JSP parser works, you can't. You could try using JSTL-EL.
 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Junilu Lacar:
The way the JSP parser works, you can't. You could try using JSTL-EL.


I think there should be a lot of cases like what I am doing. What are the other developers fixing this issue except using the JSTL?
thanks.
henry
 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
If you are using Struts 1.1, you can use the 'nested' tag library in order to nest tags though. Having never used it, however, I can't say more about it :-)
Darryl
 
Junilu Lacar
Marshal
Posts: 14347
237
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry/Darryl: I haven't really used the nested tags but from what I can recall, they still wouldn't do what Henry wanted to do, which is to nest a tag as an attribute value.
Henry, you'll either have to stick with a variation of the first form:
<input type="text" name="aName" value="<bean:write name="myBean" property="myProperty" />">
or set the value of your form property before you display it. I prefer to do this type of initialization in code rather than in the JSP since default values are usually considered as "business rules".
 
Henry Sun
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu, you are correct. Nested tag cannot resolve my problem. Just thinking to use one of the ways you mentioned.
Thanks a lot for all pastes.
Henry
 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!