Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-08-05 Thread Loren Cole
Ah, sweet.  Thanks for digging that up Jeremy.

Alec, since we were pressed for time, I piggybacked off your code to get
something working

@Override
protected void init() {
super.init();
/*
 * Adds custom skin at the end of the header
 */
setHeaderResponseDecorator(new IHeaderResponseDecorator() {
public IHeaderResponse decorate(IHeaderResponse response) {
return new DecoratingHeaderResponse(response) {
@Override
public void close() {
String css = null;
if(MyWebSession.get() != null) css =
MyWebSession.get().getCssStyle();

if(css != null  !wasRendered(css)) {
renderString(style + css + /style);
}
super.close();
}
};
}
});
}

I chose not to override renderString(), because I didn't want to break
anything that might use it.  Also, we don't know what css we want to add
when the application gets initialized; we have to wait till the user has
authenticated.  So, I stuck our css in the session after authentication and
had the decorator pull it from there.

When we get a chance I will swap this out for the bucket method for it's
added flexibility, but this does work for now.

Thanks again guys,
Loren


On Wed, Aug 3, 2011 at 9:58 PM, Jeremy Thomerson
jer...@wickettraining.comwrote:

 That thread is here: http://tinyurl.com/3fnery2

 In it there's a link to a tar of a project that's still hosted on my site.

 --
 Jeremy Thomerson
 http://wickettraining.com
 *Need a CMS for Wicket?  Use Brix! http://brixcms.org*

 On Wed, Aug 3, 2011 at 1:21 PM, Martin Grigorov mgrigo...@apache.org
 wrote:

  Hi Loren,
 
  See whether you can find the mail mentioned in
  https://cwiki.apache.org/confluence/display/WICKET/Resource+decoration
  in the mail archives.
  Jeremy attached the raw application in this mail thread and I
  transformed it to proper wicket-example for 1.5
 
  On Wed, Aug 3, 2011 at 6:36 PM, Loren Cole loren.c...@gmail.com wrote:
   Hey guys, thanks for your responses. We're still using 1.4, it looks
 like
  it
   will be a few months till we get to upgrade and use all the
 improvements
   that have been made to resource handling in 1.5.  In 1.4 it appears
 that
  you
   cannot put a bucket in the header without things getting confused and
   failing to close.  Does anyone know why this is the case, or if there
 is
  a
   way around it while still getting things in a head tag?
  
   Martin, since we're using an older version I'm having trouble taking
   advantage of your excellent advise, but I see elsewhere on the list,
 you
   mention that this aggregation example should work in 1.4 also.  Do you
   perhaps have an example of that I could look at?  The 1.4 equivalent of
   MergedResourcesResource in particular is eluding me.
  
   Am I right in thinking that aggregation will be required to order my
 css
   contributions in 1.4?  At this point in development, the performance
  boost
   doesn't necessarily offset the extra trouble of tracking down what
   stylesheet or js library a problem is in, so I'd rather avoid it if
   possible.
  
  
   Thanks, Loren
  
 
 
 
  --
  Martin Grigorov
  jWeekend
  Training, Consulting, Development
  http://jWeekend.com
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 



Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-08-03 Thread Loren Cole
Hey guys, thanks for your responses. We're still using 1.4, it looks like it
will be a few months till we get to upgrade and use all the improvements
that have been made to resource handling in 1.5.  In 1.4 it appears that you
cannot put a bucket in the header without things getting confused and
failing to close.  Does anyone know why this is the case, or if there is a
way around it while still getting things in a head tag?

Martin, since we're using an older version I'm having trouble taking
advantage of your excellent advise, but I see elsewhere on the list, you
mention that this aggregation example should work in 1.4 also.  Do you
perhaps have an example of that I could look at?  The 1.4 equivalent of
MergedResourcesResource in particular is eluding me.

Am I right in thinking that aggregation will be required to order my css
contributions in 1.4?  At this point in development, the performance boost
doesn't necessarily offset the extra trouble of tracking down what
stylesheet or js library a problem is in, so I'd rather avoid it if
possible.


Thanks, Loren


Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-08-03 Thread Martin Grigorov
Hi Loren,

See whether you can find the mail mentioned in
https://cwiki.apache.org/confluence/display/WICKET/Resource+decoration
in the mail archives.
Jeremy attached the raw application in this mail thread and I
transformed it to proper wicket-example for 1.5

On Wed, Aug 3, 2011 at 6:36 PM, Loren Cole loren.c...@gmail.com wrote:
 Hey guys, thanks for your responses. We're still using 1.4, it looks like it
 will be a few months till we get to upgrade and use all the improvements
 that have been made to resource handling in 1.5.  In 1.4 it appears that you
 cannot put a bucket in the header without things getting confused and
 failing to close.  Does anyone know why this is the case, or if there is a
 way around it while still getting things in a head tag?

 Martin, since we're using an older version I'm having trouble taking
 advantage of your excellent advise, but I see elsewhere on the list, you
 mention that this aggregation example should work in 1.4 also.  Do you
 perhaps have an example of that I could look at?  The 1.4 equivalent of
 MergedResourcesResource in particular is eluding me.

 Am I right in thinking that aggregation will be required to order my css
 contributions in 1.4?  At this point in development, the performance boost
 doesn't necessarily offset the extra trouble of tracking down what
 stylesheet or js library a problem is in, so I'd rather avoid it if
 possible.


 Thanks, Loren




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

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



Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-07-22 Thread Martin Grigorov
Hi,

It is not documented by wicket:head contributes before
#renderHead(). This may change in the future so don't rely on it.
Better take a look at
http://wicketstuff.org/wicket/resourceaggregation application. There
you can see how resources are scored. This way you can setup
org.apache.wicket.resource.filtering.HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter
which renders your specific contribution after all other.
To render CSS text use
org.apache.wicket.markup.html.IHeaderResponse.renderCSS(CharSequence
css, String id). Use the id in the filter to recognize it.

On Fri, Jul 22, 2011 at 1:00 AM, Loren Cole loren.c...@gmail.com wrote:
 Under normal circumstances I would, but I don't have my css in a file.  It
 gets pulled from a database and stashed in the session.  All the header
 contributer classes and resource references assume there's a file somewhere
 with this info.  But in my case there is not.

 And, even id I did stuff this data into a file it still wouldn't fix my
 problem, because the customer defined css needs to override everything else
 with the same css selector. If another component added a header contributor
 afterwards that would not be the case.

 -
 Loren

 On Tue, Jul 19, 2011 at 11:35 PM, Jeremy Thomerson 
 jer...@wickettraining.com wrote:

 To start, don't use a Label to contribute css.  Use a header contributor.
 That's what they're made for.
 On 2011 7 19 13:22, Loren Cole loren.c...@gmail.com wrote:
  We're making our application skinable, but I'm having some trouble
 getting
  user specified css into the right place in the header. We're working in a
  distributed environment, so instead of saving their css in the file
 system
  we're putting it in our database, and in order to get the cascade to work
  properly we need to add this css after all the others. Here's how I'm
  adding it:
 
  StandardPage.java
 
  onInitialize()
  //Add any override style
  Tenant tenant = MyWebSession.get().getTenant();
  Css css = cssRepository.GetStyleByTenant(tenant);
  if(tenant.getBranding()  css != null) {
  add(new Label(style, css.getStyle()));
  }
  }
 
  StandardPage.html
 
  wicket:head
  style type=text/css wicket:id=style/style
  /wicket:head
 
  -
  So the issue is that thet style tag comes before all my header
  contributions. I've tried specifying a header response decorator like so:
 
  Application.java
 
  public static final String HEADER_FILTER_NAME = myHeaderBucket;
 
  init() {
  super.init();
  setHeaderResponseDecorator(new IHeaderResponseDecorator() {
 
  HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[]
  filters = {new CssAcceptingHeaderResponseFilter(HEADER_FILTER_NAME)};
  @Override
  public IHeaderResponse decorate(IHeaderResponse response) {
  return new
  HeaderResponseContainerFilteringHeaderResponse(response,
 HEADER_FILTER_NAME,
  filters);
  }
  });
  }
 
  StandardPage.html
 
  wicket:head
  div wicket:id=myHeaderBucket/div
  style type=text/css wicket:id=style/style
  /wicket:head
 
  --
 
  Unfortunately I'm getting this exception when I instantiate a page:
 
  12:28:04,097 INFO [STDOUT] 2011-07-19 12:28:04.096
 [http-127.0.0.1-8080-1]
  [127.0.0.1] [T:2] [U:3 - joe_sharp]
  [com.transverse.bleep.wicket.desktop.DesktopPage] ERROR
  org.apache.wicket.RequestCycle 1529 - Exception in rendering component:
  [MarkupContainer [Component id = headerBucket]]
  org.apache.wicket.WicketRuntimeException: Exception in rendering
 component:
  [MarkupContainer [Component id = headerBucket]]
  at org.apache.wicket.Component.renderComponent(Component.java:2729)
  ~[wicket-1.4.17.jar:1.4.17]
  at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
  ~[wicket-1.4.17.jar:1.4.17]
  at org.apache.wicket.Component.render(Component.java:2521)
  ~[wicket-1.4.17.jar:1.4.17]
  ...
  Caused by: java.lang.RuntimeException: there was an error processing the
  header response - you tried to render a bucket of response from
  HeaderResponseContainerFilteringHeaderResponse, but it had not yet run
 and
  been closed. this should occur when the header container that is standard
  in wicket renders, so perhaps you have done something to keep that from
  rendering?
  at
 

 org.apache.wicket.resource.filtering.HeaderResponseFilteredResponseContainer.onComponentTagBody(HeaderResponseFilteredResponseContainer.java:67)
  ~[wicket-1.4.17.jar:1.4.17]
  at org.apache.wicket.Component.renderComponent(Component.java:2690)
  ~[wicket-1.4.17.jar:1.4.17]
  ... 81 common frames omitted
 
 
  Any ideas on what I'm doing wrong? Is there an easier approach I can
 take?
 
  Thanks,
  Loren





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

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



Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-07-22 Thread Alec Swan
I had a similar case where I wanted to contribute header sections that
are written with renderString() last. I was not able to figure out all
that resource aggregation and bucketing stuff, so I wrote something
simpler. I would appreciate if somebody could review and comment on
this:

setHeaderResponseDecorator(new IHeaderResponseDecorator()
{
@Override
public IHeaderResponse decorate(IHeaderResponse response) {
return new DecoratingHeaderResponse(response)
{
private CharSequence stringToRender;

@Override
public void renderString(CharSequence string) {
stringToRender = stringToRender == null ?
string : stringToRender.toString() + string;
}

@Override
public void close() {
renderStringIfNeeded();
super.close();
}

private void renderStringIfNeeded() {
if (stringToRender != null 
!wasRendered(stringToRender)) {
super.renderString(stringToRender);
markRendered(stringToRender);
}
}
};
}
});

On Fri, Jul 22, 2011 at 12:28 AM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 It is not documented by wicket:head contributes before
 #renderHead(). This may change in the future so don't rely on it.
 Better take a look at
 http://wicketstuff.org/wicket/resourceaggregation application. There
 you can see how resources are scored. This way you can setup
 org.apache.wicket.resource.filtering.HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter
 which renders your specific contribution after all other.
 To render CSS text use
 org.apache.wicket.markup.html.IHeaderResponse.renderCSS(CharSequence
 css, String id). Use the id in the filter to recognize it.

 On Fri, Jul 22, 2011 at 1:00 AM, Loren Cole loren.c...@gmail.com wrote:
 Under normal circumstances I would, but I don't have my css in a file.  It
 gets pulled from a database and stashed in the session.  All the header
 contributer classes and resource references assume there's a file somewhere
 with this info.  But in my case there is not.

 And, even id I did stuff this data into a file it still wouldn't fix my
 problem, because the customer defined css needs to override everything else
 with the same css selector. If another component added a header contributor
 afterwards that would not be the case.

 -
 Loren

 On Tue, Jul 19, 2011 at 11:35 PM, Jeremy Thomerson 
 jer...@wickettraining.com wrote:

 To start, don't use a Label to contribute css.  Use a header contributor.
 That's what they're made for.
 On 2011 7 19 13:22, Loren Cole loren.c...@gmail.com wrote:
  We're making our application skinable, but I'm having some trouble
 getting
  user specified css into the right place in the header. We're working in a
  distributed environment, so instead of saving their css in the file
 system
  we're putting it in our database, and in order to get the cascade to work
  properly we need to add this css after all the others. Here's how I'm
  adding it:
 
  StandardPage.java
 
  onInitialize()
  //Add any override style
  Tenant tenant = MyWebSession.get().getTenant();
  Css css = cssRepository.GetStyleByTenant(tenant);
  if(tenant.getBranding()  css != null) {
  add(new Label(style, css.getStyle()));
  }
  }
 
  StandardPage.html
 
  wicket:head
  style type=text/css wicket:id=style/style
  /wicket:head
 
  -
  So the issue is that thet style tag comes before all my header
  contributions. I've tried specifying a header response decorator like so:
 
  Application.java
 
  public static final String HEADER_FILTER_NAME = myHeaderBucket;
 
  init() {
  super.init();
  setHeaderResponseDecorator(new IHeaderResponseDecorator() {
 
  HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[]
  filters = {new CssAcceptingHeaderResponseFilter(HEADER_FILTER_NAME)};
  @Override
  public IHeaderResponse decorate(IHeaderResponse response) {
  return new
  HeaderResponseContainerFilteringHeaderResponse(response,
 HEADER_FILTER_NAME,
  filters);
  }
  });
  }
 
  StandardPage.html
 
  wicket:head
  div wicket:id=myHeaderBucket/div
  style type=text/css wicket:id=style/style
  /wicket:head
 
  --
 
  Unfortunately I'm getting this exception when I instantiate a page:
 
  12:28:04,097 INFO [STDOUT] 2011-07-19 12:28:04.096
 [http-127.0.0.1-8080-1]
  [127.0.0.1] [T:2] [U:3 - joe_sharp]
  [com.transverse.bleep.wicket.desktop.DesktopPage] ERROR
  org.apache.wicket.RequestCycle 1529 - Exception in rendering component:
  [MarkupContainer [Component id = headerBucket]]
  org.apache.wicket.WicketRuntimeException: Exception in rendering
 component:
  

Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-07-21 Thread Loren Cole
Under normal circumstances I would, but I don't have my css in a file.  It
gets pulled from a database and stashed in the session.  All the header
contributer classes and resource references assume there's a file somewhere
with this info.  But in my case there is not.

And, even id I did stuff this data into a file it still wouldn't fix my
problem, because the customer defined css needs to override everything else
with the same css selector. If another component added a header contributor
afterwards that would not be the case.

-
Loren

On Tue, Jul 19, 2011 at 11:35 PM, Jeremy Thomerson 
jer...@wickettraining.com wrote:

 To start, don't use a Label to contribute css.  Use a header contributor.
 That's what they're made for.
 On 2011 7 19 13:22, Loren Cole loren.c...@gmail.com wrote:
  We're making our application skinable, but I'm having some trouble
 getting
  user specified css into the right place in the header. We're working in a
  distributed environment, so instead of saving their css in the file
 system
  we're putting it in our database, and in order to get the cascade to work
  properly we need to add this css after all the others. Here's how I'm
  adding it:
 
  StandardPage.java
 
  onInitialize()
  //Add any override style
  Tenant tenant = MyWebSession.get().getTenant();
  Css css = cssRepository.GetStyleByTenant(tenant);
  if(tenant.getBranding()  css != null) {
  add(new Label(style, css.getStyle()));
  }
  }
 
  StandardPage.html
 
  wicket:head
  style type=text/css wicket:id=style/style
  /wicket:head
 
  -
  So the issue is that thet style tag comes before all my header
  contributions. I've tried specifying a header response decorator like so:
 
  Application.java
 
  public static final String HEADER_FILTER_NAME = myHeaderBucket;
 
  init() {
  super.init();
  setHeaderResponseDecorator(new IHeaderResponseDecorator() {
 
  HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[]
  filters = {new CssAcceptingHeaderResponseFilter(HEADER_FILTER_NAME)};
  @Override
  public IHeaderResponse decorate(IHeaderResponse response) {
  return new
  HeaderResponseContainerFilteringHeaderResponse(response,
 HEADER_FILTER_NAME,
  filters);
  }
  });
  }
 
  StandardPage.html
 
  wicket:head
  div wicket:id=myHeaderBucket/div
  style type=text/css wicket:id=style/style
  /wicket:head
 
  --
 
  Unfortunately I'm getting this exception when I instantiate a page:
 
  12:28:04,097 INFO [STDOUT] 2011-07-19 12:28:04.096
 [http-127.0.0.1-8080-1]
  [127.0.0.1] [T:2] [U:3 - joe_sharp]
  [com.transverse.bleep.wicket.desktop.DesktopPage] ERROR
  org.apache.wicket.RequestCycle 1529 - Exception in rendering component:
  [MarkupContainer [Component id = headerBucket]]
  org.apache.wicket.WicketRuntimeException: Exception in rendering
 component:
  [MarkupContainer [Component id = headerBucket]]
  at org.apache.wicket.Component.renderComponent(Component.java:2729)
  ~[wicket-1.4.17.jar:1.4.17]
  at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
  ~[wicket-1.4.17.jar:1.4.17]
  at org.apache.wicket.Component.render(Component.java:2521)
  ~[wicket-1.4.17.jar:1.4.17]
  ...
  Caused by: java.lang.RuntimeException: there was an error processing the
  header response - you tried to render a bucket of response from
  HeaderResponseContainerFilteringHeaderResponse, but it had not yet run
 and
  been closed. this should occur when the header container that is standard
  in wicket renders, so perhaps you have done something to keep that from
  rendering?
  at
 

 org.apache.wicket.resource.filtering.HeaderResponseFilteredResponseContainer.onComponentTagBody(HeaderResponseFilteredResponseContainer.java:67)
  ~[wicket-1.4.17.jar:1.4.17]
  at org.apache.wicket.Component.renderComponent(Component.java:2690)
  ~[wicket-1.4.17.jar:1.4.17]
  ... 81 common frames omitted
 
 
  Any ideas on what I'm doing wrong? Is there an easier approach I can
 take?
 
  Thanks,
  Loren



Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-07-21 Thread robert.mcguinness
put your css string from db in:


new StringBufferResourceStream().add(yourCssFromDB) 


and then you can contribute to the header properly

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Issues-with-HeaderResponseContainerFilteringHeaderResponse-tp3678890p3685782.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Issues with HeaderResponseContainerFilteringHeaderResponse

2011-07-19 Thread Jeremy Thomerson
To start, don't use a Label to contribute css.  Use a header contributor.
That's what they're made for.
On 2011 7 19 13:22, Loren Cole loren.c...@gmail.com wrote:
 We're making our application skinable, but I'm having some trouble getting
 user specified css into the right place in the header. We're working in a
 distributed environment, so instead of saving their css in the file system
 we're putting it in our database, and in order to get the cascade to work
 properly we need to add this css after all the others. Here's how I'm
 adding it:

 StandardPage.java

 onInitialize()
 //Add any override style
 Tenant tenant = MyWebSession.get().getTenant();
 Css css = cssRepository.GetStyleByTenant(tenant);
 if(tenant.getBranding()  css != null) {
 add(new Label(style, css.getStyle()));
 }
 }

 StandardPage.html

 wicket:head
 style type=text/css wicket:id=style/style
 /wicket:head

 -
 So the issue is that thet style tag comes before all my header
 contributions. I've tried specifying a header response decorator like so:

 Application.java

 public static final String HEADER_FILTER_NAME = myHeaderBucket;

 init() {
 super.init();
 setHeaderResponseDecorator(new IHeaderResponseDecorator() {

 HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[]
 filters = {new CssAcceptingHeaderResponseFilter(HEADER_FILTER_NAME)};
 @Override
 public IHeaderResponse decorate(IHeaderResponse response) {
 return new
 HeaderResponseContainerFilteringHeaderResponse(response,
HEADER_FILTER_NAME,
 filters);
 }
 });
 }

 StandardPage.html

 wicket:head
 div wicket:id=myHeaderBucket/div
 style type=text/css wicket:id=style/style
 /wicket:head

 --

 Unfortunately I'm getting this exception when I instantiate a page:

 12:28:04,097 INFO [STDOUT] 2011-07-19 12:28:04.096 [http-127.0.0.1-8080-1]
 [127.0.0.1] [T:2] [U:3 - joe_sharp]
 [com.transverse.bleep.wicket.desktop.DesktopPage] ERROR
 org.apache.wicket.RequestCycle 1529 - Exception in rendering component:
 [MarkupContainer [Component id = headerBucket]]
 org.apache.wicket.WicketRuntimeException: Exception in rendering
component:
 [MarkupContainer [Component id = headerBucket]]
 at org.apache.wicket.Component.renderComponent(Component.java:2729)
 ~[wicket-1.4.17.jar:1.4.17]
 at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
 ~[wicket-1.4.17.jar:1.4.17]
 at org.apache.wicket.Component.render(Component.java:2521)
 ~[wicket-1.4.17.jar:1.4.17]
 ...
 Caused by: java.lang.RuntimeException: there was an error processing the
 header response - you tried to render a bucket of response from
 HeaderResponseContainerFilteringHeaderResponse, but it had not yet run and
 been closed. this should occur when the header container that is standard
 in wicket renders, so perhaps you have done something to keep that from
 rendering?
 at

org.apache.wicket.resource.filtering.HeaderResponseFilteredResponseContainer.onComponentTagBody(HeaderResponseFilteredResponseContainer.java:67)
 ~[wicket-1.4.17.jar:1.4.17]
 at org.apache.wicket.Component.renderComponent(Component.java:2690)
 ~[wicket-1.4.17.jar:1.4.17]
 ... 81 common frames omitted


 Any ideas on what I'm doing wrong? Is there an easier approach I can take?

 Thanks,
 Loren