File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Cannot use one struts tag within another one? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot use one struts tag within another one?" Watch "Cannot use one struts tag within another one?" New topic
Author

Cannot use one struts tag within another one?

Henry Sun
Greenhorn

Joined: May 09, 2003
Posts: 18
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

Joined: Feb 26, 2001
Posts: 4442
    
    5

The way the JSP parser works, you can't. You could try using JSTL-EL.


Junilu - [How to Ask Questions] [How to Answer Questions]
Henry Sun
Greenhorn

Joined: May 09, 2003
Posts: 18
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

Joined: Oct 06, 2002
Posts: 303
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

Joined: Feb 26, 2001
Posts: 4442
    
    5

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

Joined: May 09, 2003
Posts: 18
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cannot use one struts tag within another one?
 
Similar Threads
problem in html:hidden tag
equal symbol expected?
HTML:link tag with dynamic page attribute?
logic:match , logic:notEqual not working
html:hidden