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


JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 56529
    
  14

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 ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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
Problem While using EL
needed help on jsp + javascript
Custom Tag Parameters as values from other Custom Tags
Setting dynamic parameter values?