You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nino martinez wael <ni...@gmail.com> on 2010/10/07 15:35:52 UTC

wicket 1.5, css resourcereference from string?

Hi

I cant get below working:

public void renderHead(IHeaderResponse response) {
super.renderHead(response);
if (wallboardConfigurationModel.getObject().hasCustomCss()) {
final StringResourceStream stringResourceStream = new StringResourceStream(
wallboardConfigurationModel.getObject().getCustomCss(),
"text/css");

ResourceReference resourceReference = new ResourceReference(
wallboardConfigurationModel.getObject().getId()) {
@Override
public IResource getResource() {
return new ResourceStreamResource(stringResourceStream);
}
};
response.renderCSSReference(resourceReference);

}
}

I get this out put in the log:

010-10-07 15:33:57,555 WARN
 [org.apache.wicket.request.resource.ResourceReferenceRegistry]  - Asked to
auto-create a ResourceReference, but
ResourceReferenceRegistry.createDefaultResourceReference() return null.
 [scope: org.apache.wicket.Application; name: test1; locale: null; style:
null; variation: null]
2010-10-07 15:33:57,555 ERROR [org.apache.wicket.request.cycle.RequestCycle]
 - Unable to execute request. No suitable RequestHandler found.
URL=wicket/resource/org.apache.wicket.Application/test1

Re: wicket 1.5, css resourcereference from string?

Posted by m j <ms...@gmail.com>.
I actually just made a youtube video how to add css/js to a page.
See it here: http://www.youtube.com/watch?v=9toRTCFJf3Y

Though I did not cover textemplateresourcereference. It is just as Igor
described but now you can see the complete code if necessary.

On Fri, Oct 8, 2010 at 12:50 PM, nino martinez wael <
nino.martinez.wael@gmail.com> wrote:

> hmm right, could I just embed it in the html page then, I guess the answer
> is yes?
>
> I guess the reason I took this path was because of the
> texttemplateresourcereference which seems to do something much like this.
>
> regards Nino
>
> 2010/10/8 Igor Vaynberg <ig...@gmail.com>
>
> > what you are trying to do doesnt make sense, think about it.
> >
> > how is wicket supposed to build a url to your anonymous reference
> instance?
> >
> > you have two options, use renderCssReference(String url) to output the
> > url to your custom css or if you need to stream it from somewhere
> > inaccessible by the browser you can create a shared resource or a
> > servlet
> >
> > -igor
> >
> > On Fri, Oct 8, 2010 at 2:44 AM, nino martinez wael
> > <ni...@gmail.com> wrote:
> > > Has someone an idea?
> > >
> > > I am just trying to read a custom css from a string and render it as a
> > > reference on the page.
> > >
> > > Do I need to register the reference somewhere or sormething?
> > >
> > > 2010/10/7 nino martinez wael <ni...@gmail.com>
> > >
> > >> Hi
> > >>
> > >> I cant get below working:
> > >>
> > >> public void renderHead(IHeaderResponse response) {
> > >>  super.renderHead(response);
> > >> if (wallboardConfigurationModel.getObject().hasCustomCss()) {
> > >>  final StringResourceStream stringResourceStream = new
> > >> StringResourceStream(
> > >> wallboardConfigurationModel.getObject().getCustomCss(),
> > >>  "text/css");
> > >>
> > >> ResourceReference resourceReference = new ResourceReference(
> > >>  wallboardConfigurationModel.getObject().getId()) {
> > >> @Override
> > >> public IResource getResource() {
> > >>  return new ResourceStreamResource(stringResourceStream);
> > >> }
> > >> };
> > >>  response.renderCSSReference(resourceReference);
> > >>
> > >> }
> > >> }
> > >>
> > >> I get this out put in the log:
> > >>
> > >> 010-10-07 15:33:57,555 WARN
> > >>  [org.apache.wicket.request.resource.ResourceReferenceRegistry]  -
> Asked
> > to
> > >> auto-create a ResourceReference, but
> > >> ResourceReferenceRegistry.createDefaultResourceReference() return
> null.
> > >>  [scope: org.apache.wicket.Application; name: test1; locale: null;
> > style:
> > >> null; variation: null]
> > >> 2010-10-07 15:33:57,555 ERROR
> > >> [org.apache.wicket.request.cycle.RequestCycle]  - Unable to execute
> > request.
> > >> No suitable RequestHandler found.
> > >> URL=wicket/resource/org.apache.wicket.Application/test1
> > >>
> > >>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: wicket 1.5, css resourcereference from string?

Posted by nino martinez wael <ni...@gmail.com>.
hmm right, could I just embed it in the html page then, I guess the answer
is yes?

I guess the reason I took this path was because of the
texttemplateresourcereference which seems to do something much like this.

regards Nino

2010/10/8 Igor Vaynberg <ig...@gmail.com>

> what you are trying to do doesnt make sense, think about it.
>
> how is wicket supposed to build a url to your anonymous reference instance?
>
> you have two options, use renderCssReference(String url) to output the
> url to your custom css or if you need to stream it from somewhere
> inaccessible by the browser you can create a shared resource or a
> servlet
>
> -igor
>
> On Fri, Oct 8, 2010 at 2:44 AM, nino martinez wael
> <ni...@gmail.com> wrote:
> > Has someone an idea?
> >
> > I am just trying to read a custom css from a string and render it as a
> > reference on the page.
> >
> > Do I need to register the reference somewhere or sormething?
> >
> > 2010/10/7 nino martinez wael <ni...@gmail.com>
> >
> >> Hi
> >>
> >> I cant get below working:
> >>
> >> public void renderHead(IHeaderResponse response) {
> >>  super.renderHead(response);
> >> if (wallboardConfigurationModel.getObject().hasCustomCss()) {
> >>  final StringResourceStream stringResourceStream = new
> >> StringResourceStream(
> >> wallboardConfigurationModel.getObject().getCustomCss(),
> >>  "text/css");
> >>
> >> ResourceReference resourceReference = new ResourceReference(
> >>  wallboardConfigurationModel.getObject().getId()) {
> >> @Override
> >> public IResource getResource() {
> >>  return new ResourceStreamResource(stringResourceStream);
> >> }
> >> };
> >>  response.renderCSSReference(resourceReference);
> >>
> >> }
> >> }
> >>
> >> I get this out put in the log:
> >>
> >> 010-10-07 15:33:57,555 WARN
> >>  [org.apache.wicket.request.resource.ResourceReferenceRegistry]  - Asked
> to
> >> auto-create a ResourceReference, but
> >> ResourceReferenceRegistry.createDefaultResourceReference() return null.
> >>  [scope: org.apache.wicket.Application; name: test1; locale: null;
> style:
> >> null; variation: null]
> >> 2010-10-07 15:33:57,555 ERROR
> >> [org.apache.wicket.request.cycle.RequestCycle]  - Unable to execute
> request.
> >> No suitable RequestHandler found.
> >> URL=wicket/resource/org.apache.wicket.Application/test1
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: wicket 1.5, css resourcereference from string?

Posted by Igor Vaynberg <ig...@gmail.com>.
what you are trying to do doesnt make sense, think about it.

how is wicket supposed to build a url to your anonymous reference instance?

you have two options, use renderCssReference(String url) to output the
url to your custom css or if you need to stream it from somewhere
inaccessible by the browser you can create a shared resource or a
servlet

-igor

On Fri, Oct 8, 2010 at 2:44 AM, nino martinez wael
<ni...@gmail.com> wrote:
> Has someone an idea?
>
> I am just trying to read a custom css from a string and render it as a
> reference on the page.
>
> Do I need to register the reference somewhere or sormething?
>
> 2010/10/7 nino martinez wael <ni...@gmail.com>
>
>> Hi
>>
>> I cant get below working:
>>
>> public void renderHead(IHeaderResponse response) {
>>  super.renderHead(response);
>> if (wallboardConfigurationModel.getObject().hasCustomCss()) {
>>  final StringResourceStream stringResourceStream = new
>> StringResourceStream(
>> wallboardConfigurationModel.getObject().getCustomCss(),
>>  "text/css");
>>
>> ResourceReference resourceReference = new ResourceReference(
>>  wallboardConfigurationModel.getObject().getId()) {
>> @Override
>> public IResource getResource() {
>>  return new ResourceStreamResource(stringResourceStream);
>> }
>> };
>>  response.renderCSSReference(resourceReference);
>>
>> }
>> }
>>
>> I get this out put in the log:
>>
>> 010-10-07 15:33:57,555 WARN
>>  [org.apache.wicket.request.resource.ResourceReferenceRegistry]  - Asked to
>> auto-create a ResourceReference, but
>> ResourceReferenceRegistry.createDefaultResourceReference() return null.
>>  [scope: org.apache.wicket.Application; name: test1; locale: null; style:
>> null; variation: null]
>> 2010-10-07 15:33:57,555 ERROR
>> [org.apache.wicket.request.cycle.RequestCycle]  - Unable to execute request.
>> No suitable RequestHandler found.
>> URL=wicket/resource/org.apache.wicket.Application/test1
>>
>>
>

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


Re: wicket 1.5, css resourcereference from string?

Posted by nino martinez wael <ni...@gmail.com>.
Has someone an idea?

I am just trying to read a custom css from a string and render it as a
reference on the page.

Do I need to register the reference somewhere or sormething?

2010/10/7 nino martinez wael <ni...@gmail.com>

> Hi
>
> I cant get below working:
>
> public void renderHead(IHeaderResponse response) {
>  super.renderHead(response);
> if (wallboardConfigurationModel.getObject().hasCustomCss()) {
>  final StringResourceStream stringResourceStream = new
> StringResourceStream(
> wallboardConfigurationModel.getObject().getCustomCss(),
>  "text/css");
>
> ResourceReference resourceReference = new ResourceReference(
>  wallboardConfigurationModel.getObject().getId()) {
> @Override
> public IResource getResource() {
>  return new ResourceStreamResource(stringResourceStream);
> }
> };
>  response.renderCSSReference(resourceReference);
>
> }
> }
>
> I get this out put in the log:
>
> 010-10-07 15:33:57,555 WARN
>  [org.apache.wicket.request.resource.ResourceReferenceRegistry]  - Asked to
> auto-create a ResourceReference, but
> ResourceReferenceRegistry.createDefaultResourceReference() return null.
>  [scope: org.apache.wicket.Application; name: test1; locale: null; style:
> null; variation: null]
> 2010-10-07 15:33:57,555 ERROR
> [org.apache.wicket.request.cycle.RequestCycle]  - Unable to execute request.
> No suitable RequestHandler found.
> URL=wicket/resource/org.apache.wicket.Application/test1
>
>