Hello Adam,
Tuesday, July 17, 2001, 9:37:21 PM, you wrote:
AY> One part of Struts where I'd like to do some additions is to form
AY> initialization. Most of the form Objects I have require prepopulation
AY> out of EJBs. What I'd like to do is specify for a form anothe object
AY> that is the factory for that form, and values for properties of the
AY> factory that should be set before creating the form.
AY> in Struts config:
AY> <struts-config>
AY> <form-beans>
AY> <form-bean
AY> name="caretoolSearchForm"
AY> factory="caretoolSearchFormFactory"/>
AY> etc:
AY> <form-factories>
AY> <form-factory
AY> name="caretoolSearchFormFactory"
AY> class="com.getcare.caretool.SearchFormFactory" />
AY> etc:
AY> Then
AY> public interface ActionFormFactory {
AY> public ActionForm create();
AY> }
AY> Is there a better way to go about doing this? Am i reinventing the
AY> wheel?
Simple way to do such task is to perform form populating in Action
class.
<action
path="/searchFormShow"
type="com.action.SearchFormShow"
name="caretoolSearchForm">
<forward name="form" path="/WEB-INF/jsp/caretoolSearchForm.jsp"/>
</action>
Place your call to the EJB in com.action.SearchFormShow action class,
create and fill form, store it in appropriate context and forward to
the 'form' forward - all values will be prepopulated.
May be your idea about automatic form prepopulating is good... I think
it needs to be more flexible in factory<->form link, because of form
can be used with different actions and prepopulating sometimes is not
needed.
--
Best regards,
Oleg mailto:[EMAIL PROTECTED]