struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Boardman" <dboard...@wagpaw.com>
Subject deep nesting of value objects in a form bean
Date Mon, 01 Oct 2001 23:39:23 GMT
I am looking for some confirmation of the approach I have taken in
developing an ActionForm that represents an Entity bean hierarchy that nests
several beans deep.

I have a form bean that I use to update a Candidate entity bean.  The
Candidate bean has an Address entity bean associated with it, and the
Address bean contains both a Country entity bean and a State entity bean.  I
have created ValueObjects for each of these entity beans so that, for
instance, I can call CandidateVO.getAddress().getState().getCode() to
retrieve the state code.  With the ValueObjects nested in this way I can
simply call the setCandidateVO() on the ActionForm and use nested properties
in my jsp to interact with the ActionForm.  For instance, if the following
field were in the jsp, then
getCandidateVO().getAddress().getState().setCode() would be called when the
form is submitted:

<html:text property="candidateVO.address.state.code" size="2"
maxlength="2"/>

I have then planned on writting updateVO() methods on each of the entity
beans that would be used to update the beans from the newly updated
ValueObjects.

I have 2 questions about this scenario:

1)From what I ahve read, ValueObjects are supposed to be immutable, however,
in the scenario above they clearly are not.  Is there a way to accomplish
the above scenario without making the ValueObjects mutable.

2)If one of the attributes of one of my entity beans is not a String, is
there still a way to use nested properties to set that attribute?  Or do I
need to create a method that does the type conversion in the ActionForm, and
then populate the ValueObject back in my Action class?

thanks,

Dave


Mime
View raw message