tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William C. Robertson" <i...@bytetherapy.com>
Subject RE: xtags:ForEach question (involving parameters)
Date Fri, 13 Jul 2001 06:11:15 GMT
Hi John,

	I think it will work if you assemble the entire string outside of the xpath
tag then use a string variable in the tag.

ie:

String var="//person[child::name[contains(text(), '" +
request.parameters("name") + "')]]"

then

<xtags:forEach select = "<%=var%>">  ...

Make sure the request part is done right (can't remember the exact syntax of
the top of my head.  Anyway, I'm new to xtags too, but try this.  Just stay
away from trying to construct the string within the forEach tag.

-Bill

-----Original Message-----
From: John Townsend [mailto:john.townsend@listenpoint.com]
Sent: Thursday, July 12, 2001 3:53 PM
To: taglibs-user@jakarta.apache.org
Subject: xtags:ForEach question (involving parameters)


I am having a problem with forEach in the xtags library. I am trying to
use XPath and xtags to select all of the person entries from my
directory that contain a substring (For example, all of the people who
have 'John' in their name).

I have an XML file that looks basically like this:

<directory>
	<person>
		<name>John Townsend</name>
		...more data...
	</person>
</directory>

Here's a piece of my JSP page:

	<xtags:forEach select = "//person[child::name[contains(text(),
'$param')]]">
      <TR>
        <TD align=right><xtags:valueOf
select="employee-number"/>&nbsp;&nbsp;</TD>
          <TD><xtags:valueOf select="name"/></TD>
          <TD><xtags:valueOf select="title"/></TD>
          <TD><A
              href="mailto:<xtags:valueOf
select="email"/>"><xtags:valueOf select="email"/></A></TD>
          <TD><NOBR><xtags:valueOf select="phone"/></NOBR></TD>
          <TD><NOBR><xtags:valueOf select="cell"/></NOBR></TD>
          <TD><NOBR><xtags:valueOf select="home"/></NOBR></TD>
          <TD><xtags:valueOf select="messenger"/></TD></TR>
     </xtags:forEach>

If my select in the forEach looks like this:

Select = "//person[child::name[contains(text(), 'John')]]"

Then it works. But, I would like to pass in the 'John' parameter from
the URL. The URL would look something like this:

http://localhost:8080/myapp/mypage.jsp?param=John

Can I do this? I thought if I put $param in my select statement it would
work, but it didn't seem to work.

Any ideas? Forgive my ignorance of XPath, I am just starting to use the
xtags library and XPath.

-- towns



Mime
View raw message