On Friday 03 March 2006 02:43, Sergei Dubov wrote:
> I have an interesting problem...
>
> Let's say I have to pass a primary key of a DB record to a component's
> parameter. Say, I write in my page template for TextField
> "ognl:customer.locationId". Customer is a domain object, locationId is a
> primary key of one of the locations that the customer has.
>
> What I want is that the locationId be encoded in the forms (on POST) and
> in the link (on GET). I can take care of the encoding mechanism. And I
> am looking for a way to tell Tapestry to do it transparently for me.
>
> I understand that the key may be the concept of IBinding. If IBinding
> knows how to encode and decode values, then this should be a piece of cake.
>
> Please let me know, first of all, if this is the correct train of
> thought. And second, please, help me figure out how to extend
> ExpressionBinding (I assume this is the one I need), to plugin in my
> encoding logic.
I think your mind set is potentially wrong. You don't need to get down to
that level of detail. Basically what form is your location id? just a
string or integer or something more complex. What about customer as a whole?
Effectively in tapestry you can pass any serializeable object as a parameter
to a listener. so all you should need for links is something like
<span jwcid="@DirectLink" listener="listener:do Action"
parameters="ognl:customer.locationId">
public IPage doAction(String id) {
...
}
or even (if Customer was serializable)
<span jwcid="@DirectLink" listener="listener:doAction"
parameters="ognl:customer">
public IPage doAction(Customer customer) {
...
}
In a form if the field is in a text field anyway, you can read it directly
from the forms listener
getCustomer().getLocationId()
or if you don't want it visible to the user just make it a hidden field
<input jwcid="@Hidden" value="ognl:customer.locationId" />
--
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]