You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Per Newgro <pe...@gmx.ch> on 2015/02/06 15:21:08 UTC

Can i render content (css) of ContextRelativeResource to markup?

Hi,

I like to render a PDF by my wicket page using flying-saucer. There i reference my css file by url (link). So far everything works.
But if i switch to SSL flying-saucer breaks. Hmm.

My solution to this issue would be to include content of my css file directly in the wicket-page used to render the pdf.

I tried to get the resource and render it in markup like this

<code>
MyPage.java
	
@Override
public void renderHead(IHeaderResponse response) {
  IResource s = new SharedResourceReference("report.css").getResource();
  Attributes a = new Attributes(getRequest(), getResponse());
  s.respond(a);
  super.renderHead(response);
}
</code>

but i get
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.UnsupportedOperationException
	at org.apache.wicket.response.StringResponse.write(StringResponse.java:88)
	at org.apache.wicket.request.Response$StreamAdapter.write(Response.java:148)
	at org.apache.wicket.util.io.Streams.copy(Streams.java:109)
	at org.apache.wicket.util.io.Streams.copy(Streams.java:76)
	at org.apache.wicket.request.resource.ContextRelativeResource$1.writeData(ContextRelativeResource.java:110)
	at org.apache.wicket.request.resource.AbstractResource.respond(AbstractResource.java:528)
	at de.MyPage.renderHead(MyPage.java:88)
	at org.apache.wicket.Component.renderHead(Component.java:4419)
	at org.apache.wicket.Component.renderHead(Component.java:2679)
	at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderRootComponent(AbstractHeaderRenderStrategy.java:127)
	at org.apache.wicket.markup.renderStrategy.ChildFirstHeaderRenderStrategy.renderHeader(ChildFirstHeaderRenderStrategy.java:60)
	at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:170)
	at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:71)
	at org.apache.wicket.Component.internalRenderComponent(Component.java:2529)
	... 51 more

It seems that my ContextRelativeResource only provides content as byte[] ans StringResponse not supporting this.
Maybe i be off the track.

Thanks for your support
Per

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


Re: wicketstuff gae-initializer-parent

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi Heiner,

the Server needs to support Servlet 3.0 Spec. It seems that you are using one which does not support that.

kind regards

Tobias

> Am 09.02.2015 um 07:46 schrieb Wicket und Cocoon <ha...@yahoo.de>:
> 
> Hello Martin,
> i tried  your gae-initializer-example but get the following  error
> wnhem i try gae:run and ask localhost:8080:
> 
> java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z
> 
> i use appengine-java-sdk-1.9.7
> and your example under jdk 1.7
> 
> when i read the few google information about wicket and appengine i am not sure
> if it is a good idea to transfer wicket to appengine.
> 
> Regards
> Heiner
> 
> 

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


Re: wicketstuff gae-initializer-parent

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

The error says that the container needs servlet-api:jar:3.0 while the
application comes with older version of the jar.
I don't use GAE myself so I have cannot give you more info.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Feb 9, 2015 at 9:18 AM, Tobias Soloschenko <
tobiassoloschenko@googlemail.com> wrote:

> Hi again,
>
> I found a topic in which the implementation of Servlet 3.0 for Google
> AppEngine is requested by several users
>
>
> https://code.google.com/p/googleappengine/issues/detail?id=3091
>
> kind regards
>
> Tobias
>
> > Am 09.02.2015 um 07:46 schrieb Wicket und Cocoon <
> hansheinrichbraun@yahoo.de>:
> >
> > Hello Martin,
> > i tried  your gae-initializer-example but get the following  error
> > wnhem i try gae:run and ask localhost:8080:
> >
> > java.lang.NoSuchMethodError:
> javax.servlet.http.HttpServletRequest.isAsyncStarted()Z
> >
> > i use appengine-java-sdk-1.9.7
> > and your example under jdk 1.7
> >
> > when i read the few google information about wicket and appengine i am
> not sure
> > if it is a good idea to transfer wicket to appengine.
> >
> > Regards
> > Heiner
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: wicketstuff gae-initializer-parent

Posted by Andrea Del Bene <an...@gmail.com>.
hi,  appengine has a quite confusing versioning policy. The last version
supporting java 6 (hence not requiring servlet 3) is 1.8.1 so if you use
this version or an earlier one you should be ok. Unfortunately l also don't
use appengine as deployment environment so l can't help you more in detail.
On 9 Feb 2015 09:09, "Martin Grigorov" <mg...@apache.org> wrote:

> Any hosting/cloud provider with Java:
> - Amazon WS
> - OpenShift
> - Cloudbees
> - Rackspace
> - ...
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Mon, Feb 9, 2015 at 9:59 AM, Wicket und Cocoon <
> hansheinrichbraun@yahoo.de> wrote:
>
> > what is a good place to upload a wicket application.
> >
> >
> > Am 09.02.2015 um 08:18 schrieb Tobias Soloschenko:
> >
> >  Hi again,
> >>
> >> I found a topic in which the implementation of Servlet 3.0 for Google
> >> AppEngine is requested by several users
> >>
> >>
> >> https://code.google.com/p/googleappengine/issues/detail?id=3091
> >>
> >> kind regards
> >>
> >> Tobias
> >>
> >>  Am 09.02.2015 um 07:46 schrieb Wicket und Cocoon <
> >>> hansheinrichbraun@yahoo.de>:
> >>>
> >>> Hello Martin,
> >>> i tried  your gae-initializer-example but get the following  error
> >>> wnhem i try gae:run and ask localhost:8080:
> >>>
> >>> java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.
> >>> isAsyncStarted()Z
> >>>
> >>> i use appengine-java-sdk-1.9.7
> >>> and your example under jdk 1.7
> >>>
> >>> when i read the few google information about wicket and appengine i am
> >>> not sure
> >>> if it is a good idea to transfer wicket to appengine.
> >>>
> >>> Regards
> >>> Heiner
> >>>
> >>>
> >>>  ---------------------------------------------------------------------
> >> 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: wicketstuff gae-initializer-parent

Posted by Martin Grigorov <mg...@apache.org>.
Any hosting/cloud provider with Java:
- Amazon WS
- OpenShift
- Cloudbees
- Rackspace
- ...

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Feb 9, 2015 at 9:59 AM, Wicket und Cocoon <
hansheinrichbraun@yahoo.de> wrote:

> what is a good place to upload a wicket application.
>
>
> Am 09.02.2015 um 08:18 schrieb Tobias Soloschenko:
>
>  Hi again,
>>
>> I found a topic in which the implementation of Servlet 3.0 for Google
>> AppEngine is requested by several users
>>
>>
>> https://code.google.com/p/googleappengine/issues/detail?id=3091
>>
>> kind regards
>>
>> Tobias
>>
>>  Am 09.02.2015 um 07:46 schrieb Wicket und Cocoon <
>>> hansheinrichbraun@yahoo.de>:
>>>
>>> Hello Martin,
>>> i tried  your gae-initializer-example but get the following  error
>>> wnhem i try gae:run and ask localhost:8080:
>>>
>>> java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.
>>> isAsyncStarted()Z
>>>
>>> i use appengine-java-sdk-1.9.7
>>> and your example under jdk 1.7
>>>
>>> when i read the few google information about wicket and appengine i am
>>> not sure
>>> if it is a good idea to transfer wicket to appengine.
>>>
>>> Regards
>>> Heiner
>>>
>>>
>>>  ---------------------------------------------------------------------
>> 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: wicketstuff gae-initializer-parent

Posted by Wicket und Cocoon <ha...@yahoo.de>.
what is a good place to upload a wicket application.


Am 09.02.2015 um 08:18 schrieb Tobias Soloschenko:
> Hi again,
>
> I found a topic in which the implementation of Servlet 3.0 for Google AppEngine is requested by several users
>
>
> https://code.google.com/p/googleappengine/issues/detail?id=3091
>
> kind regards
>
> Tobias
>
>> Am 09.02.2015 um 07:46 schrieb Wicket und Cocoon <ha...@yahoo.de>:
>>
>> Hello Martin,
>> i tried  your gae-initializer-example but get the following  error
>> wnhem i try gae:run and ask localhost:8080:
>>
>> java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z
>>
>> i use appengine-java-sdk-1.9.7
>> and your example under jdk 1.7
>>
>> when i read the few google information about wicket and appengine i am not sure
>> if it is a good idea to transfer wicket to appengine.
>>
>> Regards
>> Heiner
>>
>>
> ---------------------------------------------------------------------
> 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: wicketstuff gae-initializer-parent

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi again,

I found a topic in which the implementation of Servlet 3.0 for Google AppEngine is requested by several users


https://code.google.com/p/googleappengine/issues/detail?id=3091

kind regards

Tobias

> Am 09.02.2015 um 07:46 schrieb Wicket und Cocoon <ha...@yahoo.de>:
> 
> Hello Martin,
> i tried  your gae-initializer-example but get the following  error
> wnhem i try gae:run and ask localhost:8080:
> 
> java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z
> 
> i use appengine-java-sdk-1.9.7
> and your example under jdk 1.7
> 
> when i read the few google information about wicket and appengine i am not sure
> if it is a good idea to transfer wicket to appengine.
> 
> Regards
> Heiner
> 
> 

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


wicketstuff gae-initializer-parent

Posted by Wicket und Cocoon <ha...@yahoo.de>.
Hello Martin,
i tried  your gae-initializer-example but get the following  error
wnhem i try gae:run and ask localhost:8080:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z

i use appengine-java-sdk-1.9.7
and your example under jdk 1.7

when i read the few google information about wicket and appengine i am not sure
if it is a good idea to transfer wicket to appengine.

Regards
Heiner



Re: Can i render content (css) of ContextRelativeResource to markup?

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

You should use response.render(CssHeaderItem.forCSS(string)). This will
contribute it in <style> HTML element. With your approach it will be plain
text in the middle of the HTML.
To get the "string" you can use new
WebExternalResourceStream("report.css").getInputStream(),
read, convert to String, close.


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Feb 6, 2015 at 4:21 PM, Per Newgro <pe...@gmx.ch> wrote:

> Hi,
>
> I like to render a PDF by my wicket page using flying-saucer. There i
> reference my css file by url (link). So far everything works.
> But if i switch to SSL flying-saucer breaks. Hmm.
>
> My solution to this issue would be to include content of my css file
> directly in the wicket-page used to render the pdf.
>
> I tried to get the resource and render it in markup like this
>
> <code>
> MyPage.java
>
> @Override
> public void renderHead(IHeaderResponse response) {
>   IResource s = new SharedResourceReference("report.css").getResource();
>   Attributes a = new Attributes(getRequest(), getResponse());
>   s.respond(a);
>   super.renderHead(response);
> }
> </code>
>
> but i get
>         at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>         at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>         at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.UnsupportedOperationException
>         at
> org.apache.wicket.response.StringResponse.write(StringResponse.java:88)
>         at
> org.apache.wicket.request.Response$StreamAdapter.write(Response.java:148)
>         at org.apache.wicket.util.io.Streams.copy(Streams.java:109)
>         at org.apache.wicket.util.io.Streams.copy(Streams.java:76)
>         at
> org.apache.wicket.request.resource.ContextRelativeResource$1.writeData(ContextRelativeResource.java:110)
>         at
> org.apache.wicket.request.resource.AbstractResource.respond(AbstractResource.java:528)
>         at de.MyPage.renderHead(MyPage.java:88)
>         at org.apache.wicket.Component.renderHead(Component.java:4419)
>         at org.apache.wicket.Component.renderHead(Component.java:2679)
>         at
> org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderRootComponent(AbstractHeaderRenderStrategy.java:127)
>         at
> org.apache.wicket.markup.renderStrategy.ChildFirstHeaderRenderStrategy.renderHeader(ChildFirstHeaderRenderStrategy.java:60)
>         at
> org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:170)
>         at
> org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:71)
>         at
> org.apache.wicket.Component.internalRenderComponent(Component.java:2529)
>         ... 51 more
>
> It seems that my ContextRelativeResource only provides content as byte[]
> ans StringResponse not supporting this.
> Maybe i be off the track.
>
> Thanks for your support
> Per
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>