You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by David Leangen <wi...@leangen.net> on 2008/02/28 04:16:49 UTC

Does something happen other than what html is output?

Hello,

I am adding a MarkupContainer to my page that outputs something like
this:

 <img wicket:id="logoImage" src="file:///resources/images/logo.jpg">

or this:

<link rel="stylesheet" type="text/css"
href="file:///resources/stylesheets/text.css" /
>

[Just in case this does not render because of html-based mail clients:

 &lt;img wicket:id="logoImage"
src="file:///resources/images/logo.jpg"&gt;

or this:

&lt;link rel="stylesheet" type="text/css"
href="file:///resources/stylesheets/text.css" /&gt;

]

Although this works from a static html page, it doesn't work when Wicket
renders this page. The html shows up correctly when I view the source,
but the image and CSS don't get rendered.

Is something happening behind the scenes that I should be aware of?


Thanks!
Dave




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


RE: Does something happen other than what html is output?

Posted by David Leangen <wi...@leangen.net>.
> The url is a file:/// type url that points to a file on the local
> filesystem.
> 
> > in the first case it could be the browser preventing a site from
> > accessing your local file system, which might be allowed if it
> > sees it is a local html file.
> 
> Ah... maybe you're right!

Yep, you're exactly right!

file:// urls won't work when embedded in a remote html file, since the
browser must consider this a security threat.

Thanks for helping me find this. The thought never crossed my mind at
all.


Cheers,
Dave




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


RE: Does something happen other than what html is output?

Posted by David Leangen <wi...@leangen.net>.
> is the /resources/.... path local to the user or to the server?

The url is a file:/// type url that points to a file on the local
filesystem.

> in the first case it could be the browser preventing a site from
> accessing your local file system, which might be allowed if it
> sees it is a local html file.

Ah... maybe you're right!

That could explain why it works with a local file (which could allow the
browser to assume that it is granted permissions to use files on the local
filesystem) but not from a file served remotely. Hmmmm... interesting idea.

When I get back into the office tomorrow (I'm in Asia time), I'll try
serving up a static file remotely to test this theory.

If this is a permission problem, I wonder if there is a way around it...


> Maybe i missed an earlier post about this but why do you use file://.... ?

Because my designer wants to be able to play around with the CSS without
having to mount an entire development version of Wicket. It is especially
tricky for us, since we are using it with OSGi, and the development setup is
not trivial for a non-programmer.

So, he can just do something like:

  http://www.blah.com/top/index.html?css=file:///path/to/css

And wicket will use this.

This system works perfectly well for a http:// url. I'm trying to simply
things for the designer by making it work with file:/// urls.


Thank you all for your ideas!


Cheers,
Dave



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


Re: Does something happen other than what html is output?

Posted by Maurice Marrink <ma...@gmail.com>.
is the /resources/.... path local to the user or to the server?
in the first case it could be the browser preventing a site from
accessing your local file system, which might be allowed if it sees it
is a local html file.
in the second case the server might prevent the browser from getting
that resource.

Maybe i missed an earlier post about this but why do you use file://.... ?

Maurice

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


RE: Does something happen other than what html is output?

Posted by David Leangen <wi...@leangen.net>.
> >  > If oncomponenttag is used it should work.
> >
> >  Really? I don't see why I'd need onComponentTag for the approach I'm
> >  using...
> >
> I misunderstood, i though that sometimes the container was to render
> as an image tag and sometimes as a link tag, hence the oncomponenttag
> method :)

Oh, ok. I must not have explained well. Sorry.

Thank you very much for chiming in. :-)


Cheers,
Dave



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


Re: Does something happen other than what html is output?

Posted by Maurice Marrink <ma...@gmail.com>.
>
>  > If oncomponenttag is used it should work.
>
>  Really? I don't see why I'd need onComponentTag for the approach I'm
>  using...
>
I misunderstood, i though that sometimes the container was to render
as an image tag and sometimes as a link tag, hence the oncomponenttag
method :)

Maurice

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


RE: Does something happen other than what html is output?

Posted by David Leangen <wi...@leangen.net>.
Hello.

> >                         public void renderHead( final IHeaderResponse
> >  response )
> >                         {
> >                             response.renderString( cssLink );
> >                         }
>
> Shouldn't this read
>
> response.renderCssReference( cssLink ),
>
> instead of
>
> response.renderString( cssLink );
>
>  If I read the javadoc properly, #renderString( cssLink ), will just
> print the cssLink verbatim.

Yes, that's the whole point.

In my initial post, I mentioned that I wanted to render a file:// link.
IHeaderResponse.rednerCssReference( String ) only works for http:// and
https://.

The only way I could see to do this was to copy the way HeaderResponse
renders http and emulate this with file://.


The problem I'm encountering is that although the html is correct when I
view the source, my browser for some reason does not render the image or
css. If I copy the source and paste into a static html file, it works.


Cheers,
Dave



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


Re: Does something happen other than what html is output?

Posted by Edward Yakop <ed...@gmail.com>.
On Thu, Feb 28, 2008 at 5:33 PM, David Leangen <wi...@leangen.net> wrote:
>                         public void renderHead( final IHeaderResponse
>  response )
>                         {
>                             response.renderString( cssLink );
>                         }

Shouldn't this read

response.renderCssReference( cssLink ),

instead of

response.renderString( cssLink );

 If I read the javadoc properly, #renderString( cssLink ), will just
print the cssLink verbatim.

>  And this for the image:
>
>         final MarkupContainer container = new WebMarkupContainer( id );
>         final Model srcAttributeModel = new Model( imageUrl );
>         final AttributeModifier srcAttribute = new AttributeModifier(
>             "src",
>             true,
>             srcAttributeModel );
>         container.add( srcAttribute );
>         add( container );
>
>  I think the html looks something like this:
>   <img wicket:id="blah">IMAGE</img>

I wonder why this doesn't work. To me, this should work, is it because
of the IMAGE string?

Regards,
Edward Yakop

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


RE: Does something happen other than what html is output?

Posted by David Leangen <wi...@leangen.net>.
Thank you for your reply.

> Depends how the container produces the output.

Well, like I say below, I'm just using a MarkupContainer to output pure html
for images, and a HeaderContributor for the CSS, nothing more.

This is the code for the CSS:

    private void addCss( final Page page, final String cssLink )
    {
        final HeaderContributor cssHeaderContributor =
            new HeaderContributor
            (
                    new IHeaderContributor()
                    {
                        private static final long serialVersionUID = 1L;

                        public void renderHead( final IHeaderResponse
response )
                        {
                            response.renderString( cssLink );
                        }
                    }
            );

        page.add( cssHeaderContributor );
    }

And this for the image:

        final MarkupContainer container = new WebMarkupContainer( id );
        final Model srcAttributeModel = new Model( imageUrl );
        final AttributeModifier srcAttribute = new AttributeModifier(
            "src",
            true,
            srcAttributeModel );
        container.add( srcAttribute );
        add( container );

I think the html looks something like this:
  <img wicket:id="blah">IMAGE</img>


> If oncomponenttag is used it should work.

Really? I don't see why I'd need onComponentTag for the approach I'm
using...


> if the tags are generated by a model you might want turn off
> setescapemodelstrings on the container.

The html is rendered just fine. If I copy the code and paste it in a static
html file, everything renders just fine.


Thanks!
Dave



> On Thu, Feb 28, 2008 at 4:16 AM, David Leangen <wi...@leangen.net> wrote:
> >
> >  Hello,
> >
> >  I am adding a MarkupContainer to my page that outputs something like
> >  this:
> >
> >   <img wicket:id="logoImage" src="file:///resources/images/logo.jpg">
> >
> >  or this:
> >
> >  <link rel="stylesheet" type="text/css"
> >  href="file:///resources/stylesheets/text.css" /
> >  >
> >
> >  [Just in case this does not render because of html-based mail clients:
> >
> >   &lt;img wicket:id="logoImage"
> >  src="file:///resources/images/logo.jpg"&gt;
> >
> >  or this:
> >
> >  &lt;link rel="stylesheet" type="text/css"
> >  href="file:///resources/stylesheets/text.css" /&gt;
> >
> >  ]
> >
> >  Although this works from a static html page, it doesn't work
> when Wicket
> >  renders this page. The html shows up correctly when I view the source,
> >  but the image and CSS don't get rendered.
> >
> >  Is something happening behind the scenes that I should be aware of?
> >
> >
> >  Thanks!
> >  Dave
> >
> >
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>


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


Re: Does something happen other than what html is output?

Posted by Maurice Marrink <ma...@gmail.com>.
Depends how the container produces the output.

If oncomponenttag is used it should work.

if the tags are generated by a model you might want turn off
setescapemodelstrings on the container.

but without seeing your code it is hard to predict what could go wrong.

Maurice

On Thu, Feb 28, 2008 at 4:16 AM, David Leangen <wi...@leangen.net> wrote:
>
>  Hello,
>
>  I am adding a MarkupContainer to my page that outputs something like
>  this:
>
>   <img wicket:id="logoImage" src="file:///resources/images/logo.jpg">
>
>  or this:
>
>  <link rel="stylesheet" type="text/css"
>  href="file:///resources/stylesheets/text.css" /
>  >
>
>  [Just in case this does not render because of html-based mail clients:
>
>   &lt;img wicket:id="logoImage"
>  src="file:///resources/images/logo.jpg"&gt;
>
>  or this:
>
>  &lt;link rel="stylesheet" type="text/css"
>  href="file:///resources/stylesheets/text.css" /&gt;
>
>  ]
>
>  Although this works from a static html page, it doesn't work when Wicket
>  renders this page. The html shows up correctly when I view the source,
>  but the image and CSS don't get rendered.
>
>  Is something happening behind the scenes that I should be aware of?
>
>
>  Thanks!
>  Dave
>
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

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