You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Greg Lappen <gr...@lapcominc.com> on 2004/12/16 16:11:55 UTC
When to use script specification?
Hello-
Trying to get my head around script specifications. Is it true that
they are used mainly for when you are writing a component that has
javascript? I have a form in which I want to enable/disable one of the
fields based on the state of another field. The fields are both
PropertySelections, no custom components. It seems like the most
straightforward way to do it is to assign id's to both
PropertySelections and access the objects in javascript using
document.getElementByID to disable or enable it. If I do this, will it
adversely affect the form rewind or anything else?
Thanks,
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: When to use script specification?
Posted by Greg Lappen <gr...@lapcominc.com>.
Awesome, that was just what I needed. This makes scripts totally
reusable which is really cool.
Thanks!
Greg
On Dec 16, 2004, at 4:19 PM, Danny Mandel wrote:
> Here's a really simple example that adds to the document's onload so
> that a page will jump to a selected anchor:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE script PUBLIC
> "-//Apache Software Foundation//Tapestry Script Specification
> 3.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">
> <script>
> <!-- the anchor name in the document to jump to -->
> <input-symbol key="anchor" class="java.lang.String" required="yes"/>
> <!-- putting this code inside of the initialization tag causes it to
> be added to the body's onload() function -->
> <initialization>
> <!-- the use of the ${anchor} substitutes the value passed in for
> anchor into the quotes -->
> document.location='#${anchor}';
> </initialization>
> </script>
>
>
> Then to use this in a page, all you do is say:
>
> <!-- this works assuming you have a method called selectedAnchor in
> your class -->
> <script jwcid="@Script" script="JumpToAnchor.script"
> anchor="ognl:selectedAnchor"/>
>
> Hope that helps,
> Danny
>
> Greg Lappen wrote:
>
>> Yeah, I too suffer from fear of the script specification. The
>> examples in "Tapestry in Action" seem to involve custom components
>> (granted my page is custom component) and I'm not sure how to use a
>> script specification. Do I just create my reusable script and call
>> it from my page? And how do include it - do I override
>> renderComponent in my page like the examples and call the script
>> there?
>>
>> Actually, any examples of this in action would be awesome as this is
>> one thing that is currently murky still in my understanding of
>> Tapestry.
>>
>> Thanks,
>>
>> Greg
>> On Dec 16, 2004, at 10:41 AM, Danny Mandel wrote:
>>
>>> My personal experience with the script specification is that it's
>>> best to use it except for the most trivial of situations. I was
>>> able to get javascript working without using it, but most javascript
>>> of more than one line of complexity will benefit from using the
>>> Script specification.
>>> My hacked code inevitably become a pain to manage and I spent more
>>> time rewriting it later than if I would have taken the time to do it
>>> right in the first place.
>>>
>>> In your case, it also sounds like this could have a good probability
>>> of being a highly reusable script as the disabling of one field
>>> based on the value of another is something that can happen in a
>>> number of different cases.
>>>
>>> Hope that helps,
>>> Danny
>>>
>>> Greg Lappen wrote:
>>>
>>>> Hello-
>>>>
>>>>
>>>> Trying to get my head around script specifications. Is it true
>>>> that they are used mainly for when you are writing a component that
>>>> has javascript? I have a form in which I want to enable/disable
>>>> one of the fields based on the state of another field. The fields
>>>> are both PropertySelections, no custom components. It seems like
>>>> the most straightforward way to do it is to assign id's to both
>>>> PropertySelections and access the objects in javascript using
>>>> document.getElementByID to disable or enable it. If I do this,
>>>> will it adversely affect the form rewind or anything else?
>>>>
>>>> Thanks,
>>>>
>>>> Greg
>>>>
>>>>
>>>> --------------------------------------------------------------------
>>>> -
>>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail:
>>>> tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail:
>>> tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: When to use script specification?
Posted by Danny Mandel <dm...@tolweb.org>.
Here's a really simple example that adds to the document's onload so
that a page will jump to a selected anchor:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script PUBLIC
"-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">
<script>
<!-- the anchor name in the document to jump to -->
<input-symbol key="anchor" class="java.lang.String" required="yes"/>
<!-- putting this code inside of the initialization tag causes it to be
added to the body's onload() function -->
<initialization>
<!-- the use of the ${anchor} substitutes the value passed in for anchor
into the quotes -->
document.location='#${anchor}';
</initialization>
</script>
Then to use this in a page, all you do is say:
<!-- this works assuming you have a method called selectedAnchor in your
class -->
<script jwcid="@Script" script="JumpToAnchor.script"
anchor="ognl:selectedAnchor"/>
Hope that helps,
Danny
Greg Lappen wrote:
> Yeah, I too suffer from fear of the script specification. The
> examples in "Tapestry in Action" seem to involve custom components
> (granted my page is custom component) and I'm not sure how to use a
> script specification. Do I just create my reusable script and call it
> from my page? And how do include it - do I override renderComponent
> in my page like the examples and call the script there?
>
> Actually, any examples of this in action would be awesome as this is
> one thing that is currently murky still in my understanding of Tapestry.
>
> Thanks,
>
> Greg
> On Dec 16, 2004, at 10:41 AM, Danny Mandel wrote:
>
>> My personal experience with the script specification is that it's
>> best to use it except for the most trivial of situations. I was able
>> to get javascript working without using it, but most javascript of
>> more than one line of complexity will benefit from using the Script
>> specification.
>> My hacked code inevitably become a pain to manage and I spent more
>> time rewriting it later than if I would have taken the time to do it
>> right in the first place.
>>
>> In your case, it also sounds like this could have a good probability
>> of being a highly reusable script as the disabling of one field based
>> on the value of another is something that can happen in a number of
>> different cases.
>>
>> Hope that helps,
>> Danny
>>
>> Greg Lappen wrote:
>>
>>> Hello-
>>>
>>>
>>> Trying to get my head around script specifications. Is it true that
>>> they are used mainly for when you are writing a component that has
>>> javascript? I have a form in which I want to enable/disable one of
>>> the fields based on the state of another field. The fields are both
>>> PropertySelections, no custom components. It seems like the most
>>> straightforward way to do it is to assign id's to both
>>> PropertySelections and access the objects in javascript using
>>> document.getElementByID to disable or enable it. If I do this, will
>>> it adversely affect the form rewind or anything else?
>>>
>>> Thanks,
>>>
>>> Greg
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: When to use script specification?
Posted by Greg Lappen <gr...@lapcominc.com>.
Yeah, I too suffer from fear of the script specification. The examples
in "Tapestry in Action" seem to involve custom components (granted my
page is custom component) and I'm not sure how to use a script
specification. Do I just create my reusable script and call it from my
page? And how do include it - do I override renderComponent in my page
like the examples and call the script there?
Actually, any examples of this in action would be awesome as this is
one thing that is currently murky still in my understanding of
Tapestry.
Thanks,
Greg
On Dec 16, 2004, at 10:41 AM, Danny Mandel wrote:
> My personal experience with the script specification is that it's best
> to use it except for the most trivial of situations. I was able to
> get javascript working without using it, but most javascript of more
> than one line of complexity will benefit from using the Script
> specification.
> My hacked code inevitably become a pain to manage and I spent more
> time rewriting it later than if I would have taken the time to do it
> right in the first place.
>
> In your case, it also sounds like this could have a good probability
> of being a highly reusable script as the disabling of one field based
> on the value of another is something that can happen in a number of
> different cases.
>
> Hope that helps,
> Danny
>
> Greg Lappen wrote:
>
>> Hello-
>>
>>
>> Trying to get my head around script specifications. Is it true that
>> they are used mainly for when you are writing a component that has
>> javascript? I have a form in which I want to enable/disable one of
>> the fields based on the state of another field. The fields are both
>> PropertySelections, no custom components. It seems like the most
>> straightforward way to do it is to assign id's to both
>> PropertySelections and access the objects in javascript using
>> document.getElementByID to disable or enable it. If I do this, will
>> it adversely affect the form rewind or anything else?
>>
>> Thanks,
>>
>> Greg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: When to use script specification?
Posted by Danny Mandel <dm...@tolweb.org>.
My personal experience with the script specification is that it's best
to use it except for the most trivial of situations. I was able to get
javascript working without using it, but most javascript of more than
one line of complexity will benefit from using the Script specification.
My hacked code inevitably become a pain to manage and I spent more time
rewriting it later than if I would have taken the time to do it right in
the first place.
In your case, it also sounds like this could have a good probability of
being a highly reusable script as the disabling of one field based on
the value of another is something that can happen in a number of
different cases.
Hope that helps,
Danny
Greg Lappen wrote:
> Hello-
>
>
> Trying to get my head around script specifications. Is it true that
> they are used mainly for when you are writing a component that has
> javascript? I have a form in which I want to enable/disable one of
> the fields based on the state of another field. The fields are both
> PropertySelections, no custom components. It seems like the most
> straightforward way to do it is to assign id's to both
> PropertySelections and access the objects in javascript using
> document.getElementByID to disable or enable it. If I do this, will
> it adversely affect the form rewind or anything else?
>
> Thanks,
>
> Greg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: When to use script specification?
Posted by Danny Mandel <dm...@tolweb.org>.
Hi, the short answer is: yes it sounds possible to do what you want
without using a script specification.
The long answer is, it's probably a better idea to do it with a script
specification. When I was first learning Tapestry the script
specification frightened me, and I chose to write manual javascript with
a delegate in a Shell component for some relatively simple tasks.
Gradually these tasks arose in more places and became more complex, and
I ended up learning how to use the script specification to save my
implementation from becoming a complete hack.
While it is not trivial to learn, you will probably save time, effort,
and frustration in the long run if you learn to use the script
specification right now. It is truly an elegant implementation and is
useful in a variety of situations (not just for components with javascript).
Danny
Greg Lappen wrote:
> Hello-
>
>
> Trying to get my head around script specifications. Is it true that
> they are used mainly for when you are writing a component that has
> javascript? I have a form in which I want to enable/disable one of
> the fields based on the state of another field. The fields are both
> PropertySelections, no custom components. It seems like the most
> straightforward way to do it is to assign id's to both
> PropertySelections and access the objects in javascript using
> document.getElementByID to disable or enable it. If I do this, will
> it adversely affect the form rewind or anything else?
>
> Thanks,
>
> Greg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org