• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot use one struts tag within another one?

 
Henry Sun
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
 
Junilu Lacar
Bartender
Pie
Posts: 7306
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • 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
 
Darryl A. J. Staflund
Ranch Hand
Posts: 310
2
Android Java VI Editor
  • 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
Bartender
Pie
Posts: 7306
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic