Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag as function parameter

 
Raul Appletree
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Raul,

Try this
<%
out.print(paint("<html:text property='author' />"));
%>
 
Raul Appletree
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't works. It prints the string "<html:text...", but not the code coverted to "<input type='text'...".

Thanks
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html

Look into the section on functions
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be able to do something like this:


- Brent
[ October 01, 2007: Message edited by: Brent Sterling ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic