tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: cannot update page variable for use with xtags?
Date Fri, 09 Nov 2001 18:31:45 GMT
Hi Richard

XTags uses JSP scopes or 'attributes'. It cannot see the values of scriptlet
expressions unless they are explicitly exported using the pageContext.

If you modify the code as follows it should work...

> <xtags:variable id="helptopic" select="$topic"/>
>
> <%
>    if ("".equals(helptopic)) helptopic = "nohelp";
>    if (helptopic == null) helptopic = "nohelp";  // wasn't sure if i'd see
> an empty string or null

       pageContext.setAttribute( "helptopic", helptopic );


> %>
>
> <xtags:forEach select="/help/topic[topic-key=$helptopic][1]">

James

----- Original Message -----
From: "Richard Sand" <rsand@vgalleries.com>
To: <taglibs-user@jakarta.apache.org>
Sent: Thursday, November 08, 2001 1:27 AM
Subject: cannot update page variable for use with xtags?


> Hi all-
>
> The problem I am encountering is that when I use an xtags tag with a
> variable from the request or page scope, I cannot alter the variable in my
> JSP code.
>
> I'm trying to do the following:
>
> I have a help page generator called help.jsp which uses xtags to display
the
> selected help topic from an xml file (each topic is a tree such as:
> <topic><topic-key>mytopic</topic-key>....</topic>).  The page
gets invoked
> with the desired topic on the query string, such as:
>
> /help.jsp?topic=changepassword
>
> When my xtag usage is as follows, to get the variable directly from the
> request, it works fine, i.e.:
>
> <xtags:forEach select="/help/topic[topic-key=$topic][1]">
>
> However, what I want to do is make sure that the "topic" is provided, so I
> check the value of topic and if its missing, I set it, as follows:
>
> <xtags:variable id="helptopic" select="$topic"/>
>
> <%
>    if ("".equals(helptopic)) helptopic = "nohelp";
>    if (helptopic == null) helptopic = "nohelp";  // wasn't sure if i'd see
> an empty string or null
> %>
>
> <xtags:forEach select="/help/topic[topic-key=$helptopic][1]">
>
> However, this doesn't work!  The xtags treats helptopic as null and exits
> immediately.  I've also tried other hacks like creating a new page
variable,
> but that doesn't work either.  Basically, what I am seeing is that xtags
> allows me to see variables in my page, but it won't pick up on any changes
> to those variables in the page.
>
> Is this the expected behavior?
>
> Thank!
>
> Best regards,
>
> Richard
>
>
> --
> To unsubscribe, e-mail:
<mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:taglibs-user-help@jakarta.apache.org>
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message