Leif Hanack wrote:
>>>i think the loss of using interfaces is a big disadvantage. on the
>>>serverside it will not be clear, why i have a class User with getter
>>>and setter and a User2 with just setter.
>>
>>I disagree. I believe it's a huge advantage. It means that I don't have to
>>code server-side objects specifically for use with JSTL, and I
>>don't have to
>>retrofit existing objects just to make them available to my JSTL page
>>authors.
>
>
> mmh?! in case i want the webdeveloper access only getters of my object, i
> need to write a wrapper object on the server side, as shawn bayern mention!
> so i have to write specific object for use with jstl:-((
But an interface doesn't protect your data at all, not even when you
use plain old JSP, <jsp:useBean> and scriptlets:
<%-- Create a scripting variable for my app data: a class of
type MyData (with getters and setters), declaring it as
an instance of the MyReadOnlyInterface (with only getters) --%>
<jsp:useBean id="myData" class="myapp.MyReadOnlyInterface" />
<%-- Use it as intended -->
<%= myData.getFoo() %>
<%-- Bypass the interface to use it in an illegal way by casting
to the real class --%>
<% ((MyData) myData).setFoo("Got ya!"); %>
An interface offers no protection. If you want to protect the data
from being modified, you must use other means: do not provide setter
methods, make the setter methods private, use a wrapper with no
setters, etc.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
JavaServer Pages http://TheJSPBook.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>