I have designed a survey for my company using STRUTS.  I have tried to
follow the MVC paradigm, but I fear I may have missed something.

I have two forms, Survey1 and Survey2.  They are in the same context called
survey.  They are represented by their own JSPs called survey1.jsp and
survey2.jsp.  They both have a form beans called Survey1Form and
Survey2Form.

However, instead of two different actions, they both use the same action
called SaveSurveyAction.  At this time, this action does only two things.
It checks which instance of form, and arbitrarily returns success.  No real
inovation here, because I'm just trying to see if it works.

The problem is, survey1.jsp keeps getting this message when I invoke it in
the browser:

        javax.servlet.ServletException: No getter
        method available for property q2 for bean
        under name org.apache.struts.taglib.html.BEAN

The survey2.jsp file does not get this message.  After a bit of debugging,
it seems that the Survey1Form bean is not being inst'd for survey1.jsp.
Instead, it looks as if Survey2Form is being inst'd for both survey1.jsp and
survey2.jsp.

The property of q2 is not present in Survey2Form, and if I add it, the
message changes to the next property, q3.  But I don't want Survey2Form to
have the same properties as Survey1Form.  That's the whole point.  I should
be able to have two different forms with the same action.  No?

Here is some of my struts-config.xml:

        <form-beans>
                <form-bean name="survey1Form"
type="com.trams.survey.Survey1Form"/>
                <form-bean name="survey2Form"
type="com.trams.survey.Survey2Form"/>
        </form-beans>

        <global-forwards>
                <forward name="success" path="/thankyou.jsp"/>
        </global-forwards>

        <action-mappings>
                <action
                        path="/saveSurvey"
                        type="com.trams.survey.SaveSurveyAction"
                        name="survey1Form"
                        scope="request"
                        input="/survey1.jsp"
                        validate="true">
                </action>
                <action
                        path="/saveSurvey"
                        type="com.trams.survey.SaveSurveyAction"
                        name="survey2Form"
                        scope="request"
                        input="/survey2.jsp"
                        validate="true">
                </action>
        </action-mappings>

Any pointers would be appreciated.


Anthony

It is by caffeine alone I set my mind in motion.
It is by the Beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

Reply via email to