If I were to implmenet what you suggest below, I would need to be able
to chain actions.
Basically we are implmenting the wizard type setup
search->search results->page1->page2 etc.
So search results would go to page1Show.do page1Show.do would forward to
page1.jsp? That would work.
To address the flexibility, there are two ways. One, use a different
name for the prefilledform than for the non prefilled form. Two have a
flad in the action entry that specifies whether to use the factory or not.
The more I think about it, the more I think the showAction specified
below is the way to go. Keeps it simple.
Oleg V Alexeev wrote:
>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.
>