You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Winterfeldt <dw...@yahoo.com> on 2001/01/04 01:28:04 UTC

Logic Present Tag

Role was recently added to the logic:present tag
(thanks), but it would be nice if there was some way
to check for multiple roles.  Either by comma
delimiting the String or passing in a String[],
Collection, or anything else if someone can think of a
better way.

David Winterfeldt

__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/

Action Path Problem (Again) when Doc Base used

Posted by Deping Chian <de...@infopoll.net>.
> All my Struts actions work OK until I inserted <base href='http://java'>
in my HTML document.
After Craig fixed this for <form:link page="/logoff.do"> it works ok for NOT
linking to http://java/logoff.do. I am very happy to use this tag now.

But when I used: <form:form action="listfaq.do"  .... >
This action still submits to:   http://java/listfaqs.do
which can not be found by the action servlet. Could someone also fixes this
for me please?

Thanks a lot,

Deping


Re: Action Path Problem when Doc Base used

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Deping Chian wrote:

> Craig,
>
> Thanks for your suggestion. But I HAVE to use doc base for all my HTML pages
> under a certain template. This template has numourous pictures links,
> company logos, JavaScript libraries, et al, which are already written by
> someone else, stored in an organized directory structure in another server
> (i.e. http://java). In this template I inserted a few special tags (e.g.
> <#FAQS/>) for my JSP pages to replace with relevant HTMLs.
>
> I could setup a String servAddr for the real server address and use
> <a href="<%=servAddr%>/logoff.do"><bean:message key="mainMenu.logoff"/></a>
> to replace
> <form:link page="/logoff.do"><bean:message
> key="mainMenu.logoff"/></form:link>
> and it now correctly links to http://localhost:8080/logoff.do.
>
> But <form:link page="<%=servAddr%>/logoff.do"><bean:message
> key="mainMenu.logoff"/></form:link>
> links to http://java/<%=servAddr%>/logoff.do which is wierd. In other words,
> it seems that my Tomcat does not translate <%=xxx%> tag before taglib calls.
>

One thing to note here is that it is not legal JSP syntax to mix a runtime
expression and static text in an attribute, like this:

    <form:link page="<%= servAddr %>/logoff.do">

this should be giving you a compile error -- you would replace it with

    <form:link page='<%= srvAddr + "/logoff.do" %>'>

instead (note the switch to single quotes around the entire attribute.

But, I'm also fixing <form:link page="/xxx"> so that it works correctly for you,
by generating a complete absolute URL instead of a server-relative one.  The
current logic does not deal correctly with cases where a <base> tag is present.
The fix will be in tonight's nightly build, and you will be able to go back to:

    <form:link page="/logoff.do">

>
> Anyway, it's mostly solved for myself.
>
> Deping
>

Craig


>
> ----- Original Message -----
> From: "Craig R. McClanahan" <Cr...@eng.sun.com>
> To: <st...@jakarta.apache.org>
> Sent: Friday, January 05, 2001 6:42 PM
> Subject: Re: Action Path Problem when Doc Base used
>
> > Deping Chian wrote:
> >
> > > All my Struts actions work OK until I inserted <base href='http://java'>
> in
> > > my HTML document.
> > >
> > > This doc base caused
> > >     <form:link page="/logoff.do"><bean:message
> > > key="mainMenu.logoff"/></form:link>
> > > to link to http://java/logoff.do and of course Struts action servlet
> does
> > > not know how to handle this.
> > >
> >
> > Well, the smart ass answer would be "so don't do that" :-)
> >
> > What the <base> tag does is tells your browser to resolve relative
> references in
> > this page against the specified URL, instead of the URL it submitted to
> (which
> > will typically be an xxxxx.do URI in a Struts application).  What are you
> trying
> > to accomplish with this base setting?
> >
> > Note also that there is a <form:base/> tag you can use that generates an
> HREF of
> > the JSP page itself, so that relative references in JSP pages work the way
> you
> > think they would (relative to the page itself), even when invoked via a
> forward.
> >
> > >
> > > Any tricks?
> > >
> > > Deping
> >
> > Craig
> >
> >


Re: Action Path Problem when Doc Base used

Posted by Deping Chian <de...@infopoll.net>.
Craig,

Thanks for your suggestion. But I HAVE to use doc base for all my HTML pages
under a certain template. This template has numourous pictures links,
company logos, JavaScript libraries, et al, which are already written by
someone else, stored in an organized directory structure in another server
(i.e. http://java). In this template I inserted a few special tags (e.g.
<#FAQS/>) for my JSP pages to replace with relevant HTMLs.

I could setup a String servAddr for the real server address and use
<a href="<%=servAddr%>/logoff.do"><bean:message key="mainMenu.logoff"/></a>
to replace
<form:link page="/logoff.do"><bean:message
key="mainMenu.logoff"/></form:link>
and it now correctly links to http://localhost:8080/logoff.do.

But <form:link page="<%=servAddr%>/logoff.do"><bean:message
key="mainMenu.logoff"/></form:link>
links to http://java/<%=servAddr%>/logoff.do which is wierd. In other words,
it seems that my Tomcat does not translate <%=xxx%> tag before taglib calls.

Anyway, it's mostly solved for myself.

Deping

----- Original Message -----
From: "Craig R. McClanahan" <Cr...@eng.sun.com>
To: <st...@jakarta.apache.org>
Sent: Friday, January 05, 2001 6:42 PM
Subject: Re: Action Path Problem when Doc Base used


> Deping Chian wrote:
>
> > All my Struts actions work OK until I inserted <base href='http://java'>
in
> > my HTML document.
> >
> > This doc base caused
> >     <form:link page="/logoff.do"><bean:message
> > key="mainMenu.logoff"/></form:link>
> > to link to http://java/logoff.do and of course Struts action servlet
does
> > not know how to handle this.
> >
>
> Well, the smart ass answer would be "so don't do that" :-)
>
> What the <base> tag does is tells your browser to resolve relative
references in
> this page against the specified URL, instead of the URL it submitted to
(which
> will typically be an xxxxx.do URI in a Struts application).  What are you
trying
> to accomplish with this base setting?
>
> Note also that there is a <form:base/> tag you can use that generates an
HREF of
> the JSP page itself, so that relative references in JSP pages work the way
you
> think they would (relative to the page itself), even when invoked via a
forward.
>
> >
> > Any tricks?
> >
> > Deping
>
> Craig
>
>


Re: Action Path Problem when Doc Base used

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Deping Chian wrote:

> All my Struts actions work OK until I inserted <base href='http://java'> in
> my HTML document.
>
> This doc base caused
>     <form:link page="/logoff.do"><bean:message
> key="mainMenu.logoff"/></form:link>
> to link to http://java/logoff.do and of course Struts action servlet does
> not know how to handle this.
>

Well, the smart ass answer would be "so don't do that" :-)

What the <base> tag does is tells your browser to resolve relative references in
this page against the specified URL, instead of the URL it submitted to (which
will typically be an xxxxx.do URI in a Struts application).  What are you trying
to accomplish with this base setting?

Note also that there is a <form:base/> tag you can use that generates an HREF of
the JSP page itself, so that relative references in JSP pages work the way you
think they would (relative to the page itself), even when invoked via a forward.

>
> Any tricks?
>
> Deping

Craig



Action Path Problem when Doc Base used

Posted by Deping Chian <de...@infopoll.net>.
All my Struts actions work OK until I inserted <base href='http://java'> in
my HTML document.

This doc base caused
    <form:link page="/logoff.do"><bean:message
key="mainMenu.logoff"/></form:link>
to link to http://java/logoff.do and of course Struts action servlet does
not know how to handle this.

Any tricks?

Deping


Re: Logic Present Tag

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
David Winterfeldt wrote:

> Role was recently added to the logic:present tag
> (thanks), but it would be nice if there was some way
> to check for multiple roles.  Either by comma
> delimiting the String or passing in a String[],
> Collection, or anything else if someone can think of a
> better way.
>

You can do an "and" by nesting:

    <logic:present role="admin">
        <logic:present role="manager">
            User is an admin and a manager
        </logic:present>
    </logic:present>

so I assume you are talking about implementing an "or" check, right?

>
> David Winterfeldt
>

Craig