You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Robin Garner <ro...@scu.edu.au> on 2015/09/20 03:30:34 UTC

How to trigger a zone update from a jquery Context Menu event ?

I'm trying to use a context menu (using tapestry5-jquery's 
jquery/ContextMenu mixin) to perform an action, and then I want to 
update the page to reflect the new state.  The first part works just 
fine, but I can't figure out how to get the page updated afterwards. 
While a zone update would be ideal, reloading the page would do in a pinch.

I've reduced the problem down to a simple test page:

---------------------------------
ContextMenuTest.tml

<html t:type="layout" title="Context Menu Test"
       xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
       xmlns:p="tapestry:parameter"
       xmlns:j="tapestry-library:jquery">

   <t:zone t:id="testZone">
     The count is ${count}.
     <div t:type="any" t:items="contextMenuItems"
                  t:mixins="jquery/ContextMenu"
                  t:zone="testZone"
                  t:id="uid_contextMenu">
        left-click here
     </div>
   </t:zone>
</html>
---------------------------------

---------------------------------
ContextMenuTest.java

public class ContextMenuTest {

   @Persist @Property int count;

   public List<ContextMenuItem> getContextMenuItems() {
     return Arrays.asList(new ContextMenuItem("Update count", 
"updateCount"));
   }

   @Component private Zone testZone;

   @OnEvent(value="updateCount")
   Object contextMenuAction() {
     count++;
     return testZone.getBody();
   }
}
---------------------------------

Thanks in advance,
Robin



-- 
Dr Robin Garner
Technology Services
Southern Cross University
P: +61 2 6620 3281   M: +61 418 619 500
http://cs.anu.edu.au/people/robin.garner/

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


Re: How to trigger a zone update from a jquery Context Menu event ?

Posted by françois facon <fr...@gmail.com>.
Hello Robin,

This mixin only send a simple Ajax call.
It would make sense to ask for a new parameter that specify a Zone to
update.
at https://github.com/got5/tapestry5-jquery/issues.


François

2015-09-20 3:30 GMT+02:00 Robin Garner <ro...@scu.edu.au>:

> I'm trying to use a context menu (using tapestry5-jquery's
> jquery/ContextMenu mixin) to perform an action, and then I want to update
> the page to reflect the new state.  The first part works just fine, but I
> can't figure out how to get the page updated afterwards. While a zone
> update would be ideal, reloading the page would do in a pinch.
>
> I've reduced the problem down to a simple test page:
>
> ---------------------------------
> ContextMenuTest.tml
>
> <html t:type="layout" title="Context Menu Test"
>       xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
>       xmlns:p="tapestry:parameter"
>       xmlns:j="tapestry-library:jquery">
>
>   <t:zone t:id="testZone">
>     The count is ${count}.
>     <div t:type="any" t:items="contextMenuItems"
>                  t:mixins="jquery/ContextMenu"
>                  t:zone="testZone"
>                  t:id="uid_contextMenu">
>        left-click here
>     </div>
>   </t:zone>
> </html>
> ---------------------------------
>
> ---------------------------------
> ContextMenuTest.java
>
> public class ContextMenuTest {
>
>   @Persist @Property int count;
>
>   public List<ContextMenuItem> getContextMenuItems() {
>     return Arrays.asList(new ContextMenuItem("Update count",
> "updateCount"));
>   }
>
>   @Component private Zone testZone;
>
>   @OnEvent(value="updateCount")
>   Object contextMenuAction() {
>     count++;
>     return testZone.getBody();
>   }
> }
> ---------------------------------
>
> Thanks in advance,
> Robin
>
>
>
> --
> Dr Robin Garner
> Technology Services
> Southern Cross University
> P: +61 2 6620 3281   M: +61 418 619 500
> http://cs.anu.edu.au/people/robin.garner/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>