Prev | Current Page 243 | Next

Frank Zammetti

"Practical DWR 2 Projects"


Listing 3-6. A Simple Bean Annotated for DWR??™s Use As a Convertible Type
@DataTransferObject
public class MyBean {
@RemoteProperty
private String firstName;
public String getFirstName() {
return firstName;
}
}
The @DataTransferObject annotation indicates the bean can be marshaled by DWR, and
the @RemoteProperty annotation indicates that the property firstName should be marshaled.
So, if you wish to have some members of the bean that are not transmitted back and forth
between client and server, simply leave off the corresponding @RemoteProperty annotation,
and you??™re all set.
Note that there is an optional converter attribute to the @DataTransferObject annotation
that can specify the type of converter to use to marshal the class. Documentation was a little
sparse on this attribute frankly, so I hesitate to show an example, lest it be wrong. I can tell you
that the default converter used is the ubiquitous BeanConverter, so in most cases you won??™t
need this anyway, but if you do, I suggest pinging the DWR mailing list to get a description of
what the attribute does. We won??™t need it in any of the projects in this book, so I think I can
cop out a little bit here!
CHAPTER 3 n ADVANCED DWR 124
Incidentally, this is one of those times where using annotations doesn??™t hurt my head
very much.


Pages:
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255