You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Stopp, Bryan" <Br...@argushealth.com> on 2008/12/17 17:08:32 UTC

Tapestry 4.1 Widget

All,
  I've been working on this for a while and i can't seem to get it. 
 
I'm trying to create a tree structure in my application. I have re-used
what i could from the tapestry-contrib project, however it doesn't have
the same capabilities and/or look&feel that we are going for. So instead
i worked out my own. I have most of it working except I can't get the
AJAX widget functionality to work. 
 
The tree is designed as a hierarchy of UnorderedLists (<ul>) wich each
node being a List Item (<li>). So I created a class, ListItemWidget,
which is meant to have an on-click function to expand/collapse itself.
It extends Abstract Widget and implements IDirect. However my problem
isn't in this definition, it's in creating the script to bind into the
class to activate this component's "trigger" method. 
 
Below is the script file i have created. I have tried using the exist
Dojo components in Tapestry as an example, but i'm almost certain that
they work because Dojo has a built-in type associated with each
(Tapestry "Autocompleter" = Dojo "Select"). So i'm thinking that i am
missing something. Any kind of help would be really appreciated. I hope
to contribute it back to the contrib project if i can cleaned up and get
it working properly. Thanks all!
 
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE script PUBLIC

"-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"

"http://tapestry.apache.org/dtd/Script_3_0.dtd">

<script>

<input-symbol key="component" required="yes"/>

<input-symbol key="treeViewId" required="yes"/>

<input-symbol key="props" required="yes" />

<let key="listItem" unique="yes">listItem</let>

<let key="funcName" unique="yes">toggleNode</let>

<body>

<unique>dojo.require("tapestry.widget.Widget")</unique>

</body>

<initialization>

tapestry.widget.synchronizeWidgetState("${component.clientId}",
"Widget", ${props}, ${component.destroy});

var ${listItem} = dojo.widget.byId("${component.clientId}");

${listItem}.onClick=${funcName};

</initialization>

</script>

 

-Bryan 

 

 

PRIVILEGED AND CONFIDENTIAL
This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  If the reader of the email is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any use, dissemination or copying of this email transmission is strictly prohibited by the sender.  If you have received this transmission in error, please delete the email and immediately notify the sender via the email return address or mailto:postmaster@argushealth.com.  Thank you.




Re: Tapestry 4.1 Widget

Posted by otto95 <Ri...@gmail.com>.
Thanks for your willingness to help.

My Direct link looks like this:

JSON Test 

Where LuceneFieldData is the name of my component. It implements IJSONRender
and has a renderComponent method that uses a IJSONWriter.

The RawUrlLinkRenderer throws a class cannot be found exception. I'm
guessing this is in a jar other than tapestry framework?

When removing the renderer parameter I get an exception that the Direct Link
expects a Listener. What should I provide?

Thanks.

Rich Hephner



Andreas Andreou-2 wrote:
> 
> Just get the url of a directlink by any of the following:
> - Render a hidden direct link and get it's href, or
> - Render a direct link and set the renderer parameter to
> http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/contrib/link/RawURLLinkRenderer.html
> - or, generate the link with code (see how direct service/link does it
> - you component would have
> to implement IDirect)
> 
> 
> On Tue, Jan 20, 2009 at 6:28 PM, otto95 <Ri...@gmail.com> wrote:
>>
>> I'm sorry for coming to this conversation late, but I have exactly the
>> same
>> issue. I'd like to do as you suggest, but how do you get the url for a
>> component?
>>
>> I have a component that implements IJSONRender, but I can't figure out
>> how
>> to access it through a browser to get it's json output. Do I have to
>> include
>> it in something?
>>
>> Thanks.
>>
>> Rich Hephner
>>
>>
>> Andreas Andreou-2 wrote:
>>>
>>> Check out dojo sources: the ComboBox widget and the dojo.io.bind calls
>>>
>>> So, if you have a url, you can do something like:
>>>
>>> dojo.io.bind({url:url,load:myFunction,mimetype:"text/json"});
>>>
>>> and process the results in your function the way you like. Those
>>> results are the ones
>>> that renderComponent(IJSONWriter writer, IRequestCycle cycle)
>>> generates becuase of the
>>> text/json mimetype
>>>
>>> On Wed, Dec 17, 2008 at 8:56 PM, Stopp, Bryan
>>> <Br...@argushealth.com> wrote:
>>>> So I mis-represented my problem in my first post. What I'm really
>>>> trying
>>>> to do is:
>>>>
>>>> 1. Add an onclick() function to a component, which triggers a
>>>> server-side method
>>>> 2. Refresh another component on the page when the onclick has
>>>> completed.
>>>>
>>>> All of this is for T4.1 by the way.
>>>>
>>>> I selected using the IDirect interface and generating a URL for the
>>>> onclick method to call. However I don't know how to make tapestry/dojo
>>>> call to that URL, nor how to tell tapestry to refresh the other
>>>> component.
>>>>
>>>> I don't believe I can use a @EventListener as each component has a
>>>> generated ClientID and according to the spec the "targets" attribute of
>>>> this annotation has to have a unique ID.
>>>>
>>>> I've been trying to look at the existing Dojo examples but they and the
>>>> documentation aren't of much help. Does anyone have any examples of
>>>> components/widgets similar to this?
>>>>
>>>>
>>>>
>>>>
>>>> -Bryan Stopp
>>>>
>>>> PRIVILEGED AND CONFIDENTIAL
>>>> This email transmission contains privileged and confidential
>>>> information
>>>> intended only for the use of the individual or entity named above.  If
>>>> the reader of the email is not the intended recipient or the employee
>>>> or
>>>> agent responsible for delivering it to the intended recipient, you are
>>>> hereby notified that any use, dissemination or copying of this email
>>>> transmission is strictly prohibited by the sender.  If you have
>>>> received
>>>> this transmission in error, please delete the email and immediately
>>>> notify the sender via the email return address or
>>>> mailto:postmaster@argushealth.com.  Thank you.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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://n2.nabble.com/Tapestry-4.1-Widget-tp1668522p2187365.html
>> Sent from the Tapestry Users 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://n2.nabble.com/Tapestry-4.1-Widget-tp1668522p2192339.html
Sent from the Tapestry Users 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: Tapestry 4.1 Widget

Posted by Andreas Andreou <an...@di.uoa.gr>.
Just get the url of a directlink by any of the following:
- Render a hidden direct link and get it's href, or
- Render a direct link and set the renderer parameter to
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/contrib/link/RawURLLinkRenderer.html
- or, generate the link with code (see how direct service/link does it
- you component would have
to implement IDirect)


On Tue, Jan 20, 2009 at 6:28 PM, otto95 <Ri...@gmail.com> wrote:
>
> I'm sorry for coming to this conversation late, but I have exactly the same
> issue. I'd like to do as you suggest, but how do you get the url for a
> component?
>
> I have a component that implements IJSONRender, but I can't figure out how
> to access it through a browser to get it's json output. Do I have to include
> it in something?
>
> Thanks.
>
> Rich Hephner
>
>
> Andreas Andreou-2 wrote:
>>
>> Check out dojo sources: the ComboBox widget and the dojo.io.bind calls
>>
>> So, if you have a url, you can do something like:
>>
>> dojo.io.bind({url:url,load:myFunction,mimetype:"text/json"});
>>
>> and process the results in your function the way you like. Those
>> results are the ones
>> that renderComponent(IJSONWriter writer, IRequestCycle cycle)
>> generates becuase of the
>> text/json mimetype
>>
>> On Wed, Dec 17, 2008 at 8:56 PM, Stopp, Bryan
>> <Br...@argushealth.com> wrote:
>>> So I mis-represented my problem in my first post. What I'm really trying
>>> to do is:
>>>
>>> 1. Add an onclick() function to a component, which triggers a
>>> server-side method
>>> 2. Refresh another component on the page when the onclick has completed.
>>>
>>> All of this is for T4.1 by the way.
>>>
>>> I selected using the IDirect interface and generating a URL for the
>>> onclick method to call. However I don't know how to make tapestry/dojo
>>> call to that URL, nor how to tell tapestry to refresh the other
>>> component.
>>>
>>> I don't believe I can use a @EventListener as each component has a
>>> generated ClientID and according to the spec the "targets" attribute of
>>> this annotation has to have a unique ID.
>>>
>>> I've been trying to look at the existing Dojo examples but they and the
>>> documentation aren't of much help. Does anyone have any examples of
>>> components/widgets similar to this?
>>>
>>>
>>>
>>>
>>> -Bryan Stopp
>>>
>>> PRIVILEGED AND CONFIDENTIAL
>>> This email transmission contains privileged and confidential information
>>> intended only for the use of the individual or entity named above.  If
>>> the reader of the email is not the intended recipient or the employee or
>>> agent responsible for delivering it to the intended recipient, you are
>>> hereby notified that any use, dissemination or copying of this email
>>> transmission is strictly prohibited by the sender.  If you have received
>>> this transmission in error, please delete the email and immediately
>>> notify the sender via the email return address or
>>> mailto:postmaster@argushealth.com.  Thank you.
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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://n2.nabble.com/Tapestry-4.1-Widget-tp1668522p2187365.html
> Sent from the Tapestry Users 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


Re: Tapestry 4.1 Widget

Posted by otto95 <Ri...@gmail.com>.
I'm sorry for coming to this conversation late, but I have exactly the same
issue. I'd like to do as you suggest, but how do you get the url for a
component?

I have a component that implements IJSONRender, but I can't figure out how
to access it through a browser to get it's json output. Do I have to include
it in something?

Thanks.

Rich Hephner


Andreas Andreou-2 wrote:
> 
> Check out dojo sources: the ComboBox widget and the dojo.io.bind calls
> 
> So, if you have a url, you can do something like:
> 
> dojo.io.bind({url:url,load:myFunction,mimetype:"text/json"});
> 
> and process the results in your function the way you like. Those
> results are the ones
> that renderComponent(IJSONWriter writer, IRequestCycle cycle)
> generates becuase of the
> text/json mimetype
> 
> On Wed, Dec 17, 2008 at 8:56 PM, Stopp, Bryan
> <Br...@argushealth.com> wrote:
>> So I mis-represented my problem in my first post. What I'm really trying
>> to do is:
>>
>> 1. Add an onclick() function to a component, which triggers a
>> server-side method
>> 2. Refresh another component on the page when the onclick has completed.
>>
>> All of this is for T4.1 by the way.
>>
>> I selected using the IDirect interface and generating a URL for the
>> onclick method to call. However I don't know how to make tapestry/dojo
>> call to that URL, nor how to tell tapestry to refresh the other
>> component.
>>
>> I don't believe I can use a @EventListener as each component has a
>> generated ClientID and according to the spec the "targets" attribute of
>> this annotation has to have a unique ID.
>>
>> I've been trying to look at the existing Dojo examples but they and the
>> documentation aren't of much help. Does anyone have any examples of
>> components/widgets similar to this?
>>
>>
>>
>>
>> -Bryan Stopp
>>
>> PRIVILEGED AND CONFIDENTIAL
>> This email transmission contains privileged and confidential information
>> intended only for the use of the individual or entity named above.  If
>> the reader of the email is not the intended recipient or the employee or
>> agent responsible for delivering it to the intended recipient, you are
>> hereby notified that any use, dissemination or copying of this email
>> transmission is strictly prohibited by the sender.  If you have received
>> this transmission in error, please delete the email and immediately
>> notify the sender via the email return address or
>> mailto:postmaster@argushealth.com.  Thank you.
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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://n2.nabble.com/Tapestry-4.1-Widget-tp1668522p2187365.html
Sent from the Tapestry Users 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: Tapestry 4.1 Widget

Posted by Andreas Andreou <an...@di.uoa.gr>.
Check out dojo sources: the ComboBox widget and the dojo.io.bind calls

So, if you have a url, you can do something like:

dojo.io.bind({url:url,load:myFunction,mimetype:"text/json"});

and process the results in your function the way you like. Those
results are the ones
that renderComponent(IJSONWriter writer, IRequestCycle cycle)
generates becuase of the
text/json mimetype

On Wed, Dec 17, 2008 at 8:56 PM, Stopp, Bryan
<Br...@argushealth.com> wrote:
> So I mis-represented my problem in my first post. What I'm really trying
> to do is:
>
> 1. Add an onclick() function to a component, which triggers a
> server-side method
> 2. Refresh another component on the page when the onclick has completed.
>
> All of this is for T4.1 by the way.
>
> I selected using the IDirect interface and generating a URL for the
> onclick method to call. However I don't know how to make tapestry/dojo
> call to that URL, nor how to tell tapestry to refresh the other
> component.
>
> I don't believe I can use a @EventListener as each component has a
> generated ClientID and according to the spec the "targets" attribute of
> this annotation has to have a unique ID.
>
> I've been trying to look at the existing Dojo examples but they and the
> documentation aren't of much help. Does anyone have any examples of
> components/widgets similar to this?
>
>
>
>
> -Bryan Stopp
>
> PRIVILEGED AND CONFIDENTIAL
> This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  If the reader of the email is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any use, dissemination or copying of this email transmission is strictly prohibited by the sender.  If you have received this transmission in error, please delete the email and immediately notify the sender via the email return address or mailto:postmaster@argushealth.com.  Thank you.
>
>
>
>
>
> ---------------------------------------------------------------------
> 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


RE: Tapestry 4.1 Widget

Posted by "Stopp, Bryan" <Br...@argushealth.com>.
So I mis-represented my problem in my first post. What I'm really trying
to do is:

1. Add an onclick() function to a component, which triggers a
server-side method 
2. Refresh another component on the page when the onclick has completed.

All of this is for T4.1 by the way.

I selected using the IDirect interface and generating a URL for the
onclick method to call. However I don't know how to make tapestry/dojo
call to that URL, nor how to tell tapestry to refresh the other
component.

I don't believe I can use a @EventListener as each component has a
generated ClientID and according to the spec the "targets" attribute of
this annotation has to have a unique ID. 

I've been trying to look at the existing Dojo examples but they and the
documentation aren't of much help. Does anyone have any examples of
components/widgets similar to this?




-Bryan Stopp

PRIVILEGED AND CONFIDENTIAL
This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  If the reader of the email is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any use, dissemination or copying of this email transmission is strictly prohibited by the sender.  If you have received this transmission in error, please delete the email and immediately notify the sender via the email return address or mailto:postmaster@argushealth.com.  Thank you.





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


Re: Tapestry 4.1 Widget

Posted by Andreas Andreou <an...@di.uoa.gr>.
it doesn't seem that you have a custom dojo widget in place that would
justify using
AbstractWidget + the initialization script you showed.

If you do have a dojo widget, the easiest way to tie it to tapestry IMHO is
http://tacos.sourceforge.net/tacos4.1/components/dojo/DojoWidget.html

If you don't, there's already a tree component that works similarly as
you describe (generating similar markup):
http://tacos.sourceforge.net/tacos4.1/tacos-core/tapdocs/net.sf.tacos.Tacos/Tree/index.html

If you want to keep with your solution, i'd just change the .script
file you have into:
<initialization>
dojo.event.connect(dojo.byId("${component.clientId}"), "onclick", ${funcName});
</initialization>

or similar variations...

On Wed, Dec 17, 2008 at 6:08 PM, Stopp, Bryan
<Br...@argushealth.com> wrote:
> All,
>  I've been working on this for a while and i can't seem to get it.
>
> I'm trying to create a tree structure in my application. I have re-used
> what i could from the tapestry-contrib project, however it doesn't have
> the same capabilities and/or look&feel that we are going for. So instead
> i worked out my own. I have most of it working except I can't get the
> AJAX widget functionality to work.
>
> The tree is designed as a hierarchy of UnorderedLists (<ul>) wich each
> node being a List Item (<li>). So I created a class, ListItemWidget,
> which is meant to have an on-click function to expand/collapse itself.
> It extends Abstract Widget and implements IDirect. However my problem
> isn't in this definition, it's in creating the script to bind into the
> class to activate this component's "trigger" method.
>
> Below is the script file i have created. I have tried using the exist
> Dojo components in Tapestry as an example, but i'm almost certain that
> they work because Dojo has a built-in type associated with each
> (Tapestry "Autocompleter" = Dojo "Select"). So i'm thinking that i am
> missing something. Any kind of help would be really appreciated. I hope
> to contribute it back to the contrib project if i can cleaned up and get
> it working properly. Thanks all!
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE script PUBLIC
>
> "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
>
> "http://tapestry.apache.org/dtd/Script_3_0.dtd">
>
> <script>
>
> <input-symbol key="component" required="yes"/>
>
> <input-symbol key="treeViewId" required="yes"/>
>
> <input-symbol key="props" required="yes" />
>
> <let key="listItem" unique="yes">listItem</let>
>
> <let key="funcName" unique="yes">toggleNode</let>
>
> <body>
>
> <unique>dojo.require("tapestry.widget.Widget")</unique>
>
> </body>
>
> <initialization>
>
> tapestry.widget.synchronizeWidgetState("${component.clientId}",
> "Widget", ${props}, ${component.destroy});
>
> var ${listItem} = dojo.widget.byId("${component.clientId}");
>
> ${listItem}.onClick=${funcName};
>
> </initialization>
>
> </script>
>
>
>
> -Bryan
>
>
>
>
>
> PRIVILEGED AND CONFIDENTIAL
> This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  If the reader of the email is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any use, dissemination or copying of this email transmission is strictly prohibited by the sender.  If you have received this transmission in error, please delete the email and immediately notify the sender via the email return address or mailto:postmaster@argushealth.com.  Thank you.
>
>
>
>



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