You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kalle Korhonen <ka...@gmail.com> on 2007/12/01 18:45:56 UTC

T4: From the client side, how do you programmatically update a component?

I have a use case where I need to "click on" a directllink to
updatecomponents with async=true or do an equivalent action in Javascript. I
know I can do tapestry.bind('<span jwcid=@DirectLink.../>') and it makes
some sense, but looks rather ugly. Any cleaner way to accomplish this?

Kalle

Re: T4: From the client side, how do you programmatically update a component?

Posted by Kalle Korhonen <ka...@gmail.com>.
Yeap, thanks Igor. I like the idea of calling the script with a parameter,
but overall a bit much compared to the one-liner on the client side, as ugly
as it may be. Adding such a component to the contrib lib or tacos might make
sense though. I'd think others might have similar needs.

Kalle


On 12/3/07, Igor Drobiazko <ig...@gmail.com> wrote:
>
> Hi,
>
> you you can do following:
>
> -your component should implement the interface IDirect
> -create a link:
>       public ILink getLink(){
>           return getDirectService().getLink(false, new
> DirectServiceParameter(this));
>       }
>
> - and pass the url of the link as a parameter to your Script
>             Map params = new HashMap();
>             params.put("url", getLink().getURL());
>             PageRenderSupport pageRenderSupport =
> TapestryUtils.getPageRenderSupport(cycle, this);
>             getScript().execute(this, cycle, pageRenderSupport, params);
> - call the url in your script
> <script>
>     <input-symbol key="url" required="yes" />
>     <body>
>         <unique>
>             foo =function(){
>                 tapestry.bind("${url}", ........);
>             }
>         </unique>
>     </body>
> </script>
>
> - update the components in you trigger() method:
>         public void trigger(IRequestCycle cycle){
>
> getRequestCycle().getResponseBuilder().updateComponent("COMPONENT_ID")
>         }
>
> Hope this helps
>
> On Dec 2, 2007 12:24 AM, Kalle Korhonen <ka...@gmail.com>
> wrote:
>
> > No - I want to trigger the update programmatically via Javascript, not
> > from
> > a user's click.
> >
> > Kalle
> >
> >
> > On 12/1/07, Ulrich Stärk <ul...@spielviel.de> wrote:
> > >
> > > I can't follow you. You want a component to update itself
> asynchronously
> > > upon a user's click on a DirectLink? Why don't you just use
> DirectLink's
> > > updateComponents parameter with async="true"?
> > >
> > > Uli
> > >
> > > Kalle Korhonen schrieb:
> > > > I have a use case where I need to "click on" a directllink to
> > > > updatecomponents with async=true or do an equivalent action in
> > > Javascript. I
> > > > know I can do tapestry.bind('<span jwcid=@DirectLink.../>') and it
> > makes
> > > > some sense, but looks rather ugly. Any cleaner way to accomplish
> this?
> > > >
> > > > Kalle
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>

Re: T4: From the client side, how do you programmatically update a component?

Posted by Igor Drobiazko <ig...@gmail.com>.
Hi,

you you can do following:

-your component should implement the interface IDirect
-create a link:
      public ILink getLink(){
          return getDirectService().getLink(false, new
DirectServiceParameter(this));
      }

- and pass the url of the link as a parameter to your Script
            Map params = new HashMap();
            params.put("url", getLink().getURL());
            PageRenderSupport pageRenderSupport =
TapestryUtils.getPageRenderSupport(cycle, this);
            getScript().execute(this, cycle, pageRenderSupport, params);
- call the url in your script
<script>
    <input-symbol key="url" required="yes" />
    <body>
        <unique>
            foo =function(){
                tapestry.bind("${url}", ........);
            }
        </unique>
    </body>
</script>

- update the components in you trigger() method:
        public void trigger(IRequestCycle cycle){

getRequestCycle().getResponseBuilder().updateComponent("COMPONENT_ID")
        }

Hope this helps

On Dec 2, 2007 12:24 AM, Kalle Korhonen <ka...@gmail.com> wrote:

> No - I want to trigger the update programmatically via Javascript, not
> from
> a user's click.
>
> Kalle
>
>
> On 12/1/07, Ulrich Stärk <ul...@spielviel.de> wrote:
> >
> > I can't follow you. You want a component to update itself asynchronously
> > upon a user's click on a DirectLink? Why don't you just use DirectLink's
> > updateComponents parameter with async="true"?
> >
> > Uli
> >
> > Kalle Korhonen schrieb:
> > > I have a use case where I need to "click on" a directllink to
> > > updatecomponents with async=true or do an equivalent action in
> > Javascript. I
> > > know I can do tapestry.bind('<span jwcid=@DirectLink.../>') and it
> makes
> > > some sense, but looks rather ugly. Any cleaner way to accomplish this?
> > >
> > > Kalle
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: T4: From the client side, how do you programmatically update a component?

Posted by Kalle Korhonen <ka...@gmail.com>.
No - I want to trigger the update programmatically via Javascript, not from
a user's click.

Kalle


On 12/1/07, Ulrich Stärk <ul...@spielviel.de> wrote:
>
> I can't follow you. You want a component to update itself asynchronously
> upon a user's click on a DirectLink? Why don't you just use DirectLink's
> updateComponents parameter with async="true"?
>
> Uli
>
> Kalle Korhonen schrieb:
> > I have a use case where I need to "click on" a directllink to
> > updatecomponents with async=true or do an equivalent action in
> Javascript. I
> > know I can do tapestry.bind('<span jwcid=@DirectLink.../>') and it makes
> > some sense, but looks rather ugly. Any cleaner way to accomplish this?
> >
> > Kalle
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T4: From the client side, how do you programmatically update a component?

Posted by Ulrich Stärk <ul...@spielviel.de>.
I can't follow you. You want a component to update itself asynchronously 
upon a user's click on a DirectLink? Why don't you just use DirectLink's 
updateComponents parameter with async="true"?

Uli

Kalle Korhonen schrieb:
> I have a use case where I need to "click on" a directllink to
> updatecomponents with async=true or do an equivalent action in Javascript. I
> know I can do tapestry.bind('<span jwcid=@DirectLink.../>') and it makes
> some sense, but looks rather ugly. Any cleaner way to accomplish this?
> 
> Kalle
> 


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