aspose file tools*
The moose likes Struts and the fly likes Tag as function parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tag as function parameter" Watch "Tag as function parameter" New topic
Author

Tag as function parameter

Raul Appletree
Greenhorn

Joined: Sep 30, 2007
Posts: 2
Hello,

I'm trying to use a tag as function parameter, but I don't know how to do it, if it's possible.

I have the following function:

<%!
public String paint (String p_val)
{
String cad = "";

cad += p_val + "<br>";

return cad;
}
%>

And I want to call this function like that:


<%= paint (<html:text property="author" />) %>

is it possible to do it?

Thanks in advance.
Mason Zhao
Greenhorn

Joined: Sep 19, 2007
Posts: 21
Hi, Raul,

Try this
<%
out.print(paint("<html:text property='author' />"));
%>
Raul Appletree
Greenhorn

Joined: Sep 30, 2007
Posts: 2
It doesn't works. It prints the string "<html:text...", but not the code coverted to "<input type='text'...".

Thanks
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html

Look into the section on functions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Originally posted by Raul Appletree:
I'm trying to use a tag as function parameter, but I don't know how to do it, if it's possible.
It isn't. A tag is a unit of processing, not a value that can be passed around. You cannot mix scriplets and tags in this way.

Since it's a Struts tag that you are dealing with, I've moved this to the Struts forum where you should explain what you are actually trying to accomplish so that you can be instructed how to do it using a realistic approach.
[ September 30, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
You might be able to do something like this:


- Brent
[ October 01, 2007: Message edited by: Brent Sterling ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag as function parameter
 
Similar Threads
EL Functions
needed help on jsp + javascript
Setting dynamic parameter values?
Custom Tag Parameters as values from other Custom Tags
Problem While using EL