Missing setters dont cause a problem and missing getters dont either (it
just wont get that variable ;)
Java Introspection is based on what it finds for getters and setters and not
the actual variable.
But even though that's how ji works it is still considered "standard" to
define all getters and setters.
You can always define empty methods or return null methods.
ex:
public xx getY()
{
return null;
}
public void setY( xx y )
{
//dont do anything.
}
If you ever use a javabean creator (from an IDE or whatever) it might do
something like:
public xx getY()
{
throw new NotImplementedException("blah");
}
public void setY( xx y )
{
throw new NotImplementedException("blah");
}
Do not use those especially with the commons BeanUtils copyxxx methods as
this will cause a exception to be throw even if ur not using that getter and
setter in a target bean.
Then again.. if its not broken.. why fix it. heh
-Tim
-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Friday, March 14, 2003 8:00 PM
To: [EMAIL PROTECTED]
Subject: JSTL okay with get method, but no set method?
I have a DTO that contains a List of objects. Since you can add any Object
to a List, I would rather not have a
setAssistants( List asst );
method that would allow someone to add a list of inappropriate object types.
Instead, I want to only have:
public List getAssistants();
public void addAssistant( PersonView p);
I know that having two 'set' methods with the same name but different
parameters *really* confuses the introspection/reflection/whatever magic
happens with JavaBeans. Learned that one the hard way. :(
But what about a 'missing' set method? It _seems_ to be working:
<c:forEach items="${trackDto.assistants}" var="asst">
<c:out value="${asst.assistant.preferredName}"/> <c:out
value="${asst.assistedDate}"/>
</c:forEach>
I gather that JSTL uses the 'get' method to determine the type of the
object, because I'm not specifying that here and it's having no problems.
Please stop me now if I'm doing something that's going to cause problems
later!
Thanks,
--
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]