Thanks! And please attach it to the JIRA file. Per Apache foundation
copyright guidelines, only code written by committers or posted in JIRA
can be committed.
On Thu, 06 Jan 2011 18:35:51 -0200, Paul Stanton <p...@mapshed.com.au>
wrote:
Thiago,
FYI here's my latest version of my MultiZoneUpdate helper, updated for
t5.2 renamed to XHRResponseHelper:
public class XHRResponseHelper
{
private HashMap<String, Object> zoneUpdates;
public XHRResponseHelper()
{
this.zoneUpdates = new HashMap<String, Object>();
}
public void addScriptCall(final String script, PageRenderQueue
pageRenderQueue, final JavaScriptSupport javascriptSupport)
{
pageRenderQueue.addPartialMarkupRendererFilter(new
PartialMarkupRendererFilter()
{
public void renderMarkup(MarkupWriter writer, JSONObject
reply, PartialMarkupRenderer renderer)
{
javascriptSupport.addScript(script);
renderer.renderMarkup(writer, reply);
}
});
}
public void addZoneUpdate(String zoneId, ComponentResources
componentResoures)
{
addZoneUpdate(zoneId,
componentResoures.getEmbeddedComponent(zoneId));
}
private void addZoneUpdate(String zoneId, Object renderer)
{
zoneUpdates.put(zoneId, renderer);
}
public MultiZoneUpdate buildMultiZoneUpdate()
{
MultiZoneUpdate mzu = null;
for (Entry<String, Object> entry : zoneUpdates.entrySet())
{
if (mzu == null)
mzu = new MultiZoneUpdate(entry.getKey(),
entry.getValue());
else
mzu.add(entry.getKey(), entry.getValue());
}
return mzu; // null if zoneUpdates is empty
}
}
It can be used like so:
@Inject
private PageRenderQueue pageRenderQueue;
@Inject
private JavaScriptSupport javascriptSupport;
@Inject
private ComponentResources componentResources;
MultiZoneUpdate onSelectItem(String identifier)
{
XHRResponseHelper xrh = new XHRResponseHelper();
xrh.addScriptCall("alert('selected " + identifier + "');",
pageRenderQueue, javascriptSupport);
xrh.addZoneUpdate("myZone", componentResources);
return xrh.buildMultiZoneUpdate();
}
The tapestry resouces pageRenderQueue, javascriptSupport and
componentResources are passed in as parameters to each method since they
are environmental services and the XHRResponseHelper may be contributed
to by embedded components as well.
will log jira issues for consideration now.
p.
On 6/01/2011 10:49 PM, Thiago H. de Paula Figueiredo wrote:
On Thu, 06 Jan 2011 08:09:41 -0200, Paul Stanton <p...@mapshed.com.au>
wrote:
On 6/01/2011 12:53 PM, Thiago H. de Paula Figueiredo wrote:
As far as I know, when you return a MultiZoneUpdate, the value passed
to the zone parameter is completely ignored, so there's no need to
create a dummy zone.
really? i thought a valid zone was required to initiate the ajax
request (in the current methodology).
A valid zone is needed for MultiZoneUpdate requests AFAIK, but which
one is passed to the zone parameter is ignored.
Tapestry.findZoneManagerForZone(zoneId).updateFromURL(url)
Do you give us permission to use it in Tapestry itself if the team
approves your code?
absolutely. only glaringly obvious problem is that the context
parameters don't get encoded properly, hopefully someone can rectify
this..
Cool!
Feel free to file a JIRA for your suggestions.
I will do.
I'd be keen to contribute further, but I imagine I don't understand
the big picture well enough yet to be a committer.
Give your suggestions and let the Tapestry team decide. :)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org