You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Britske <gb...@gmail.com> on 2007/11/28 17:39:30 UTC

T5: problems when extending DateField. More flexibility needed?

Hi, 

I extended datafield to call a defined callback function in javascript.  
like so:

public class MyDateField extends DateField
{
	protected void configure(JSONObject setup)
	{
		setup.put("onUpdate", "callOnUpdate");
		super.configure(setup);
	}
}

This puts a nice javascript into my htmls (see below). However I have 2
issues: 

1. for a callback function to work with the javascript calendar, I need the
text 'callOnUpdate' to be included into the Calendar.setup (see below) 
WITHOUT quotes. However there's no way I see that I have control of
outputting this without quotes. 

2. for the defined funciton (callOnUpdate) to be picked up by the Calendar,
the function must be in the same script-block as where calendar.setup sits.
(At least thats what I conclude after testing this my hand. Im no
javascript-guru). Since this block is rendered by DateField I have no
possibility of writing the function into the block. 

Whatwould be the best way to tackel this? Of course, I could totally hack
around DataField ( I can't extend much since most is package-private) but I
really don't want to.

Cheers, 
Geert-Jan


This is what tapestry does: 
--------------------------------

<script type="text/javascript">
<!--
Event.observe(window, "load", function() {
Tapestry.registerForm('form');
Calendar.setup({"inputField":"a","ifFormat":"%d-%m-%y","button":"a:trigger","onUpdate":"callOnUpdate"});
});
// -->
</script>

what i need:
----------------------------
<script type="text/javascript">
<!--

function callOnUpdate(cal)
{
    	alert('do something here');
}

Event.observe(window, "load", function() {
Tapestry.registerForm('form');
Calendar.setup({inputField:"a",ifFormat:"%d-%m-%y",button:"a:trigger",onUpdate:callOnUpdate});
});
// -->
</script>

-- 
View this message in context: http://www.nabble.com/T5%3A-problems-when-extending-DateField.-More-flexibility-needed--tf4889614.html#a13996007
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: problems when extending DateField. More flexibility needed?

Posted by Howard Lewis Ship <hl...@gmail.com>.
That is a problem; we're seeing a subtle difference between a
JavaScript hash and a JSON object.  What you want to specify is a
hash, because that what's the Calendar wants.  This may require a hack
on JSONObject.


On Nov 28, 2007 8:39 AM, Britske <gb...@gmail.com> wrote:
>
> Hi,
>
> I extended datafield to call a defined callback function in javascript.
> like so:
>
> public class MyDateField extends DateField
> {
>         protected void configure(JSONObject setup)
>         {
>                 setup.put("onUpdate", "callOnUpdate");
>                 super.configure(setup);
>         }
> }
>
> This puts a nice javascript into my htmls (see below). However I have 2
> issues:
>
> 1. for a callback function to work with the javascript calendar, I need the
> text 'callOnUpdate' to be included into the Calendar.setup (see below)
> WITHOUT quotes. However there's no way I see that I have control of
> outputting this without quotes.
>
> 2. for the defined funciton (callOnUpdate) to be picked up by the Calendar,
> the function must be in the same script-block as where calendar.setup sits.
> (At least thats what I conclude after testing this my hand. Im no
> javascript-guru). Since this block is rendered by DateField I have no
> possibility of writing the function into the block.
>
> Whatwould be the best way to tackel this? Of course, I could totally hack
> around DataField ( I can't extend much since most is package-private) but I
> really don't want to.
>
> Cheers,
> Geert-Jan
>
>
> This is what tapestry does:
> --------------------------------
>
> <script type="text/javascript">
> <!--
> Event.observe(window, "load", function() {
> Tapestry.registerForm('form');
> Calendar.setup({"inputField":"a","ifFormat":"%d-%m-%y","button":"a:trigger","onUpdate":"callOnUpdate"});
> });
> // -->
> </script>
>
> what i need:
> ----------------------------
> <script type="text/javascript">
> <!--
>
> function callOnUpdate(cal)
> {
>         alert('do something here');
> }
>
> Event.observe(window, "load", function() {
> Tapestry.registerForm('form');
> Calendar.setup({inputField:"a",ifFormat:"%d-%m-%y",button:"a:trigger",onUpdate:callOnUpdate});
> });
> // -->
> </script>
>
> --
> View this message in context: http://www.nabble.com/T5%3A-problems-when-extending-DateField.-More-flexibility-needed--tf4889614.html#a13996007
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

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


Re: T5: problems when extending DateField. More flexibility needed?

Posted by Britske <gb...@gmail.com>.
OK , I'll do that. 
How about issue 2? 



Andreas Andreou wrote:
> 
> That's the same as
> https://issues.apache.org/jira/browse/TAPESTRY-1795
> only for Tapestry-5... add an issue for it
> 
> On Nov 28, 2007 6:39 PM, Britske <gb...@gmail.com> wrote:
>>
>> Hi,
>>
>> I extended datafield to call a defined callback function in javascript.
>> like so:
>>
>> public class MyDateField extends DateField
>> {
>>         protected void configure(JSONObject setup)
>>         {
>>                 setup.put("onUpdate", "callOnUpdate");
>>                 super.configure(setup);
>>         }
>> }
>>
>> This puts a nice javascript into my htmls (see below). However I have 2
>> issues:
>>
>> 1. for a callback function to work with the javascript calendar, I need
>> the
>> text 'callOnUpdate' to be included into the Calendar.setup (see below)
>> WITHOUT quotes. However there's no way I see that I have control of
>> outputting this without quotes.
>>
>> 2. for the defined funciton (callOnUpdate) to be picked up by the
>> Calendar,
>> the function must be in the same script-block as where calendar.setup
>> sits.
>> (At least thats what I conclude after testing this my hand. Im no
>> javascript-guru). Since this block is rendered by DateField I have no
>> possibility of writing the function into the block.
>>
>> Whatwould be the best way to tackel this? Of course, I could totally hack
>> around DataField ( I can't extend much since most is package-private) but
>> I
>> really don't want to.
>>
>> Cheers,
>> Geert-Jan
>>
>>
>> This is what tapestry does:
>> --------------------------------
>>
>> <script type="text/javascript">
>> <!--
>> Event.observe(window, "load", function() {
>> Tapestry.registerForm('form');
>> Calendar.setup({"inputField":"a","ifFormat":"%d-%m-%y","button":"a:trigger","onUpdate":"callOnUpdate"});
>> });
>> // -->
>> </script>
>>
>> what i need:
>> ----------------------------
>> <script type="text/javascript">
>> <!--
>>
>> function callOnUpdate(cal)
>> {
>>         alert('do something here');
>> }
>>
>> Event.observe(window, "load", function() {
>> Tapestry.registerForm('form');
>> Calendar.setup({inputField:"a",ifFormat:"%d-%m-%y",button:"a:trigger",onUpdate:callOnUpdate});
>> });
>> // -->
>> </script>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-problems-when-extending-DateField.-More-flexibility-needed--tf4889614.html#a13996007
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-problems-when-extending-DateField.-More-flexibility-needed--tf4889614.html#a14022547
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: problems when extending DateField. More flexibility needed?

Posted by Andreas Andreou <an...@gmail.com>.
That's the same as
https://issues.apache.org/jira/browse/TAPESTRY-1795
only for Tapestry-5... add an issue for it

On Nov 28, 2007 6:39 PM, Britske <gb...@gmail.com> wrote:
>
> Hi,
>
> I extended datafield to call a defined callback function in javascript.
> like so:
>
> public class MyDateField extends DateField
> {
>         protected void configure(JSONObject setup)
>         {
>                 setup.put("onUpdate", "callOnUpdate");
>                 super.configure(setup);
>         }
> }
>
> This puts a nice javascript into my htmls (see below). However I have 2
> issues:
>
> 1. for a callback function to work with the javascript calendar, I need the
> text 'callOnUpdate' to be included into the Calendar.setup (see below)
> WITHOUT quotes. However there's no way I see that I have control of
> outputting this without quotes.
>
> 2. for the defined funciton (callOnUpdate) to be picked up by the Calendar,
> the function must be in the same script-block as where calendar.setup sits.
> (At least thats what I conclude after testing this my hand. Im no
> javascript-guru). Since this block is rendered by DateField I have no
> possibility of writing the function into the block.
>
> Whatwould be the best way to tackel this? Of course, I could totally hack
> around DataField ( I can't extend much since most is package-private) but I
> really don't want to.
>
> Cheers,
> Geert-Jan
>
>
> This is what tapestry does:
> --------------------------------
>
> <script type="text/javascript">
> <!--
> Event.observe(window, "load", function() {
> Tapestry.registerForm('form');
> Calendar.setup({"inputField":"a","ifFormat":"%d-%m-%y","button":"a:trigger","onUpdate":"callOnUpdate"});
> });
> // -->
> </script>
>
> what i need:
> ----------------------------
> <script type="text/javascript">
> <!--
>
> function callOnUpdate(cal)
> {
>         alert('do something here');
> }
>
> Event.observe(window, "load", function() {
> Tapestry.registerForm('form');
> Calendar.setup({inputField:"a",ifFormat:"%d-%m-%y",button:"a:trigger",onUpdate:callOnUpdate});
> });
> // -->
> </script>
>
> --
> View this message in context: http://www.nabble.com/T5%3A-problems-when-extending-DateField.-More-flexibility-needed--tf4889614.html#a13996007
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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