wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gonzalo Aguilar Delgado <gagui...@aguilardelgado.com>
Subject Re: Do I need a custom ResourceAggregator
Date Sat, 08 Sep 2012 23:26:49 GMT
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(),dojoDependencies));
		}
	}
...
}



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


Mime
View raw message