You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ross MacCharles <rm...@oncecorp.com> on 2002/03/04 20:17:11 UTC

RE: why would type and name attributes be necessary in in this case?


You have shown two of your defined actions "selectEditQuestion" and
"editQuestion".  However your form tags refer to "saveQuestion".  I'm
wondering what form bean  saveQuestion is bound to.  Perhaps your page comes
up blank because saveQuestion is not bound to the correct form bean?



/Ross



 -----Original Message-----
From: 	tim mansfield [mailto:timmansfield@hotmail.com] 
Sent:	Monday, March 04, 2002 1:44 PM
To:	struts-user@jakarta.apache.org
Subject:	why would type and name attributes be necessary in
<html:form> in this case?

I have two pages,  selectEditQuestion.jsp and EditQuestion.jsp.  First you 
select the question you want to edit, then you edit it, simple enough.

Here's the strange thing:

The form tag in the first page (selectEditQuestion.jsp) is set up in the 
standard way, and that's fine:

    <html:form action="/editQuestion.do">

However if I set up the form tag in the second page (EditQuestion.jsp) as 
follows:

    <html:form action="/saveQuestion.do">

... then no form fields are populated in that page (EditQuestion.jsp).

But if i add the type and name attributes to the form tag in that page:

    <html:form action="/saveQuestion.do" type="thingy.form.QuestionForm" 
name="questionForm">

... then in EditQuestion.jsp, the form fields are properly populated.

This makes no sense to me because:

1) scope is set to "session" in the mapping definitions (see below)
2) the type and name of the ActionForm (again, see below) associated with 
the form on editQuestion.jsp should be exactly what is specified in the 
verbose versions of <html:form> above.  But isn't the point of the mapping 
definition so I don't have to specify class type and class name in the .jsp?

  And the strange thing is, it actually does work for the first page, but 
not for the second.

The implementation of all Actions in this project is very simple, they just 
handle cancel or forward to the appropriate jsp.

Any thoughts on this anomaly?

----------------------------------------------------------------------------
----------------------------

  <!-- ========== Form Bean Definitions =================================== 
-->
  <form-beans>
    <!-- Question form bean -->
    <form-bean name="questionForm"
               type="thingy.form.QuestionForm"/>

[...snip...]

  <!-- ========== Action Mapping Definitions ============================== 
-->
  <action-mappings>
    <!-- Select Edit question -->
    <action path="/selectEditQuestion"
            type="thingy.action.SelectEditQuestionAction"
            name="questionForm"
            scope="session"
            validate="false">
      <forward name="start" path="/selectEditQuestion.jsp"/>
    </action>

    <!-- Edit question -->
    <action path="/editQuestion"
            type="thingy.action.EditQuestionAction"
            name="questionForm"
            scope="session"
            validate="false">
      <forward name="start" path="/editQuestion.jsp"/>
    </action>

[...snip...]

_________________________________________________________________
Con MSN Hotmail súmese al servicio de correo electrónico más grande del 
mundo. http://www.hotmail.com/ES


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>