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 18:18:57 UTC

how to get component event source?

Fresh Request now that we have a simple question (re: subject line).

Here is the template for my component (a PhoneExtension) - it receives a phone call.

<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.number} ${currentExtension.name} (note: these values are null on AJAX refresh)
		</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>


It has 2 Zones for dropping objects into (jquery drag and drop).  I can't identify which out of 10 of these gets the drop because all id are either extensionZone or voicemailZone.

My page template uses this phone component like this (the receptionist (with a draggable component) drops the calls onto the PhoneExtensions):

	<div id="reception-lines">
		<t:ReceptionLine source="trunks" value="currentTrunk" />
	</div>
	
	<div id="office-phones">
 		<t:PhoneExtension source="extensions" value="currentExtension" />
 	</div>

If it's time to go back to the drawing board with it and use MarkupWriter...then so be it!!

Any help is great,
Cheers
Chris

P.S. It's 2 am - I'm going to sleep.

Re: how to get component event source?

Posted by Chris Mylonas <ch...@opencsta.org>.
oh stop it, you big tease :D

Let's just leave it on idle for a bit - i've got what i want out of @ImportJQueryUI stuff and my own custom JS (i used to detest js back before these handy js-toolkits came about - times have changed...)
For my own prototyping, I'll be needing to possibly make update-able _all_ zones - so that will give me a fair intro into tapestry ajax updates / json etc.

It's a good test of patience all this this AJAX deving caper, but not as good as untangling 100m of rope in a small space!

It's all good timing though - tapestry5-jquery rocks...jumpstart with some fresh ajax stuff to check out.  has never been a better time for java web deving.

Cheers
Chris


On 16/04/2012, at 8:53 PM, Lance Java wrote:

> Now I'm starting to doubt myself, I'm starting to think that the @Parameter
> will be null when the ajax method is invoked.
> 
> You will need to pass the droppablecontext in the AJAX event URL in a
> similar way to how the draggablecontext is passed.
> 
> https://github.com/got5/tapestry5-jquery/blob/master/src/main/resources/org/got5/tapestry5/jquery/assets/mixins/zonedroppable/zonedroppable.js
> 
> Perhaps this is back in the too-hard-basket. Sorry for the tease


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


Re: how to get component event source?

Posted by Lance Java <la...@googlemail.com>.
Now I'm starting to doubt myself, I'm starting to think that the @Parameter
will be null when the ajax method is invoked.

You will need to pass the droppablecontext in the AJAX event URL in a
similar way to how the draggablecontext is passed.

https://github.com/got5/tapestry5-jquery/blob/master/src/main/resources/org/got5/tapestry5/jquery/assets/mixins/zonedroppable/zonedroppable.js

Perhaps this is back in the too-hard-basket. Sorry for the tease

Re: how to get component event source?

Posted by Chris Mylonas <ch...@opencsta.org>.
Geez Lance, thanks for checking it out further, hope you had a pleasant weekend.

Are you serious with that's all that has to happen + a parameter i guess?
I read the source code and was tempted by it's length - and yes it doesn't look too hard, but you've seriously taken it to easy-ville!!
Especially by tacking on the droppable context like that...

For my own prototyping (not the js library) I have gone back down my custom js path.

I'm yet to fully comprehend where I can go by implementing the zonedroppable context - or whether I just stick to custom js.
Thanks heaps for your follow up, I will sit on it for a day or two whilst I muck around with some related code :)

Chris

On 16/04/2012, at 7:13 PM, Lance Java wrote:

> Hi Chris, the ZoneDroppable mixin is only a few lines of code
> https://github.com/got5/tapestry5-jquery/blob/master/src/main/java/org/got5/tapestry5/jquery/mixins/ZoneDroppable.java
> 
> You could quite easily create another mixin by copying/tweaking the code or
> better yet, clone the repository and send a pull request to the author :)
> 
> The following line is what fires the AJAX event on your page
>   resources.triggerEvent(JQueryEventConstants.DROP, context, callback);
> 
> You could change the line of code to something like:
>   Object[] concatenatedContext = concatenateArrays(context,
> this.droppablecontext);
>  resources.triggerEvent(JQueryEventConstants.DROP, concatenatedContext,
> callback);
> 
> Cheers,
> Lance.


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


how to get component event source?

Posted by Lance Java <la...@googlemail.com>.
Hi Chris, the ZoneDroppable mixin is only a few lines of code
https://github.com/got5/tapestry5-jquery/blob/master/src/main/java/org/got5/tapestry5/jquery/mixins/ZoneDroppable.java

You could quite easily create another mixin by copying/tweaking the code or
better yet, clone the repository and send a pull request to the author :)

The following line is what fires the AJAX event on your page
   resources.triggerEvent(JQueryEventConstants.DROP, context, callback);

You could change the line of code to something like:
   Object[] concatenatedContext = concatenateArrays(context,
this.droppablecontext);
  resources.triggerEvent(JQueryEventConstants.DROP, concatenatedContext,
callback);

Cheers,
Lance.

Re: how to get component event source?

Posted by Chris Mylonas <ch...@opencsta.org>.
I agree with you there on droppablecontext!!!  We would have saved 20 emails and 20 hours!
The draggable is a component and it's easy for my novice eyes to see it's @Parameter.

The droppable though is a mixin for a Zone.  I thought about trying to add my own droppable context, but at this stage it's in the too hard basket - given I'd also have to screw around with the AJAX-y part.

I did however get my old custom jquery code to work with standard @ImportJQueryUI stuff.  The previous week I was doing it this way but had a problem because jquery.ui.mouse was not in the import statement and then was in the wrong order - which led me to the template based way of doing it because there was no drag-age or drop-age :(  - but this is working now :)

Going back has helped me do my things the way I had sussed out last year with jquery.  At least the steps for going down my own AJAX component seem easier going by the "look at the auto complete component source code" as suggested at the bottom of this page - https://tapestry.apache.org/ajax-and-zones.html
I can do that I think.   I took the afternoon to fix some real world things around the joint :)

The most of the examples from jqueryui.com I tested work @ImportJQueryUI with custom js - i.e. effects, accordion, dragndrop




On 14/04/2012, at 6:06 PM, Lance Java wrote:

> If the URL is the same then the zone id is the same. Im guessing that your
> droppables are defined in a loop too? (I'm talking t:id not client id)
> 
> I think that the droppable mixin needs to accept a droppablecontext in a
> similar way to draggablecontext and the serverside event should have both
> contexts passed to it
> 
> My 2p


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


Re: how to get component event source?

Posted by Lance Java <la...@googlemail.com>.
If the URL is the same then the zone id is the same. Im guessing that your
droppables are defined in a loop too? (I'm talking t:id not client id)

I think that the droppable mixin needs to accept a droppablecontext in a
similar way to draggablecontext and the serverside event should have both
contexts passed to it

My 2p

Re: how to get component event source?

Posted by Chris Mylonas <ch...@opencsta.org>.
Good morning - thanks for the candid comments, they are welcome :D

Hacky it is.   The URL generated is the same for each component.  So I'll look at what Thiago suggested by passing a query parameter.
Or just let the code sit there ready to tackle it the next release :)

Cheers
Chris

On 14/04/2012, at 7:39 AM, Thiago H. de Paula Figueiredo wrote:

> On Fri, 13 Apr 2012 17:15:13 -0300, Lance Java <la...@googlemail.com> wrote:
> 
>> Well... to say it's not possible is wrong. To say it's hacky is correct ;)
> 
> Yep, that's right. I'd say Tapestry itself doesn't provide the source of the event, but you can try to figure that out by looking at the URL. :)


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


Re: how to get component event source?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 13 Apr 2012 17:15:13 -0300, Lance Java <la...@googlemail.com>  
wrote:

> Well... to say it's not possible is wrong. To say it's hacky is correct  
> ;)

Yep, that's right. I'd say Tapestry itself doesn't provide the source of  
the event, but you can try to figure that out by looking at the URL. :)

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


Re: how to get component event source?

Posted by Lance Java <la...@googlemail.com>.
Well... to say it's not possible is wrong. To say it's hacky is correct ;)

He's using a library which doesn't pass the information and might not want
to wait for a new release of the library

The information is there... Worst case scenario you could @Inject the
request and parse the component id from the URL.

Re: how to get component event source?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Answer to the question is the subject: there's no way to do that.

On the other hand, you can add a query parameter to your AJAX request with  
the information of which client-side object triggered it.

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