You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Martin Samm <m_...@rroom.net> on 2001/11/21 10:11:49 UTC

Dynamic Tag values

i'm having trouble populating tag attributes from request parameters. The 
code below generates an error "Attribute name is not specified". 
However, when i remove the pcard tag the other request parameter outputs 
function correctly, so i know that the request parameter is being populated.

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/pnstruts.tld" prefix="pcard" %>
<html>
<head><title>Postcard</title>
</head>
<body>
<h1><%= request.getParameter("name") %></h1>
<p align="center">

<pcard:pcard name="<%= request.getParameter("name") %>">
<%= request.getParameter("name") %></pcard:pcard>

</p>
</body>
</html>


I've also enclosed the tag definition from the .tld (and have set rtexprvalue 
to true).

    <tag>
        <name>pcard</name>
        <tagclass>pnstruts.tags.pcardTag</tagclass>
        <bodycontent>JSP</bodycontent>
        <info>PCARD tag for celeb info</info>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>

Any ideas?
-- 
Martin Samm
m_sam@rroom.net

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Dynamic Tag values

Posted by Martin Samm <m_...@rroom.net>.
Thanks,
i'd discovered that defining and populating a variable and then using it, 
rather than referencing the request directly would work, but as you say, not 
nice!

On Wednesday 21 Nov 2001 3:52 pm, you wrote:
> Hi,
>
> In Your mail sent 21 listopada 2001 You wrote:
>
> MS> i'm having trouble populating tag attributes from request parameters.
> The MS> code below generates an error "Attribute name is not specified".
> MS> However, when i remove the pcard tag the other request parameter
> outputs MS> function correctly, so i know that the request parameter is
> being populated.
>
> [cut]
>
> MS> <pcard:pcard name="<%= request.getParameter("name") %>">
> MS> <%= request.getParameter("name") %></pcard:pcard>
>
> [cut]
>
> I'd same problem with
>
> <logic:equals ... value="<%=session.getParameter("name"%)>"/>
>
> It   generated  the  same  error  as  Yours. Someone wrote, that maybe
> single quotes after value should be used, like:
>
> <logic:equals ... value='<%=session.getParameter("name"%)>'/>
>
> but it didn't word either, although the error was different.
> Finally I settled with:
>
> <%
>   String v = (String)session.getParameter("name"%);
> %>
> <logic:equals ... value="<%=v%>"/>
>
> and  it  works.  I know it's not the nicest way, but I couldn't figure
> antything better.
> Hope It helps.

-- 
Martin Samm
m_sam@rroom.net

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Dynamic Tag values

Posted by Maciej Ko³odziej <Ma...@comarch.pl>.
Hi,

In Your mail sent 21 listopada 2001 You wrote:

MS> i'm having trouble populating tag attributes from request parameters. The 
MS> code below generates an error "Attribute name is not specified". 
MS> However, when i remove the pcard tag the other request parameter outputs 
MS> function correctly, so i know that the request parameter is being populated.

[cut]

MS> <pcard:pcard name="<%= request.getParameter("name") %>">
MS> <%= request.getParameter("name") %></pcard:pcard>

[cut]

I'd same problem with

<logic:equals ... value="<%=session.getParameter("name"%)>"/>

It   generated  the  same  error  as  Yours. Someone wrote, that maybe
single quotes after value should be used, like:

<logic:equals ... value='<%=session.getParameter("name"%)>'/>

but it didn't word either, although the error was different.
Finally I settled with:

<%
  String v = (String)session.getParameter("name"%);
%>
<logic:equals ... value="<%=v%>"/>

and  it  works.  I know it's not the nicest way, but I couldn't figure
antything better.
Hope It helps.


-- 
Best regards,
 Maciej


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>