You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Paul Stanton (JIRA)" <ji...@apache.org> on 2011/01/07 08:25:46 UTC

[jira] Created: (TAP5-1407) multizoneupdate should be easier to use - not a chain

multizoneupdate should be easier to use - not a chain
-----------------------------------------------------

                 Key: TAP5-1407
                 URL: https://issues.apache.org/jira/browse/TAP5-1407
             Project: Tapestry 5
          Issue Type: Improvement
          Components: tapestry-core
    Affects Versions: 5.2.4
            Reporter: Paul Stanton


Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] [Assigned] (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by Taha Hafeez <ta...@gmail.com>.
Hi Howard

I submitted a patch for TAPS-1476 which is related to this issue.

https://issues.apache.org/jira/browse/TAP5-1476?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

regards
Taha

On Fri, Jul 8, 2011 at 6:32 AM, Howard M. Lewis Ship (JIRA) <jira@apache.org
> wrote:

>
>     [
> https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> Howard M. Lewis Ship reassigned TAP5-1407:
> ------------------------------------------
>
>    Assignee: Howard M. Lewis Ship
>
> > multizoneupdate should be easier to use - not a chain
> > -----------------------------------------------------
> >
> >                 Key: TAP5-1407
> >                 URL: https://issues.apache.org/jira/browse/TAP5-1407
> >             Project: Tapestry 5
> >          Issue Type: Improvement
> >          Components: tapestry-core
> >    Affects Versions: 5.2.4
> >            Reporter: Paul Stanton
> >            Assignee: Howard M. Lewis Ship
> >
> > Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> > public class MultiZoneUpdate
> > {
> > ...
> >     public MultiZoneUpdate add(String zoneId, Object renderer)
> >     {
> >         return new MultiZoneUpdate(zoneId, renderer, this);
> >     }
> > ...
> > }
> > usage:
> > MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> > mzu = mzu.add("zone2", zone2); // ugly!
> > mzu = mzu.add("zone3", zone3); // ugly!
> > ...
> > return mzu;
> > This becomes hard to use when event handlers call common methods which
> contribute zone updates.
> > Also, it is possible to request multiple updates for the one zone which
> doesn't make much sense.
> > In some cases it would be much easier if you could construct a
> MultiZoneUpdate object without actually contributing a zone update
> directive. ie:
> > MultiZoneUpdate mzu = new MultiZoneUpdate();
> > mzu.add("zone2", zone1);
> > mzu.add("zone2", zone2);
> > mzu.add("zone3", zone3);
> > mzu.add("zone3", zone3); // knocks out prev zone3 update
> > ...
> > return mzu;
> > I have created a utility class which helps me work around this issue (and
> issue #TAP5-1406), however note it relies on the dummy zone hack.:
> > import java.util.HashMap;
> > import java.util.Map.Entry;
> > import org.apache.tapestry5.ComponentResources;
> > import org.apache.tapestry5.MarkupWriter;
> > import org.apache.tapestry5.ajax.MultiZoneUpdate;
> > import org.apache.tapestry5.internal.services.PageRenderQueue;
> > import org.apache.tapestry5.json.JSONObject;
> > import org.apache.tapestry5.services.PartialMarkupRenderer;
> > import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> > import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> > public class XHRResponseHelper
> > {
> >       private HashMap<String, Object> zoneUpdates;
> >       private boolean scriptAdded;
> >       public XHRResponseHelper()
> >       {
> >               this.zoneUpdates = new HashMap<String, Object>();
> >               scriptAdded = false;
> >       }
> >       public void addScriptCall(final String script, PageRenderQueue
> pageRenderQueue, final JavaScriptSupport javascriptSupport)
> >       {
> >               scriptAdded = true;
> >               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
> componentResources)
> >       {
> >               addZoneUpdate(zoneId,
> componentResources.getEmbeddedComponent(zoneId));
> >       }
> >       public void addZoneUpdate(String zoneId, Object renderer)
> >       {
> >               zoneUpdates.put(zoneId, renderer);
> >       }
> >       public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources
> componentResources)
> >       {
> >               // work around issue  -
> https://issues.apache.org/jira/browse/TAP5-1406
> >               if (zoneUpdates.isEmpty() && scriptAdded)
> >                       addZoneUpdate("dummyZone", componentResources);
> >               MultiZoneUpdate mzu = null;
> >               for (Entry<String, Object> entry : zoneUpdates.entrySet())
> >               {
> >                       if (mzu == null)
> >                               mzu = new MultiZoneUpdate(entry.getKey(),
> entry.getValue());
> >                       else
> >                               mzu = mzu.add(entry.getKey(),
> entry.getValue());
> >               }
> >               return mzu; // null if zoneUpdates is empty
> >       }
> > }
> > usage:
> > XHRResponseHelper response = new XHRResponseHelper();
> > response.addZoneUpdate("myZone", componentResources);
> > response.addZoneUpdate("myZone2", block);
> > response.addScriptCall("alert('script');", pageRenderQueue,
> javascriptSupport);
> > return response.buildMultiZoneUpdate(componentResources);
> > hope that helps.
>
> --
> This message is automatically generated by JIRA.
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>


-- 
regards
Tawus
tawus.wordpress.com

[jira] Commented: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978883#action_12978883 ] 

Howard M. Lewis Ship commented on TAP5-1407:
--------------------------------------------

Actually, I'm thinking the MultiZoneUpdate object could be deprecated, and a service take its place.  MZU is just a bit unwieldy to use, despite some work on it in 5.2 and, in the long run, it doesn't actually prevent some amount of per-thread state from being stored ... in other words, over-engineered.  

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
	{
		scriptAdded = true;
		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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Assigned] (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship reassigned TAP5-1407:
------------------------------------------

    Assignee: Howard M. Lewis Ship

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>            Assignee: Howard M. Lewis Ship
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
	{
		scriptAdded = true;
		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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
	{
		scriptAdded = true;
		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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		MultiZoneUpdate mzu = null;

		for (Entry<String, Object> entry : zoneUpdates.entrySet())
		{
			if (mzu == null)
				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
			else
				mzu = mzu.add(entry.getKey(), entry.getValue());
		}

		return mzu; // null if zoneUpdates is empty
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
	{
		scriptAdded = true;
		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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.


fixed bug in XhrResponseHelper

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Fix Version/s: 5.2.4
      Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu = mzu.add("zone2", zone2);
mzu = mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
> mzu = mzu.add("zone2", zone2);
> mzu = mzu.add("zone3", zone3);
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> ...
> return mzu;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Assigned] (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship reassigned TAP5-1407:
------------------------------------------

    Assignee: Howard M. Lewis Ship

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>            Assignee: Howard M. Lewis Ship
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978883#action_12978883 ] 

Howard M. Lewis Ship commented on TAP5-1407:
--------------------------------------------

Actually, I'm thinking the MultiZoneUpdate object could be deprecated, and a service take its place.  MZU is just a bit unwieldy to use, despite some work on it in 5.2 and, in the long run, it doesn't actually prevent some amount of per-thread state from being stored ... in other words, over-engineered.  

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Fix Version/s: 5.2.4
      Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu = mzu.add("zone2", zone2);
mzu = mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
> mzu = mzu.add("zone2", zone2);
> mzu = mzu.add("zone3", zone3);
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> ...
> return mzu;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Fix Version/s:     (was: 5.2.4)

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

in my utility class, i create a map of updates and construct the MultiZoneUpdate chain at the end.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu = mzu.add("zone2", zone2);
mzu = mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> in my utility class, i create a map of updates and construct the MultiZoneUpdate chain at the end.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

in my utility class, i create a map of updates and construct the MultiZoneUpdate chain at the end.


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978935#action_12978935 ] 

Paul Stanton commented on TAP5-1407:
------------------------------------

good, that is kind of what i'm suggesting too.

if it were a service, would it be an environmental? if so, wouldn't it fall into the trap of being bound to one 'component layer'?

in one 'xhr-response' i often need to create zone updates for zones at different levels ie (note the method 'addSomeZoneUpdatesUsingYourOwnComponentResources'):

public class MyPage
{
...
@InjectComponent
private MyComponent myComponent;

private MultiZoneUpdate onMyEvent()
{
XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);

myComponent.addSomeZoneUpdatesUsingYourOwnComponentResources(response);

response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);
}

this is why i have the environmentals as parameters for my helper class .. so that the response can be contributed to from multiple 'environments' ie components.

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Resolved] (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship resolved TAP5-1407.
----------------------------------------

    Resolution: Duplicate

Will be addressed as part of TAP5-1476.

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>            Assignee: Howard M. Lewis Ship
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Fix Version/s:     (was: 5.2.4)

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978935#action_12978935 ] 

Paul Stanton commented on TAP5-1407:
------------------------------------

good, that is kind of what i'm suggesting too.

if it were a service, would it be an environmental? if so, wouldn't it fall into the trap of being bound to one 'component layer'?

in one 'xhr-response' i often need to create zone updates for zones at different levels ie (note the method 'addSomeZoneUpdatesUsingYourOwnComponentResources'):

public class MyPage
{
...
@InjectComponent
private MyComponent myComponent;

private MultiZoneUpdate onMyEvent()
{
XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);

myComponent.addSomeZoneUpdatesUsingYourOwnComponentResources(response);

response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);
}

this is why i have the environmentals as parameters for my helper class .. so that the response can be contributed to from multiple 'environments' ie components.

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

in my utility class, i create a map of updates and construct the MultiZoneUpdate chain at the end.


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		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
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Resolved] (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship resolved TAP5-1407.
----------------------------------------

    Resolution: Duplicate

Will be addressed as part of TAP5-1476.

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>            Assignee: Howard M. Lewis Ship
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

in my utility class, i create a map of updates and construct the MultiZoneUpdate chain at the end.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1);
mzu = mzu.add("zone2", zone2);
mzu = mzu.add("zone3", zone3);
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
...
return mzu;


> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> in my utility class, i create a map of updates and construct the MultiZoneUpdate chain at the end.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

Posted by "Paul Stanton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Stanton updated TAP5-1407:
-------------------------------

    Description: 
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
	{
		scriptAdded = true;
		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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		MultiZoneUpdate mzu = null;

		for (Entry<String, Object> entry : zoneUpdates.entrySet())
		{
			if (mzu == null)
				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
			else
				mzu = mzu.add(entry.getKey(), entry.getValue());
		}

		return mzu; // null if zoneUpdates is empty
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.

  was:
Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie

public class MultiZoneUpdate
{
...
    public MultiZoneUpdate add(String zoneId, Object renderer)
    {
        return new MultiZoneUpdate(zoneId, renderer, this);
    }
...
}

usage:

MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
mzu = mzu.add("zone2", zone2); // ugly!
mzu = mzu.add("zone3", zone3); // ugly!
...
return mzu;

This becomes hard to use when event handlers call common methods which contribute zone updates.

Also, it is possible to request multiple updates for the one zone which doesn't make much sense.

In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:

MultiZoneUpdate mzu = new MultiZoneUpdate();
mzu.add("zone2", zone1);
mzu.add("zone2", zone2);
mzu.add("zone3", zone3);
mzu.add("zone3", zone3); // knocks out prev zone3 update
...
return mzu;

I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:


import java.util.HashMap;
import java.util.Map.Entry;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ajax.MultiZoneUpdate;
import org.apache.tapestry5.internal.services.PageRenderQueue;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.PartialMarkupRenderer;
import org.apache.tapestry5.services.PartialMarkupRendererFilter;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class XHRResponseHelper
{
	private HashMap<String, Object> zoneUpdates;
	private boolean scriptAdded;

	public XHRResponseHelper()
	{
		this.zoneUpdates = new HashMap<String, Object>();
		scriptAdded = false;
	}

	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
	{
		scriptAdded = true;
		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 componentResources)
	{
		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
	}

	public void addZoneUpdate(String zoneId, Object renderer)
	{
		zoneUpdates.put(zoneId, renderer);
	}

	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
	{
		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
		if (zoneUpdates.isEmpty() && scriptAdded)
			addZoneUpdate("dummyZone", componentResources);

		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
	}
}

usage:

XHRResponseHelper response = new XHRResponseHelper();
response.addZoneUpdate("myZone", componentResources);
response.addZoneUpdate("myZone2", block);
response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
return response.buildMultiZoneUpdate(componentResources);


hope that helps.


fixed bug in XhrResponseHelper

> multizoneupdate should be easier to use - not a chain
> -----------------------------------------------------
>
>                 Key: TAP5-1407
>                 URL: https://issues.apache.org/jira/browse/TAP5-1407
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.2.4
>            Reporter: Paul Stanton
>             Fix For: 5.2.4
>
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
>     public MultiZoneUpdate add(String zoneId, Object renderer)
>     {
>         return new MultiZoneUpdate(zoneId, renderer, this);
>     }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which doesn't make much sense.
> In some cases it would be much easier if you could construct a MultiZoneUpdate object without actually contributing a zone update directive. ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
> 	private HashMap<String, Object> zoneUpdates;
> 	private boolean scriptAdded;
> 	public XHRResponseHelper()
> 	{
> 		this.zoneUpdates = new HashMap<String, Object>();
> 		scriptAdded = false;
> 	}
> 	public void addScriptCall(final String script, PageRenderQueue pageRenderQueue, final JavaScriptSupport javascriptSupport)
> 	{
> 		scriptAdded = true;
> 		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 componentResources)
> 	{
> 		addZoneUpdate(zoneId, componentResources.getEmbeddedComponent(zoneId));
> 	}
> 	public void addZoneUpdate(String zoneId, Object renderer)
> 	{
> 		zoneUpdates.put(zoneId, renderer);
> 	}
> 	public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources componentResources)
> 	{
> 		// work around issue  - https://issues.apache.org/jira/browse/TAP5-1406
> 		if (zoneUpdates.isEmpty() && scriptAdded)
> 			addZoneUpdate("dummyZone", componentResources);
> 		MultiZoneUpdate mzu = null;
> 		for (Entry<String, Object> entry : zoneUpdates.entrySet())
> 		{
> 			if (mzu == null)
> 				mzu = new MultiZoneUpdate(entry.getKey(), entry.getValue());
> 			else
> 				mzu = mzu.add(entry.getKey(), entry.getValue());
> 		}
> 		return mzu; // null if zoneUpdates is empty
> 	}
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.