You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martijn Dashorst <ma...@gmail.com> on 2011/12/03 22:24:47 UTC

Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Or new ContextImage(...)

Martijn

On Wed, Nov 30, 2011 at 9:09 PM, Martin Grigorov <mg...@apache.org> wrote:
> Try with: new Image(someId, new ContextRelativeResource("images/logout.png"))
>
> On Wed, Nov 30, 2011 at 6:40 PM, chris.schaefer <cg...@gmail.com> wrote:
>>
>> another thing i did not mention is,
>>
>> that in this applicaiton the images and js and css files are stored in the
>> webapp/images folder and not in the classpath packages !
>>
>> is it intended / required to store all images within java packages ?
>>
>>
>> chris
>>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4123974.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

If you can reproduce this in a mini application (aka quickstart) then
please attach it to a ticket in our Jira and we will have a look.

On Wed, Jul 4, 2012 at 1:08 PM, sardo <ma...@power-oasis.com> wrote:
> UPDATE:
>
> I created a new TestBasePage and a new class that extends TestBasePage. The
> markup for TestBasePage has the same <head> mark up as that in my
> application's BasePage class.  When I tested the rendered html it still has
> two <head> tags.  I then added the <wicket:head> tag to the child class of
> TestBasePage and then the second <head> disappears. So:
>
> I put this in the child class before the <wicket:extend> tag:
>
>   <wicket:head>
>
>   </wicket:head>
>
> Which renders the following, removing the second <head> tag:
>
>    <head>
>       <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"
> />
>       <title>Test page</title>
>
>       <link type="text/css" rel="stylesheet" href="css/application.css" />
>
>
>
>
>   </head>
>
> Not really a solution, and I still don't know why it's happening.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650357.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by sardo <ma...@power-oasis.com>.
UPDATE:

I created a new TestBasePage and a new class that extends TestBasePage. The
markup for TestBasePage has the same <head> mark up as that in my
application's BasePage class.  When I tested the rendered html it still has
two <head> tags.  I then added the <wicket:head> tag to the child class of
TestBasePage and then the second <head> disappears. So:

I put this in the child class before the <wicket:extend> tag:

  <wicket:head>
    
  </wicket:head>

Which renders the following, removing the second <head> tag:

   <head>
      <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"
/>
      <title>Test page</title>
    
      <link type="text/css" rel="stylesheet" href="css/application.css" />
      
      


  </head>

Not really a solution, and I still don't know why it's happening.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650357.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by sardo <ma...@power-oasis.com>.
Martin Grigorov-4 wrote
> 
> 
>>If you provide components library then you need to distribute the
>>resources too, not just the classes.
>>Shared resources is more for delivering dynamically generated content.
>>A content that is different depending on some external condition
>>(request parameter, session variable, ...).
>>If you have one monolithic application and the resource is really
>>static then I see no reason why not to put it in its expected place in
>>the .war.
> 
> I see thanks Martin. For general app stuff though my personal feeling is
> that it's best to modify as much as possible by just changing the class of
> component's associated tag. 
> 
>>Not sure.
>>I see no <wicket:extend> in UnSecureTemplate.html.
> 
> Oh that's due to my formatting error, I've corrected the post. I'm not
> sure how to fix this one, it's going to take some time to try and debug.
> I've just had a look again at what the Wicket 1.4 version of the app
> produces. I get two <head> tags but it doesn't repeat what's in the
> BasePage <head>, which is what's happening in Wicket 1.5.  See below for
> Wicket 1.4 mark up. Wicket 1.5 reproduces the content of the first header
> (yes I know the css gets added several times, it's one of the things I'm
> correcting. I'm wondering if there's something that's related to repeated
> additions of CSS causing the problem):
> 
> 
> 	<head>
> 		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1"
> />
> 		<title>This site holds the key to wealth, success, and being able to
> attract the opposite sex</title>
> 		<link type="text/css" rel="stylesheet" href="css/application.css"/>
> 		
> 		
> 	<link rel="stylesheet" type="text/css" href="css/application.css" />
>       </head>
> 
> 	
>     <head><link rel="stylesheet" type="text/css"
> href="css/application.css" />
>     </head><body id="body" onload="preloadImages(); return true;">
> 
> 
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650350.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@.apache
>> For additional commands, e-mail: users-help@.apache
>>
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@.apache
> For additional commands, e-mail: users-help@.apache
> 


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650355.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Tue, Jul 3, 2012 at 11:32 PM, sardo <ma...@power-oasis.com> wrote:
> Thanks Martin, that helps. Forgive my naivety, but why do I have the option
> of adding CSS via the Java code? Surely it's better to follow convention and
> add it into the appropriate .war directory?

If you provide components library then you need to distribute the
resources too, not just the classes.
Shared resources is more for delivering dynamically generated content.
A content that is different depending on some external condition
(request parameter, session variable, ...).
If you have one monolithic application and the resource is really
static then I see no reason why not to put it in its expected place in
the .war.

>
> ...and if I could do the Columbo, "Just one more thing", thing. Why am I
> getting two <head> tags in my app?  There's a <title> tag in a base page
> which is linked to a Label component in the code, which when rendered in the
> second <head> tag predictably throws an exception.  The full question is on
> the link below in Stack Overflow. This code worked in Wicket 1.4 but not
> after porting to 1.5:
>
> http://stackoverflow.com/questions/11243714/wicket-head-tag-rendered-twice-for-pages-extending-a-base-page
> http://stackoverflow.com/questions/11243714/wicket-head-tag-rendered-twice-for-pages-extending-a-base-page

Not sure.
I see no <wicket:extend> in UnSecureTemplate.html.

>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650350.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by sardo <ma...@power-oasis.com>.
Thanks Martin, that helps. Forgive my naivety, but why do I have the option
of adding CSS via the Java code? Surely it's better to follow convention and
add it into the appropriate .war directory?

...and if I could do the Columbo, "Just one more thing", thing. Why am I
getting two <head> tags in my app?  There's a <title> tag in a base page
which is linked to a Label component in the code, which when rendered in the
second <head> tag predictably throws an exception.  The full question is on
the link below in Stack Overflow. This code worked in Wicket 1.4 but not
after porting to 1.5:

http://stackoverflow.com/questions/11243714/wicket-head-tag-rendered-twice-for-pages-extending-a-base-page
http://stackoverflow.com/questions/11243714/wicket-head-tag-rendered-twice-for-pages-extending-a-base-page 


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650350.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Either don't use ContextRelativeResource for the css or use it for all
resources, i.e. the image should be delivered by
ContextRelativeResource too.

With the SharedResources you mount the .css at your own url and
deliver its content. But there is no such code for the images.

I'd remove the shared resources mounting and put the <link> to the
.css directly in MyPage.html.

On Tue, Jul 3, 2012 at 11:50 AM, sardo <ma...@power-oasis.com> wrote:
> I have a similar problem:
>
> A css style sheet is added to the app like so:
>
>      getSharedResources().add("css_table", new
> ContextRelativeResource("css/table.css"));
>
> and this css file contains image references like so:
>
>   div.tabpanel div.tab-row li {
>         float: left;
>         background: url("../images/tabs/left.png") no-repeat left top;
>         margin: 0;
>         padding: 0 0 0 9px;
>   }
>
> The problem is the images aren't displayed because Wicket is prefixing the
> path with:
>
>    myApp/wicket/resource/images/tabs/left.png (generates a 404)
>
> instead of leaving it like this:
>
>    myApp/images/tabs/left.png
>
> Is there a way to solve this?  chris.schaefer did ask something similar
> during the discussion above but I don't think it was answered...
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650329.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Caching Imagages, CSS, JS in Wicket 1.5.3

Posted by sardo <ma...@power-oasis.com>.
I have a similar problem:

A css style sheet is added to the app like so:

     getSharedResources().add("css_table", new
ContextRelativeResource("css/table.css"));

and this css file contains image references like so:

  div.tabpanel div.tab-row li {
	float: left;
	background: url("../images/tabs/left.png") no-repeat left top;
	margin: 0;
	padding: 0 0 0 9px;
  }

The problem is the images aren't displayed because Wicket is prefixing the
path with:

   myApp/wicket/resource/images/tabs/left.png (generates a 404)

instead of leaving it like this:

   myApp/images/tabs/left.png

Is there a way to solve this?  chris.schaefer did ask something similar
during the discussion above but I don't think it was answered...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Caching-Imagages-CSS-JS-in-Wicket-1-5-3-tp4121068p4650329.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org