wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emond Papegaaij <emond.papega...@topicus.nl>
Subject Re: Do I need a custom ResourceAggregator
Date Mon, 10 Sep 2012 07:48:28 GMT
Yes, this is the way to do it. Most of the code in ResourceAggregator is about 
resolving dependencies and resource bundles. If your DojoRequireHeaderItem is 
never part of a bundle (which probably is the case), you can skip the 
'getItemToBeRendered' part.

Best regards,
Emond

On Sunday 09 September 2012 01:26:49 Gonzalo Aguilar Delgado wrote:
> Hello,
> 
> I can answer myself.
> 
> I was studing wicket code and the examples and found a solution,
> extending DecoratingHeaderResponse. It still makes me feel a little bit
> lost but it works.
> 
> I copied functionality from ResourceAggregator.
> 
> 
> public class DojoAggregatorHeaderResponse extends
> DecoratingHeaderResponse {
> ...
> 
> 	private void renderCombinedEventScripts()
> 	{
> 		StringBuilder combinedScript = new StringBuilder();
> 		List<String> dojoDependencies = new ArrayList<String>();
> 		for (DojoRequireHeaderItem curItem : dojoRequireItemsToBeRendered)
> 		{
> 			HeaderItem itemToBeRendered = getItemToBeRendered(curItem);
> 			if (itemToBeRendered == curItem)
> 			{
> 				combinedScript.append("\n");
> 				combinedScript.append(curItem.getJavaScript());
> 				combinedScript.append(";");
> 				for(String requirement : curItem.getDojoDependencies())
> 				{
> 					if(!dojoDependencies.contains(requirement))
> 						dojoDependencies.add(requirement);			// TODO Will be 
faster with a
> hash?
> 				}
> 			}
> 			else
> 			{
> 				getRealResponse().render(itemToBeRendered);
> 			}
> 
> 		}
> 		if (combinedScript.length() > 0)
> 		{
> 			getRealResponse().render(
> 
> DojoRequireHeaderItem.forScript(combinedScript.append("\n").toString(),dojoD
> ependencies)); }
> 	}
> ...
> }
> 
> 
> 
> Is this correct way to do it?
> 
> 
> Best regards,
> 
> El sáb, 08-09-2012 a las 21:35 +0200, Gonzalo Aguilar Delgado escribió:
> > Hello,
> > 
> > I'm reimplementing my dojo interface again with version 6.0.0 of wicket.
> > 
> > I need to replicate same functionality that gives ResourceAggregator +
> > OnDomReadyHeaderItem.
> > 
> > I mean, I need that every script that goes into the require when don is
> > aggregated.
> > 
> > 
> > require(["dojo/dom", "dojo/domReady!"], function(dom){
> > 
> > 	// All scripts here...
> > 
> > });
> > 
> > 
> > So I just want to create a new header item called DojoReadyHeaderItem
> > and add everything needed to the same script at the begining of the
> > page.
> > 
> > Behaviors will do something like this:
> > 
> > response.render(DojoReadyHeaderItem.forScript("foobar"));
> > 
> > 		response.render(DojoReadyHeaderItem.forScript("foobar2"));
> > 
> > And the result will be like:
> > 
> > 
> > require(["dojo/dom", "dojo/domReady!"], function(dom){
> > 
> > 	foobar;
> > 	foobar2;
> > 
> > });
> > 
> > 
> > How can I do this with current implementation?
> > 
> > I don't know how to add my own ResourceAggregator...
> > 
> > 
> > Thank you in advance.
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > 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

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


Mime
View raw message