tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Athneria, Mahendra" <mahendra.athne...@atos.net>
Subject Encoder with <t:loop>
Date Fri, 22 Jun 2012 05:30:12 GMT
Hi,

I have one Page which is displaying details of some Client. I am using t:loop to display some
data. In t: loop I am just passing source and value. So far so good, my page is working fine.
But when I try to submit the Page it suddenly give me the Exception.

"Could not find a coercion from type java.lang.String to type [addressUsageValue] Available
coercions:.........."

Below is the sample code

<t:loop source="addressUsageInfo" value="addressUsageValue">
                  <tr>
                              <td>${addressUsageValue?.usage}</td>
                              <td>${addressUsageValue?.address}</td>
                              <td>${addressUsageValue?.postCode}</td>
                              <td>${addressUsageValue?.city}</td>
                              <td>${addressUsageValue?.country}</td>
                  </tr>
</t:loop>

I did some goggling and find below references.

http://tapestry.apache.org/5.3.3/apidocs/org/apache/tapestry5/corelib/components/Loop.html
https://issues.apache.org/jira/browse/TAP5-609

So I have created encoder for Loop. Below is the sample code. In below toClient() method I
have randomly returned any value and in toValue() method I am returning null.

      private final ValueEncoder<DtoAddressUsageInfo> addressUssageEncoder = new ValueEncoder<DtoAddressUsageInfo>()
{

            public String toClient(DtoAddressUsageInfo value) {
                  return String.valueOf(value.getUsage());
            }

            public DtoAddressUsageInfo toValue(String clientValue) {
                  return null;
            }

      };
Now my code is working fine and I am able to submit the form.

Here my doubt comes

First - I am not able to understand why encoder is required when using loop?? And if it is
required to submit the form then why it is not Mandatory parameter??

Second - I have just implemented the Encoder without any logic. I am not able to understand
where toValue() and toClient() method is used and what is the purpose?

Third - when I submit the Page why form required Encoder??

Regards,
Mahendra Athneria
[cid:221044411@01072011-28AB]
Ext-+91 22 6733 3729
Mob-+91 9833 121 309
mahendra.athneria@atos.net
[cid:image001.gif@01CA57B6.7335F1E0]


Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message