You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Mylonas <ch...@opencsta.org> on 2012/04/13 11:41:18 UTC
Render Queue Error in Expansion
Hi Tap List,
I've got two custom components. Reception Line & Office Phone
They are just little divs and with a draggable and a droppable zone respectively.
In my testing, dragging and dropping between these works when everything is done on the same page and this is my first shot at componentizing my initial drag and drop fiddling. I mean, one component has the drag, and another component has the drop zone.
Each Office Phone looks like this
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<div id="extension">
<div t:type='zone' t:id="extensionZone" t:mixins='jquery/zonedroppable'>
${currentExtension.name}
${currentExtension.number}
</div>
<div t:type='zone' t:id="voicemailZone" t:mixins='jquery/zonedroppable'>
<div id="random1">
<img src="${asset:context:layout/images/email.png}" />
</div>
</div>
</div>
</t:container>
I have 3 of these in my List<Phone> "source".
I think I understand that ${currentExtension} worked when rendering the page. But now that there is some AJAX happening - ${currentExtension} is null because there is no "source" anymore. Where should I start looking in Tapestry to pass this stuff. Can I somehow grab the "id" of something then traverse my "source" List<Phone> and get the corresponding name/number that this expansion had during the initial render?
Hope that makes sense,
Cheers
Chris
AJAX Re: Render Queue Error in Expansion
Posted by Chris Mylonas <ch...@opencsta.org>.
Ah ha - let me make it a bit clearer.
The AJAX stuff all works, if I hard code the values within my component.
It's like having a grid and each row has the ${currentRow.name} ${currentRow.value}
These property bindings don't exist after render.
If I were to use the Grid -> addCell then there is no problem. AJAX does it's drag and drop thing.
On 13/04/2012, at 7:41 PM, Chris Mylonas wrote:
> Hi Tap List,
>
> I've got two custom components. Reception Line & Office Phone
> They are just little divs and with a draggable and a droppable zone respectively.
>
> In my testing, dragging and dropping between these works when everything is done on the same page and this is my first shot at componentizing my initial drag and drop fiddling. I mean, one component has the drag, and another component has the drop zone.
>
> Each Office Phone looks like this
> <t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
>
> <div id="extension">
> <div t:type='zone' t:id="extensionZone" t:mixins='jquery/zonedroppable'>
> ${currentExtension.name}
> ${currentExtension.number}
> </div>
> <div t:type='zone' t:id="voicemailZone" t:mixins='jquery/zonedroppable'>
> <div id="random1">
> <img src="${asset:context:layout/images/email.png}" />
> </div>
> </div>
> </div>
>
> </t:container>
>
> I have 3 of these in my List<Phone> "source".
>
> I think I understand that ${currentExtension} worked when rendering the page. But now that there is some AJAX happening - ${currentExtension} is null because there is no "source" anymore. Where should I start looking in Tapestry to pass this stuff. Can I somehow grab the "id" of something then traverse my "source" List<Phone> and get the corresponding name/number that this expansion had during the initial render?
>
> Hope that makes sense,
> Cheers
> Chris
Re: Render Queue Error in Expansion
Posted by Chris Mylonas <ch...@opencsta.org>.
> Your ajax event handler method will need to initialize any properties that
> are required in the rendering block
So somewhere in my early rendering phases I'd need to get a reference to the current block that is to be re-rendered and grab values out of that - I guess.
> Draggables can have a "draggablecontext" attribute. Although I've not used
> it I'm sure that you could pass the context required to initialize your
> property.
draggable context gets passed no problem - it's on the drop zone.
Within my component, the currentExtension is null.
I think I'll have to re-work what I want to do, or dive into tapestry's innards to get a reference to the current component. (like row in a grid)
//THIS WORKS!
@OnEvent(value = JQueryEventConstants.DROP, component = "extensionZone")
void dropOnExtensionZone(Object[] context){
String contextString = (String)context[0];
this.thedata = contextString + " on dropzone for " + currentExtension ;
}
Re: Render Queue Error in Expansion
Posted by Chris Mylonas <ch...@opencsta.org>.
Mate, thanks a lot for your effort I must say. And you summed it up well
- how to get the source of a component event? (if all the components have the same id)
At the moment, all 16 droppables have a component id of either "extensionZone" or "voicemailZone".
I can't set a "context" or custom id as I would like because you can't have property expansions passing into components - the exception is "...it must start with a letter and contain letters,numbers and underscore" - and for some reason "context" i passed in didn't stick.
If i leave no id so that tapestry assigns it, i get an exception.
I don't mind the "a lot of work aspect" -- but my tapestry knowledge hasn't quite hit into environment (apart from heartbeat) and contributing/augmenting stuff. My brain would explode at this point :)
I might try the MarkupWriter again and see if I can push t:id stuff through it - that way I may be able to do the Zone.getBody() or getId() to be unique
But last week when I was mucking around with this stuff, using the @ImportJQueryUI() with my own custom javascript for drag and drop (simple jqueryui samples) failed to do anything. This tml based stuff was the only way to make drag'n'drop work.
If I can set up a clean project with the non-working drag and drop, maybe i can submit a bug to the github project.
> I think that you need a handle on the ComponentEventRequestParameters so
> that you can call getNestedComponentId() which will have the id of the zone
> which fired the event.
>
> I'm not sure that this tapestry makes this avaliable to you by default but
> you could do it yourself.
>
> 1. Writer a ComponentEventRequestFilter which @Injects the Environment and
> calls environment.push() and pop() with the ComponentEventRequestParameters
>
> 2. Contribute the filter to the AjaxComponentEventRequestHandler
>
> 3. Your component could do this
> @Environmental ComponentEventRequestParameters parameters;
> @Inject ComponentResources resources;
>
> void myEventHandler() {
> Component component =
> resources.getEmbeddedComponent(parameters.getNestedComponentId());
> }
>
> It sounds like a lot of work... perhaps someone else knows of an easier way
> to get the source of a component event?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Render Queue Error in Expansion
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 13 Apr 2012 12:14:23 -0300, Lance Java <la...@googlemail.com>
wrote:
> It sounds like a lot of work... perhaps someone else knows of an easier
> way to get the source of a component event?
Have you thought of adding a query parameter containing the id of the
rendered object? That's what I'd do.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Render Queue Error in Expansion
Posted by Lance Java <la...@googlemail.com>.
Ignore my prev post about adding the drop zone to the context as this is
not associated with the draggable when the page is drawn.
I think that you need a handle on the ComponentEventRequestParameters so
that you can call getNestedComponentId() which will have the id of the zone
which fired the event.
I'm not sure that this tapestry makes this avaliable to you by default but
you could do it yourself.
1. Writer a ComponentEventRequestFilter which @Injects the Environment and
calls environment.push() and pop() with the ComponentEventRequestParameters
2. Contribute the filter to the AjaxComponentEventRequestHandler
3. Your component could do this
@Environmental ComponentEventRequestParameters parameters;
@Inject ComponentResources resources;
void myEventHandler() {
Component component =
resources.getEmbeddedComponent(parameters.getNestedComponentId());
}
It sounds like a lot of work... perhaps someone else knows of an easier way
to get the source of a component event?
Re: Render Queue Error in Expansion
Posted by Lance Java <la...@googlemail.com>.
If you want to know which dropzone received the dragabble, just pass the
zone id in the context along with the extension id.
I can't remember exatly how but I'm sure you can lookup zones by id by
@Inject'ing the ComponentResources
Re: Render Queue Error in Expansion
Posted by Lance Java <la...@googlemail.com>.
Something like this:
<t:loop source="extensions" value="extension">
<t:jquery.Draggable t:id="draggableItem1" t:draggablecontext="
extension.id" >
${extension.name}
${extension.number}
</t:jquery.Draggable>
</t:loop>
<div t:type='zone' t:id="extensionZone" t:mixins='jquery/zonedroppable'>
${droppedExtension.name}
${droppedExtension.number}
</div>
Page.java
---------
@InjectComponent
private Zone extensionZone;
@Property
private Item extension;
@Property
private List<Extension> extensions;
@Property
private Item droppedExtension;
@Inject
private ExtensionDao extensionDao;
void onActivate() {
extensions = ???;
}
@OnEvent(value = JQueryEventConstants.DROP, component = "extensionZone")
void Object dropOnExtensionZone(Object[] context){
String extensionId = (String) context[0];
this.droppedExtension = extensionDao.getFromDatabase(extensionId);
return extensionZone.getBody();
}
Re: Render Queue Error in Expansion
Posted by Chris Mylonas <ch...@opencsta.org>.
Thanks Lance -
I have two problems at the moment - both when I componentize the stuff. On a single page, no probs.
1. Render Queue Error - on AJAX update for Extensions - it gets lost after the initial render because the looping is finished from initial page load (i presume).
2. Which dropzone got the event.
NOTE: Draggable's are OK - I have the draggablecontext to pass.
<Draggable Reception Line> -----gets dropped onto----> <Droppable Extension Zone / Voicemail Zone> (transfer the call)
Currently, If I hard code ALL the drop zones, I know which one got dropped on from @OnEvent(value, component)
Which is fine for a one-off prototype, but I don't want to repackage the app and redeploy on adds/moves/changes to phone system configs. i.e. add 2 extensions. Especially on 5 different sites.
With my component(s), I have the luxury of "dynamic" changes to number of reception lines and extensions - but lose the ability to know which dropzone was triggered. I always know which reception line is doing the transferring because of the draggablecontext.
I'm already getting 1234 was dropped onto ....
I'll give it a shot because I need the ValueEncoder practise - but I don't think it will solve my which-dropzone-received-the-draggable problem.
If it does, I'll eat my goatee :)
Chris
On 13/04/2012, at 11:48 PM, Lance Java wrote:
> Create a ValueEncoder for your currentExtension Object
>
> Then use ValueEncoder.toClient(V value) to create a string which will be
> used in your draggablecontext.
>
> Then, in your drop event, use ValueEncoder.toValue(String value) on the
> context value to deserialise the Object.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Render Queue Error in Expansion
Posted by Lance Java <la...@googlemail.com>.
Create a ValueEncoder for your currentExtension Object
Then use ValueEncoder.toClient(V value) to create a string which will be
used in your draggablecontext.
Then, in your drop event, use ValueEncoder.toValue(String value) on the
context value to deserialise the Object.
Re: Render Queue Error in Expansion
Posted by Chris Mylonas <ch...@opencsta.org>.
I think I need to
@InjectContainer
private MainPage container
Then I can access the "rows" of the grid through the source List<>. (or source list of my entity - phones in this case)
I'll have a look at the in-place-editor for grid because that must do something similar.
Then do something in the beforeRenderTemplate to redraw the AJAX-updated re-render.
On 13/04/2012, at 8:12 PM, Lance Java wrote:
> Your ajax event handler method will need to initialize any properties that
> are required in the rendering block
>
> Draggables can have a "draggablecontext" attribute. Although I've not used
> it I'm sure that you could pass the context required to initialize your
> property.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Render Queue Error in Expansion
Posted by Lance Java <la...@googlemail.com>.
Your ajax event handler method will need to initialize any properties that
are required in the rendering block
Draggables can have a "draggablecontext" attribute. Although I've not used
it I'm sure that you could pass the context required to initialize your
property.