I have a select option list that is populated by a Collection of
"UserType" beans. At the very least my Action Form( DynaActionForm
actually) will need to get populated with the "userTypeId" and the
"userTypeName" of the UserType selected from this selection list.

I know this should be easy but what is the cleanest way to accomplish
getting this userTypeId and userTypeName information?

The way it set now is I gave my Form Bean an indexId attribute and
this is what I pass to my Action. Then in the Action I pull the
correct UserType from the collection based on this index value and
then I manually set the DynaActionForm properties in my action and put
this DynaActionForm into request scope, so the next forwarded page can
add to the DynaActionForm.

Although the above works, I'm wondering if there are better ways to
handle what I'm trying to accomplish. My Action form (which extends
DispatchAction) is going to start getting REALLY big awfully quick if
I have to this kind of stuff a lot:

//get the UserTypeDTO selected from drop down based on the index
//in drop down
UserTypeDTO userTypeDTO = 
    (UserTypeDTO)userTypesList.get( userTypeIndex );
int userTypeId = userTypeDTO.getId();

//set the dyna form attributes with DTO attributes
f.set( "userTypeId", String.valueOf( userTypeId ) );
f.set( "userTypeName", userTypeDTO.getDisplayName() );

//add form to request and pass on to choose unit information page
request.setAttribute( "userTypeForm", f );

//forward to appropriate page for choosing information
if ( userTypeId == 1 || userTypeId == 2 || userTypeId == 3 ) {
    return mapping.findForward( "unitStoreOrJvp" );
}
if ( userTypeId == 4 ) {
    return mapping.findForward( "rvp" );
}
if ( userTypeId == 5 ) {
    return mapping.findForward( "other" );
}
else {
    //add some ActionError stuff here first
    return mapping.findForward( "error" );
}

--

Rick

mailto:[EMAIL PROTECTED]

"Instead of studying for finals, what about just going to the Bahamas
and catching some rays? Maybe you'll flunk, but you might have flunked
anyway; that's my point."
  -Jack Handey


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to