You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Leon Derks <le...@cumquat.nl> on 2008/04/28 17:53:42 UTC

multiple context values

How can I add multiple context values to an actionlink?

For example a productId and a categoryId?





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


Re: multiple context values

Posted by Howard Lewis Ship <hl...@gmail.com>.
Marcelo has the right answer for Tapestry 5.0.18:  you must create a
property of your page to assemble the context values into a List or
array.

In 5.1, there's new property expression syntax for creating a list:

  context="[ productId, categoryId ]"

On Mon, Apr 28, 2008 at 8:53 AM, Leon Derks <le...@cumquat.nl> wrote:
> How can I add multiple context values to an actionlink?
>
> For example a productId and a categoryId?
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

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: multiple context values

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, Apr 2, 2009 at 11:37 AM, Fernanda C. Carmo
<fe...@gmail.com> wrote:

> Is there any other way to have only one parameter ProjectVersion like this?
>
>    public Object onActionFromEditProjectVersion(ProjectVersion
> projectVersion) {
>
>        editProjectVersionPage.setProjectVersion(projectVersion);
>        return editProjectVersionPage;
>    }

I guess implementing ValueEncoder for ProjectVersion and then
contributing it to ValueEncoderSource, as Filip suggested, would make
your code work.

-- 
Thiago

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


Re: multiple context values

Posted by "Fernanda C. Carmo" <fe...@gmail.com>.
Thiago and Filip, thank you very much!

Actually, I have an object ProjectVersion with the composite primary key. 
So in ListProjectVersionPage I would like to go to EditProjectVersionPage
this way:

    public Object onActionFromEditProjectVersion(EventContext context) {
        
        Integer proCodigo = context.get(Integer.class, 0);
        Integer vprCodigo = context.get(Integer.class, 1);        
        projectVersion =
projectVersionService.getProjectVersionFromPK(proCodigo, vprCodigo);
        
        editProjectVersionPage.setProjectVersion(projectVersion);
        return editProjectVersionPage;
    }

It works fine! But maybe it's not the best way.

Is there any other way to have only one parameter ProjectVersion like this?

    public Object onActionFromEditProjectVersion(ProjectVersion
projectVersion) {
        
        editProjectVersionPage.setProjectVersion(projectVersion);
        return editProjectVersionPage;
    }

Thanks again!


Thiago H. de Paula Figueiredo wrote:
> 
> On Wed, Apr 1, 2009 at 7:45 PM, Filip S. Adamsen <fs...@fsadev.com> wrote:
>> What about contributing a ValueEncoder that converts between a ProductId
>> and a String? I haven't needed to work with composite primary keys, so I
>> can't say if it'd work, but it's worth a shot.
> 
> This is a more reusable solution than the one I've suggested before,
> so that's the one I recommend. ;)
> 
> -- 
> Thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 


-----
Fernanda Cristina do Carmo
System Analyst and Java Developer
MSN/GoogleTalk: fernanda.carmo@gmail.com

-- 
View this message in context: http://www.nabble.com/multiple-context-values-tp16941976p22849424.html
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: multiple context values

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, Apr 1, 2009 at 7:45 PM, Filip S. Adamsen <fs...@fsadev.com> wrote:
> What about contributing a ValueEncoder that converts between a ProductId
> and a String? I haven't needed to work with composite primary keys, so I
> can't say if it'd work, but it's worth a shot.

This is a more reusable solution than the one I've suggested before,
so that's the one I recommend. ;)

-- 
Thiago

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


Re: multiple context values

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What about contributing a ValueEncoder that converts between a ProductId
and a String? I haven't needed to work with composite primary keys, so I
can't say if it'd work, but it's worth a shot.

/Filip

On 2009-04-02 00:33, Thiago H. de Paula Figueiredo wrote:
> Em Wed, 01 Apr 2009 18:35:53 -0300, Fernanda C. Carmo
> <fe...@gmail.com> escreveu:
> 
>> I have an object Product and it has a composite primary key (ProductId).
>> How can I put this object Product in actionlink's context value?
> 
> Hi!
> 
> Create a method that return a List containig the values thatt comprise
> the composite primary key. ;) This works in any Tapestry version.
> Use EventContext as the only parameter of onActivate or any other event
> handler method.
> By the way, in new code, avoid composite primary keys. It's not worth
> the trouble.
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEcBAEBAgAGBQJJ0+6AAAoJEEfiH7PpjaMngogH/jK+fjLs1Q01kukoVAA/V/rb
A2FW5oB8T9sik+OL/gRueSF8eV0z00j/lYaZ8F/p+sbIetSy16CCn0XnPUOYagx6
JBBWplsSDgHG62NnpO5+RzYBPmF4gLh4gOYrGo+WIaZcT/ZK9ohWrcLfF9V0IQrw
ciBcdxb1VToJF51qmtHnG4EcMORNkyd0gzElX1FpBVLiiJUOb4+CWRhLdEasF0nu
muKNA0zuZd85C3w2K7yWt15NBR8HRg3jJ/Xa54vHAq8OQ+1hFhkJLFck9PGIYrt3
HCQHqKbJxPYOgd3JVamrTSszqjnhVriVNHKfD8H8LfUb0/dBxDaclx88KTY0Oy8=
=EgqM
-----END PGP SIGNATURE-----

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


Re: multiple context values

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 01 Apr 2009 18:35:53 -0300, Fernanda C. Carmo  
<fe...@gmail.com> escreveu:

> I have an object Product and it has a composite primary key (ProductId).
> How can I put this object Product in actionlink's context value?

Hi!

Create a method that return a List containig the values thatt comprise the  
composite primary key. ;) This works in any Tapestry version.
Use EventContext as the only parameter of onActivate or any other event  
handler method.
By the way, in new code, avoid composite primary keys. It's not worth the  
trouble.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: multiple context values

Posted by "Fernanda C. Carmo" <fe...@gmail.com>.
I have an object Product and it has a composite primary key (ProductId).

How can I put this object Product in actionlink's context value?

Thank's!!!


Geoff Callender-2 wrote:
> 
> You need the "list" binding prefix so you can do this:   
> t:context="list:p.productId, p.categoryId".  It's available 2 ways  
> that I know of:
> 
> 1. You can add it to your project by hand from
> http://wiki.apache.org/tapestry/Tapestry5HowToAddBindingPrefix
> 2. You can get it for free by including the t5components in your  
> project: http://code.google.com/p/tapestry5-components/
> 
> Cheers,
> 
> Geoff
> http://files.doublenegative.com.au/jumpstart/
> 
> On 29/04/2008, at 3:09 AM, Marcelo Lotif wrote:
> 
>> I was just caught by this problem some time ago, and in the tapestry
>> site they recommend this:
>>
>> public Object[] getAccountContext()
>> {
>>    return new Object[] { account.companyId, account.id };
>> }
>>
>> Object onActionFromDelete(long companyId, long accountId){
>> //...
>> }
>>
>> <p>
>> [<t:actionlink t:id="delete" context="accountContext">delete</ 
>> t:actionlink>
>> </p>
>>
>> see:
>> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/ActionLink.html
>>
>>
>> 2008/4/28 Manuel Corrales <ma...@gmail.com>:
>>> I think you can separate the values with commas like this:
>>>
>>> t:context="p.productId, p.categoryId"
>>>
>>> Good luck!
>>>
>>>
>>>
>>>
>>> On Mon, Apr 28, 2008 at 12:53 PM, Leon Derks  
>>> <le...@cumquat.nl> wrote:
>>>
>>>> How can I add multiple context values to an actionlink?
>>>>
>>>> For example a productId and a categoryId?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>
>>
>>
>>
>> -- 
>> Atenciosamente,
>> Marcelo Lotif
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 


-----
Fernanda Cristina do Carmo
System Analyst and Java Developer
MSN/GoogleTalk: fernanda.carmo@gmail.com

-- 
View this message in context: http://www.nabble.com/multiple-context-values-tp16941976p22834770.html
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: multiple context values

Posted by Geoff Callender <ge...@gmail.com>.
You need the "list" binding prefix so you can do this:   
t:context="list:p.productId, p.categoryId".  It's available 2 ways  
that I know of:

1. You can add it to your project by hand from http://wiki.apache.org/tapestry/Tapestry5HowToAddBindingPrefix
2. You can get it for free by including the t5components in your  
project: http://code.google.com/p/tapestry5-components/

Cheers,

Geoff
http://files.doublenegative.com.au/jumpstart/

On 29/04/2008, at 3:09 AM, Marcelo Lotif wrote:

> I was just caught by this problem some time ago, and in the tapestry
> site they recommend this:
>
> public Object[] getAccountContext()
> {
>    return new Object[] { account.companyId, account.id };
> }
>
> Object onActionFromDelete(long companyId, long accountId){
> //...
> }
>
> <p>
> [<t:actionlink t:id="delete" context="accountContext">delete</ 
> t:actionlink>
> </p>
>
> see: http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/ActionLink.html
>
>
> 2008/4/28 Manuel Corrales <ma...@gmail.com>:
>> I think you can separate the values with commas like this:
>>
>> t:context="p.productId, p.categoryId"
>>
>> Good luck!
>>
>>
>>
>>
>> On Mon, Apr 28, 2008 at 12:53 PM, Leon Derks  
>> <le...@cumquat.nl> wrote:
>>
>>> How can I add multiple context values to an actionlink?
>>>
>>> For example a productId and a categoryId?
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>
>
>
> -- 
> Atenciosamente,
> Marcelo Lotif
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: multiple context values

Posted by Marcelo Lotif <ml...@gmail.com>.
I was just caught by this problem some time ago, and in the tapestry
site they recommend this:

public Object[] getAccountContext()
{
    return new Object[] { account.companyId, account.id };
}

Object onActionFromDelete(long companyId, long accountId){
//...
}

<p>
 [<t:actionlink t:id="delete" context="accountContext">delete</t:actionlink>
</p>

see: http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/ActionLink.html


2008/4/28 Manuel Corrales <ma...@gmail.com>:
> I think you can separate the values with commas like this:
>
> t:context="p.productId, p.categoryId"
>
> Good luck!
>
>
>
>
> On Mon, Apr 28, 2008 at 12:53 PM, Leon Derks <le...@cumquat.nl> wrote:
>
> > How can I add multiple context values to an actionlink?
> >
> > For example a productId and a categoryId?
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>



-- 
Atenciosamente,
Marcelo Lotif

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


Re: multiple context values

Posted by Manuel Corrales <ma...@gmail.com>.
I think you can separate the values with commas like this:

t:context="p.productId, p.categoryId"

Good luck!

On Mon, Apr 28, 2008 at 12:53 PM, Leon Derks <le...@cumquat.nl> wrote:

> How can I add multiple context values to an actionlink?
>
> For example a productId and a categoryId?
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>