You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by James CE Johnson <jc...@tragus.org> on 2003/03/18 03:18:05 UTC

Modules, tiles and images...

Hi all,


My struts application has several modules. Each module has its own tiles 
definition file and also shares a single "common tiles" definition file. 
  In the common definition file is where I have my layout defined:

<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

   <html>
     <head>
       <title><tiles:getAsString name="title"/></title>
     </head>

     <body>
	<html:img page="/images/corpLogo.png"/>
	<tiles:insert attribute="header"/>
	<tiles:insert attribute="menu"/>
	<tiles:insert attribute="body"/>
	<tiles:insert attribute="footer"/>
     </body>
   </html>

Unfortunately, the generated <img...> tag is rooted at the module's 
context path rather than the application's context path. That means that 
the image never shows up for any of my modules.

I can work around the problem by using a traditional <img...> tag:
	<img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
but that's kind of gross IMO.

For struts tags that support the 'forward' attribute I can define a set 
of global forwards (in a shared struts config file). But the 
<html:img...> tag doesn't seem to support the 'forward' attribute.

Does anybody have a solution to this?

Thanks,
J


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by Eddie Bush <ek...@swbell.net>.
James CE Johnson wrote:

>>James CE Johnson wrote:
>>
>>>>Response inline ...
>>>>
>>>Likewise.
>>>
>>... inline again ... (some clean-up done)
>>
>>>>>Unfortunately, the generated <img...> tag is rooted at the module's
>>>>>context path rather than the application's context path. That means
>>>>>that the image never shows up for any of my modules.
>>>>>
>>>>Have you tried <html:img src="..."/> instead of <html:img
>>>>page="..."/>?
>>>>
>>>Yes. I did that before I posted my question. It doesn't work. Which is
>>>*why* I posted my question.
>>>
>>I see.  You failed to mention that.  I really think the src attribute
>>should be context-relative.
>>    
>>
>Maybe, but you need some way to access images outside of your application
>context too.
>
Yeah - I know you saw that below.  I don't know wth I had going through 
my head when those words slipped through my fingers <smack-head/>.

>As I see it, there are three reasonable sources for images:
>- src: Somewhere in the world
>- page: Somewhere in your module
>- ???: Somewhere in the default app
>
Right.

>>>This always works because it explicitly sets the src of a "raw" img
>>>tag: <img height="34"
>>>    src="<%=request.getContextPath()%>/images/header/logo_efx.gif"
>>>width="284" border="0">
>>>
>>>In any request it yields:
>>><img height="34"
>>>    src="/MyApp/images/header/logo_efx.gif"
>>>    width="284" border="0">
>>>
>>>
>>>This only works in the default module. It fails in any other:
>>><html:img page="/images/header/logo_efx.gif"
>>>    height="34"
>>>    width="284" border="0"/>
>>>
>>>In the admin module, for instance, it yields:
>>><img src="/MyApp/admin/images/header/logo_efx.gif" height="34"
>>>     width="284" border="0">
>>>
>>>This never works because it ignores the context path entirely:
>>><html:img src="/images/header/logo_efx.gif"
>>>    height="34"
>>>    width="284" border="0"/>
>>>
>>>Yielding:
>>><img src="/images/header/logo_efx.gif" height="34"
>>>    width="284" border="0">
>>>
>>Hrm.  The page attribute explicitly states that it is module-relative; I
>> can see why it doesn't work in non-default modules.  The src attribute
>>wasn't as explicit in the javadoc, though - last I used it
>>(<ashamed>haven't had time to update to the most recent copy of
>>Struts</ashamed>) - it was context-relative.
>>
>No, it doesn't work that way in 1.1-RC1. The ImgTag source pretty much
>passes the 'src' attribute directly to the browser.
>
I don't think I've used 1.1-RC1 yet :-(  I've been preoccupied on other 
things.  It, for some reason, popped into my head that was how it worked 
- the more I think about it, the more wrong I believe I was.

>>>>>I can work around the problem by using a traditional <img...> tag:
>>>>>   <img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
>>>>>but that's kind of gross IMO.
>>>>>
>>>>Have you tried examining the javadoc for the ImgTag class?
>>>>
>>>Yes. Believe it or not, RTFM isn't applicable to everyone who asks a
>>>question.
>>>
>>To me, it is - unless you clearly state what you've already tried.  I
>>can't, as my redneck brother would put it, "look up your butt and read
>>your mind".  Don't take that harshly - I'm as serious as you are - not
>>trying to be smart-aelic at all.
>>
>If I told you everything I'd tried before posting to the list you'd never
>both to read my 10-page email :-) At some point we have to assume (yea,
>bad word) that folks have put forth a reasonable effort. At least, that's
>my approach.
>
I know; I know.  ... and I'm generally the guy that flames the flamers 
for flaming.

>>>>Believe
>>>>it or not, the javadocs are well maintained.  Another good source of
>>>>insight is the code itself.  You'll find it remarkably legible and
>>>>easy to follow.  Yes, it may be slightly intimidating at first, but
>>>>there really isn't any one single thing (except perhaps in Tiles or
>>>>the Validator) which is terribly complex.  This isn't rocket science
>>>>by any means.
>>>>
>>>Please don't assume that everyone who asks a question is stupid or new
>>>
>>Congratulations.  Have you any clue how many remedial questions people
>>ask repeatedly on this list simply because they lack RTFM/STFW skills?
>>
>Yes, this list and the other dozen or so I subscribe to. Some of them I
>answer, some of them I ignore, some of them I roll my eyes at. But I try
>very hard not to insult folks with a knee-jerk RTFM-style answer. That
>just doesn't help anyone. Frankly, it pisses off the recipient and makes
>you look like a jerk. Not only to that person but also to anyone reading
>the archives in the future.
>
>On the other hand, if someone repeatedly asks questions that *could* have
>been answer by RTFM then I say flame on. Just don't do it on the first (or
>second or even third) seemingly dumbass question.
>
>> I'm sorry to lump you into that category, but, unless you state what
>>process you've been through to get something to work you can't hardly
>>expect us to know.
>>
>>In the end, it's not really about how (un-)educated or (un-)intelligent
>>a person is.  Mostly it comes down to how (un-)agressive a person is in
>>pursuing a solution to a problem and how (un-)thorough they are about
>>communicating their (un-)successful actions to others.
>>
>I'll fire up 'script' and record everything I do so that you'll have a
>vivid history of everything I try :-)
>
LOL - that's probably overkill :-) but it would be nice for you to say 
"I tried approaches a, b, c, and d.  I got various results: 
<expand-results>".

>>>This is, however, the first time I've busted my application into a
>>>half-dozen modules. Each module has its own struts config and its own
>>>tiles definition file as well as sharing a set of global definitions
>>>and global tiles. As such I'm very like to have a question or two and
>>>it would be nice to ask that question in a non-hostile environment. It
>>>would be a shame if folks have to resort to including a resume in their
>>>signature just to be taken seriously.
>>>
>>I wasn't trying to be hostile.  My apologies if you took it that way.
>> It's ... aggrevating to see so many repetetive questions which could be
>>
>>solved by folks exercising their RTFM/STFW muscles.  Please do continue
>>asking about anything you need clearification on.  Please also include
>>what you have tried that didn't work - the more thorough you are, the
>>less potential there is to wind up in this sort of discussion with
>>someone.
>>
>>Please let us know what you've tried that caused you to ask your
>>question - a resume is not only unnecessary but irrelevant (IMHO).
>> Knowing what you have tried that hasn't worked for you is the surest
>>way for us to be able to determine the cause of your problem.  In this
>>case, I would personally think that the src attribute should be
>>context-relative as that would be what I would consider "proper"
>>behavior.
>>
>>... actually, I'm incorrect.  Doing that would not allow a person to use
>> an image from outside their application.
>>
>>>>>For struts tags that support the 'forward' attribute I can define a
>>>>>set of global forwards (in a shared struts config file). But the
>>>>><html:img...> tag doesn't seem to support the 'forward' attribute.
>>>>>
>>>>Nope - sure doesn't.  Nor, I think, should it.
>>>>
>>>I agree.
>>>
>>>>>Does anybody have a solution to this?
>>>>>
>>>>Yes, read the javadocs :-)
>>>>
>>>I did.
>>>
>>>In fact, I went further than that and added a new attribute to my copy
>>>of ImgTag. This attribute is called 'contextRelative' (similar to its
>>>counterpart in struts-config*xml). When present, an <html:img
>>>page="/foo"/> will not insert the module's prefix in its rendered
>>>output. The patch is available here
>>>http://www.tragus.org/~jcej/ImgTag.patch.
>>>
>>I'm truly sorry I offended you.  That was not my intent.  Seems to me
>>that the way most folks get around the cumbersome-ness you describe is
>>to make use of the "base" tag to reference their image resources.  If
>>your images are centrally-located, a combination of using the base tag
>>and <html:img src= .../> should solve your problem, shouldn't it?
>>
>I tried <html:base/> and a manual <base .../> tag. It might be my browser
>(a recent Mozilla) but that didn't seem to help.
>
Hrm ... that seems odd :-/

>More specifically, I tried:
>   <base href="/MyApplication"/>
>with the hope that a subsequent:
>   <img src="images/foo.gif"/> (or <html:img src="images/foo.gif"/>)
>would find the image from /MyApplication/images/foo.gif.
>
>No joy.
>
>In fact, the <base...> seemed to be completely ignored unless it was
>prefixed with a http://some.server/ (eg -- <base
>href="http://some.server/MyApplication"/>).
>
Hrmph ...

>In any case, if it *did* work, it would affect much more than just the
><img...> tags and probably cause other problems.
>
Yes, it would -- all your relative URLs would be affected.

>>We are definitely open to patches for bug-fixes and enhancements.  Find
>>(or create) a bug report in bugzilla (issues.apache.org/bugzilla) and
>>attach your patch to the bug.  When one of us gets around to applying
>>patches yours will be considered and applied as is deemed appropriate by
>> the commiter examining the patch.  Should your patch be deemed
>>inappropriate, most of us are good about saying why (in our opinion) it
>>wasn't acceptable.  The reason we ask for folks to put such things in
>>bugzilla is that we typically don't have time to
>>examine/apply/test/commit patches when they are posted.  Placing them in
>> bugzilla keeps them from getting lost/forgotten.
>>
>Thanks. I did that earlier today (see 18107 and 18111) and saw that Ted
>posted a response this afternoon. In case you haven't seen it, I also ran
>into a similar issue with the <html:rewrite.../> tag where I'm doing:
>  <td background="<html:rewrite page="/images/foo.gif"/>">...
>Same thing. I need the image to be rooted at the application context, not
>the module context.
>
Yes, I understand your perdicament (now).

>>>>>Thanks,
>>>>>J
>>>>>
>>Peace? :-)
>>
>Yup.
>
>Sorry we got off on the wrong foot. I look forward to "lively debates" in
>the future :-)
>
Ah - no sweat - it's forgotten already.  I regret that you took what I 
said as a personal insult - I (nearly) never give them intentionally, 
but I do come off wrong at times (as I suppose we all do).  Lively 
debates are welcome here AFAIK :-) That's where some of the best ideas 
come from ;-)

-- 
Eddie Bush





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by James CE Johnson <jc...@tragus.org>.
> James CE Johnson wrote:
>
>>>Response inline ...
>>>
>>>
>>Likewise.
>>
> ... inline again ... (some clean-up done)
>
>>>>Unfortunately, the generated <img...> tag is rooted at the module's
>>>> context path rather than the application's context path. That means
>>>> that the image never shows up for any of my modules.
>>>>
>>>>
>>>Have you tried <html:img src="..."/> instead of <html:img
>>> page="..."/>?
>>>
>>Yes. I did that before I posted my question. It doesn't work. Which is
>> *why* I posted my question.
>>
> I see.  You failed to mention that.  I really think the src attribute
> should be context-relative.

Maybe, but you need some way to access images outside of your application
context too.

As I see it, there are three reasonable sources for images:
- src: Somewhere in the world
- page: Somewhere in your module
- ???: Somewhere in the default app

>
>>This always works because it explicitly sets the src of a "raw" img
>> tag: <img height="34"
>>     src="<%=request.getContextPath()%>/images/header/logo_efx.gif"
>> width="284" border="0">
>>
>>In any request it yields:
>><img height="34"
>>     src="/MyApp/images/header/logo_efx.gif"
>>     width="284" border="0">
>>
>>
>>This only works in the default module. It fails in any other:
>><html:img page="/images/header/logo_efx.gif"
>>     height="34"
>>     width="284" border="0"/>
>>
>>In the admin module, for instance, it yields:
>><img src="/MyApp/admin/images/header/logo_efx.gif" height="34"
>>      width="284" border="0">
>>
>>This never works because it ignores the context path entirely:
>><html:img src="/images/header/logo_efx.gif"
>>     height="34"
>>     width="284" border="0"/>
>>
>>Yielding:
>><img src="/images/header/logo_efx.gif" height="34"
>>     width="284" border="0">
>>
> Hrm.  The page attribute explicitly states that it is module-relative; I
>  can see why it doesn't work in non-default modules.  The src attribute
> wasn't as explicit in the javadoc, though - last I used it
> (<ashamed>haven't had time to update to the most recent copy of
> Struts</ashamed>) - it was context-relative.

No, it doesn't work that way in 1.1-RC1. The ImgTag source pretty much
passes the 'src' attribute directly to the browser.

>
>>>>I can work around the problem by using a traditional <img...> tag:
>>>>    <img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
>>>>but that's kind of gross IMO.
>>>>
>>>>
>>>Have you tried examining the javadoc for the ImgTag class?
>>>
>>>
>>Yes. Believe it or not, RTFM isn't applicable to everyone who asks a
>> question.
>>
> To me, it is - unless you clearly state what you've already tried.  I
> can't, as my redneck brother would put it, "look up your butt and read
> your mind".  Don't take that harshly - I'm as serious as you are - not
> trying to be smart-aelic at all.

If I told you everything I'd tried before posting to the list you'd never
both to read my 10-page email :-) At some point we have to assume (yea,
bad word) that folks have put forth a reasonable effort. At least, that's
my approach.

>
>>>Believe
>>>it or not, the javadocs are well maintained.  Another good source of
>>> insight is the code itself.  You'll find it remarkably legible and
>>> easy to follow.  Yes, it may be slightly intimidating at first, but
>>> there really isn't any one single thing (except perhaps in Tiles or
>>> the Validator) which is terribly complex.  This isn't rocket science
>>> by any means.
>>>
>>>
>>Please don't assume that everyone who asks a question is stupid or new
>> to this or both. I've been using Struts and Tiles for years.
>>
> Congratulations.  Have you any clue how many remedial questions people
> ask repeatedly on this list simply because they lack RTFM/STFW skills?

Yes, this list and the other dozen or so I subscribe to. Some of them I
answer, some of them I ignore, some of them I roll my eyes at. But I try
very hard not to insult folks with a knee-jerk RTFM-style answer. That
just doesn't help anyone. Frankly, it pisses off the recipient and makes
you look like a jerk. Not only to that person but also to anyone reading
the archives in the future.

On the other hand, if someone repeatedly asks questions that *could* have
been answer by RTFM then I say flame on. Just don't do it on the first (or
second or even third) seemingly dumbass question.

>  I'm sorry to lump you into that category, but, unless you state what
> process you've been through to get something to work you can't hardly
> expect us to know.
>
> In the end, it's not really about how (un-)educated or (un-)intelligent
> a person is.  Mostly it comes down to how (un-)agressive a person is in
> pursuing a solution to a problem and how (un-)thorough they are about
> communicating their (un-)successful actions to others.

I'll fire up 'script' and record everything I do so that you'll have a
vivid history of everything I try :-)

>
>>This is, however, the first time I've busted my application into a
>> half-dozen modules. Each module has its own struts config and its own
>> tiles definition file as well as sharing a set of global definitions
>> and global tiles. As such I'm very like to have a question or two and
>> it would be nice to ask that question in a non-hostile environment. It
>> would be a shame if folks have to resort to including a resume in their
>> signature just to be taken seriously.
>>
> I wasn't trying to be hostile.  My apologies if you took it that way.
>  It's ... aggrevating to see so many repetetive questions which could be
>
> solved by folks exercising their RTFM/STFW muscles.  Please do continue
> asking about anything you need clearification on.  Please also include
> what you have tried that didn't work - the more thorough you are, the
> less potential there is to wind up in this sort of discussion with
> someone.
>
> Please let us know what you've tried that caused you to ask your
> question - a resume is not only unnecessary but irrelevant (IMHO).
>  Knowing what you have tried that hasn't worked for you is the surest
> way for us to be able to determine the cause of your problem.  In this
> case, I would personally think that the src attribute should be
> context-relative as that would be what I would consider "proper"
> behavior.
>
> ... actually, I'm incorrect.  Doing that would not allow a person to use
>  an image from outside their application.
>
>>>>For struts tags that support the 'forward' attribute I can define a
>>>> set of global forwards (in a shared struts config file). But the
>>>> <html:img...> tag doesn't seem to support the 'forward' attribute.
>>>>
>>>>
>>>Nope - sure doesn't.  Nor, I think, should it.
>>>
>>I agree.
>>
>>>>Does anybody have a solution to this?
>>>>
>>>>
>>>Yes, read the javadocs :-)
>>>
>>I did.
>>
>>In fact, I went further than that and added a new attribute to my copy
>> of ImgTag. This attribute is called 'contextRelative' (similar to its
>> counterpart in struts-config*xml). When present, an <html:img
>>page="/foo"/> will not insert the module's prefix in its rendered
>> output. The patch is available here
>> http://www.tragus.org/~jcej/ImgTag.patch.
>>
> I'm truly sorry I offended you.  That was not my intent.  Seems to me
> that the way most folks get around the cumbersome-ness you describe is
> to make use of the "base" tag to reference their image resources.  If
> your images are centrally-located, a combination of using the base tag
> and <html:img src= .../> should solve your problem, shouldn't it?

I tried <html:base/> and a manual <base .../> tag. It might be my browser
(a recent Mozilla) but that didn't seem to help.

More specifically, I tried:
   <base href="/MyApplication"/>
with the hope that a subsequent:
   <img src="images/foo.gif"/> (or <html:img src="images/foo.gif"/>)
would find the image from /MyApplication/images/foo.gif.

No joy.

In fact, the <base...> seemed to be completely ignored unless it was
prefixed with a http://some.server/ (eg -- <base
href="http://some.server/MyApplication"/>).

In any case, if it *did* work, it would affect much more than just the
<img...> tags and probably cause other problems.

>
> We are definitely open to patches for bug-fixes and enhancements.  Find
> (or create) a bug report in bugzilla (issues.apache.org/bugzilla) and
> attach your patch to the bug.  When one of us gets around to applying
> patches yours will be considered and applied as is deemed appropriate by
>  the commiter examining the patch.  Should your patch be deemed
> inappropriate, most of us are good about saying why (in our opinion) it
> wasn't acceptable.  The reason we ask for folks to put such things in
> bugzilla is that we typically don't have time to
> examine/apply/test/commit patches when they are posted.  Placing them in
>  bugzilla keeps them from getting lost/forgotten.

Thanks. I did that earlier today (see 18107 and 18111) and saw that Ted
posted a response this afternoon. In case you haven't seen it, I also ran
into a similar issue with the <html:rewrite.../> tag where I'm doing:
  <td background="<html:rewrite page="/images/foo.gif"/>">...
Same thing. I need the image to be rooted at the application context, not
the module context.
>
>>>>Thanks,
>>>>J
>>>>
>>>--
>>>Eddie Bush
>>>
> Peace? :-)

Yup.

Sorry we got off on the wrong foot. I look forward to "lively debates" in
the future :-)

>
> --
> Eddie Bush
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by Eddie Bush <ek...@swbell.net>.
James CE Johnson wrote:

>>Response inline ...
>>    
>>
>Likewise.
>
... inline again ... (some clean-up done)

>>>Unfortunately, the generated <img...> tag is rooted at the module's
>>>context path rather than the application's context path. That means
>>>that the image never shows up for any of my modules.
>>>      
>>>
>>Have you tried <html:img src="..."/> instead of <html:img page="..."/>?
>>
>Yes. I did that before I posted my question. It doesn't work. Which is
>*why* I posted my question.
>
I see.  You failed to mention that.  I really think the src attribute 
should be context-relative.

>This always works because it explicitly sets the src of a "raw" img tag:
><img height="34"
>     src="<%=request.getContextPath()%>/images/header/logo_efx.gif"
>     width="284" border="0">
>
>In any request it yields:
><img height="34"
>     src="/MyApp/images/header/logo_efx.gif"
>     width="284" border="0">
>
>
>This only works in the default module. It fails in any other:
><html:img page="/images/header/logo_efx.gif"
>     height="34"
>     width="284" border="0"/>
>
>In the admin module, for instance, it yields:
><img src="/MyApp/admin/images/header/logo_efx.gif" height="34"
>      width="284" border="0">
>
>This never works because it ignores the context path entirely:
><html:img src="/images/header/logo_efx.gif"
>     height="34"
>     width="284" border="0"/>
>
>Yielding:
><img src="/images/header/logo_efx.gif" height="34"
>     width="284" border="0">
>
Hrm.  The page attribute explicitly states that it is module-relative; I 
can see why it doesn't work in non-default modules.  The src attribute 
wasn't as explicit in the javadoc, though - last I used it 
(<ashamed>haven't had time to update to the most recent copy of 
Struts</ashamed>) - it was context-relative.

>>>I can work around the problem by using a traditional <img...> tag:
>>>    <img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
>>>but that's kind of gross IMO.
>>>      
>>>
>>Have you tried examining the javadoc for the ImgTag class?
>>    
>>
>Yes. Believe it or not, RTFM isn't applicable to everyone who asks a
>question.
>
To me, it is - unless you clearly state what you've already tried.  I 
can't, as my redneck brother would put it, "look up your butt and read 
your mind".  Don't take that harshly - I'm as serious as you are - not 
trying to be smart-aelic at all.

>>Believe
>>it or not, the javadocs are well maintained.  Another good source of
>>insight is the code itself.  You'll find it remarkably legible and easy
>>to follow.  Yes, it may be slightly intimidating at first, but there
>>really isn't any one single thing (except perhaps in Tiles or the
>>Validator) which is terribly complex.  This isn't rocket science by any
>>means.
>>    
>>
>Please don't assume that everyone who asks a question is stupid or new to
>this or both. I've been using Struts and Tiles for years.
>
Congratulations.  Have you any clue how many remedial questions people 
ask repeatedly on this list simply because they lack RTFM/STFW skills? 
 I'm sorry to lump you into that category, but, unless you state what 
process you've been through to get something to work you can't hardly 
expect us to know.

In the end, it's not really about how (un-)educated or (un-)intelligent 
a person is.  Mostly it comes down to how (un-)agressive a person is in 
pursuing a solution to a problem and how (un-)thorough they are about 
communicating their (un-)successful actions to others.

>This is, however, the first time I've busted my application into a
>half-dozen modules. Each module has its own struts config and its own
>tiles definition file as well as sharing a set of global definitions and
>global tiles. As such I'm very like to have a question or two and it would
>be nice to ask that question in a non-hostile environment. It would be a
>shame if folks have to resort to including a resume in their signature
>just to be taken seriously.
>
I wasn't trying to be hostile.  My apologies if you took it that way. 
 It's ... aggrevating to see so many repetetive questions which could be 
solved by folks exercising their RTFM/STFW muscles.  Please do continue 
asking about anything you need clearification on.  Please also include 
what you have tried that didn't work - the more thorough you are, the 
less potential there is to wind up in this sort of discussion with someone.

Please let us know what you've tried that caused you to ask your 
question - a resume is not only unnecessary but irrelevant (IMHO). 
 Knowing what you have tried that hasn't worked for you is the surest 
way for us to be able to determine the cause of your problem.  In this 
case, I would personally think that the src attribute should be 
context-relative as that would be what I would consider "proper" behavior.

... actually, I'm incorrect.  Doing that would not allow a person to use 
an image from outside their application.

>>>For struts tags that support the 'forward' attribute I can define a
>>>set of global forwards (in a shared struts config file). But the
>>><html:img...> tag doesn't seem to support the 'forward' attribute.
>>>      
>>>
>>Nope - sure doesn't.  Nor, I think, should it.
>>
>I agree.
>
>>>Does anybody have a solution to this?
>>>      
>>>
>>Yes, read the javadocs :-)
>>
>I did.
>
>In fact, I went further than that and added a new attribute to my copy of
>ImgTag. This attribute is called 'contextRelative' (similar to its
>counterpart in struts-config*xml). When present, an <html:img
>page="/foo"/> will not insert the module's prefix in its rendered output.
>The patch is available here http://www.tragus.org/~jcej/ImgTag.patch.
>
I'm truly sorry I offended you.  That was not my intent.  Seems to me 
that the way most folks get around the cumbersome-ness you describe is 
to make use of the "base" tag to reference their image resources.  If 
your images are centrally-located, a combination of using the base tag 
and <html:img src= .../> should solve your problem, shouldn't it?

We are definitely open to patches for bug-fixes and enhancements.  Find 
(or create) a bug report in bugzilla (issues.apache.org/bugzilla) and 
attach your patch to the bug.  When one of us gets around to applying 
patches yours will be considered and applied as is deemed appropriate by 
the commiter examining the patch.  Should your patch be deemed 
inappropriate, most of us are good about saying why (in our opinion) it 
wasn't acceptable.  The reason we ask for folks to put such things in 
bugzilla is that we typically don't have time to 
examine/apply/test/commit patches when they are posted.  Placing them in 
bugzilla keeps them from getting lost/forgotten.

>>>Thanks,
>>>J
>>>
>>--
>>Eddie Bush
>>
Peace? :-)

-- 
Eddie Bush




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by James CE Johnson <jc...@tragus.org>.
> Response inline ...

Likewise.

>
> James CE Johnson wrote:
>
>> Hi all,
>>
>> My struts application has several modules. Each module has its own
>> tiles definition file and also shares a single "common tiles"
>> definition file.  In the common definition file is where I have my
>> layout defined:
>>
>> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
>> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>>
>>   <html>
>>     <head>
>>       <title><tiles:getAsString name="title"/></title>
>>     </head>
>>
>>     <body>
>>     <html:img page="/images/corpLogo.png"/>
>>     <tiles:insert attribute="header"/>
>>     <tiles:insert attribute="menu"/>
>>     <tiles:insert attribute="body"/>
>>     <tiles:insert attribute="footer"/>
>>     </body>
>>   </html>
>>
>> Unfortunately, the generated <img...> tag is rooted at the module's
>> context path rather than the application's context path. That means
>> that the image never shows up for any of my modules.
>
> Have you tried <html:img src="..."/> instead of <html:img page="..."/>?
>

Yes. I did that before I posted my question. It doesn't work. Which is
*why* I posted my question.

This always works because it explicitly sets the src of a "raw" img tag:
<img height="34"
     src="<%=request.getContextPath()%>/images/header/logo_efx.gif"
     width="284" border="0">

In any request it yields:
<img height="34"
     src="/MyApp/images/header/logo_efx.gif"
     width="284" border="0">


This only works in the default module. It fails in any other:
<html:img page="/images/header/logo_efx.gif"
     height="34"
     width="284" border="0"/>

In the admin module, for instance, it yields:
<img src="/MyApp/admin/images/header/logo_efx.gif" height="34"
      width="284" border="0">


This never works because it ignores the context path entirely:
<html:img src="/images/header/logo_efx.gif"
     height="34"
     width="284" border="0"/>

Yielding:
<img src="/images/header/logo_efx.gif" height="34"
     width="284" border="0">


>> I can work around the problem by using a traditional <img...> tag:
>>     <img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
>> but that's kind of gross IMO.
>
> Have you tried examining the javadoc for the ImgTag class?

Yes. Believe it or not, RTFM isn't applicable to everyone who asks a
question.

> That'd be
> the surest way to find out what the attributes mean.  If you had done
> that, you would have almost certainly seen the src attribute.

Uh huh.

> Believe
> it or not, the javadocs are well maintained.  Another good source of
> insight is the code itself.  You'll find it remarkably legible and easy
> to follow.  Yes, it may be slightly intimidating at first, but there
> really isn't any one single thing (except perhaps in Tiles or the
> Validator) which is terribly complex.  This isn't rocket science by any
> means.

Please don't assume that everyone who asks a question is stupid or new to
this or both. I've been using Struts and Tiles for years.

This is, however, the first time I've busted my application into a
half-dozen modules. Each module has its own struts config and its own
tiles definition file as well as sharing a set of global definitions and
global tiles. As such I'm very like to have a question or two and it would
be nice to ask that question in a non-hostile environment. It would be a
shame if folks have to resort to including a resume in their signature
just to be taken seriously.

>
>> For struts tags that support the 'forward' attribute I can define a
>> set of global forwards (in a shared struts config file). But the
>> <html:img...> tag doesn't seem to support the 'forward' attribute.
>
> Nope - sure doesn't.  Nor, I think, should it.

I agree.

>
>> Does anybody have a solution to this?
>
> Yes, read the javadocs :-)

I did.

In fact, I went further than that and added a new attribute to my copy of
ImgTag. This attribute is called 'contextRelative' (similar to its
counterpart in struts-config*xml). When present, an <html:img
page="/foo"/> will not insert the module's prefix in its rendered output.
The patch is available here http://www.tragus.org/~jcej/ImgTag.patch.

>
>> Thanks,
>> J
>
>
> --
> Eddie Bush
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by Eddie Bush <ek...@swbell.net>.
Mark Zeltser wrote:

>Eddie,
>
>I tried 'src' attribute. It does include submodule name in URI.
>Struts: 1.1b3
>
>Mark.
>
Try the page attribute - which is module-relative.

-- 
Eddie Bush





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by Mark Zeltser <Ma...@morganstanley.com>.
Eddie,

I tried 'src' attribute. It does include submodule name in URI.
Struts: 1.1b3

Mark.

Eddie Bush wrote:

> Response inline ...
>
> James CE Johnson wrote:
>
> > Hi all,
> >
> > My struts application has several modules. Each module has its own
> > tiles definition file and also shares a single "common tiles"
> > definition file.  In the common definition file is where I have my
> > layout defined:
> >
> > <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> >
> >   <html>
> >     <head>
> >       <title><tiles:getAsString name="title"/></title>
> >     </head>
> >
> >     <body>
> >     <html:img page="/images/corpLogo.png"/>
> >     <tiles:insert attribute="header"/>
> >     <tiles:insert attribute="menu"/>
> >     <tiles:insert attribute="body"/>
> >     <tiles:insert attribute="footer"/>
> >     </body>
> >   </html>
> >
> > Unfortunately, the generated <img...> tag is rooted at the module's
> > context path rather than the application's context path. That means
> > that the image never shows up for any of my modules.
>
> Have you tried <html:img src="..."/> instead of <html:img page="..."/>?
>
> > I can work around the problem by using a traditional <img...> tag:
> >     <img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
> > but that's kind of gross IMO.
>
> Have you tried examining the javadoc for the ImgTag class?  That'd be
> the surest way to find out what the attributes mean.  If you had done
> that, you would have almost certainly seen the src attribute.  Believe
> it or not, the javadocs are well maintained.  Another good source of
> insight is the code itself.  You'll find it remarkably legible and easy
> to follow.  Yes, it may be slightly intimidating at first, but there
> really isn't any one single thing (except perhaps in Tiles or the
> Validator) which is terribly complex.  This isn't rocket science by any
> means.
>
> > For struts tags that support the 'forward' attribute I can define a
> > set of global forwards (in a shared struts config file). But the
> > <html:img...> tag doesn't seem to support the 'forward' attribute.
>
> Nope - sure doesn't.  Nor, I think, should it.
>
> > Does anybody have a solution to this?
>
> Yes, read the javadocs :-)
>
> > Thanks,
> > J
>
> --
> Eddie Bush
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

--
NOTICE: If received in error, please destroy and notify sender.  Sender
does not waive confidentiality or privilege, and use is prohibited.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Modules, tiles and images...

Posted by Eddie Bush <ek...@swbell.net>.
Response inline ...

James CE Johnson wrote:

> Hi all,
>
> My struts application has several modules. Each module has its own 
> tiles definition file and also shares a single "common tiles" 
> definition file.  In the common definition file is where I have my 
> layout defined:
>
> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>
>   <html>
>     <head>
>       <title><tiles:getAsString name="title"/></title>
>     </head>
>
>     <body>
>     <html:img page="/images/corpLogo.png"/>
>     <tiles:insert attribute="header"/>
>     <tiles:insert attribute="menu"/>
>     <tiles:insert attribute="body"/>
>     <tiles:insert attribute="footer"/>
>     </body>
>   </html>
>
> Unfortunately, the generated <img...> tag is rooted at the module's 
> context path rather than the application's context path. That means 
> that the image never shows up for any of my modules. 

Have you tried <html:img src="..."/> instead of <html:img page="..."/>?

> I can work around the problem by using a traditional <img...> tag:
>     <img src="<%=request.getContextPath()%>/images/corpLogo.png"/>
> but that's kind of gross IMO. 

Have you tried examining the javadoc for the ImgTag class?  That'd be 
the surest way to find out what the attributes mean.  If you had done 
that, you would have almost certainly seen the src attribute.  Believe 
it or not, the javadocs are well maintained.  Another good source of 
insight is the code itself.  You'll find it remarkably legible and easy 
to follow.  Yes, it may be slightly intimidating at first, but there 
really isn't any one single thing (except perhaps in Tiles or the 
Validator) which is terribly complex.  This isn't rocket science by any 
means.

> For struts tags that support the 'forward' attribute I can define a 
> set of global forwards (in a shared struts config file). But the 
> <html:img...> tag doesn't seem to support the 'forward' attribute. 

Nope - sure doesn't.  Nor, I think, should it.

> Does anybody have a solution to this? 

Yes, read the javadocs :-)

> Thanks,
> J 


-- 
Eddie Bush





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org