You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by M�ris Orbid�ns <M....@datapro.lv> on 2001/12/15 18:10:15 UTC

form bean problem & interesting question

hello

If I forward to an action then Struts creates new form bean that is
populated with parameters from current request. But if current request
contains parameters with the same names as
properties of new form's bean then these values will be displayed on my
new form !

For example:
+ Create two JSP forms. Both with input field with name "SSN".

+ Then if you forward http request from first form's action class to
second's form's action
 class (which will forward request to it's JSP page) then  value of SSN
from first form
 will be displayed on the second form, though SSN was never entered
there.


How to solve this ?  not to use input fields with equal names ?

Wouldnt it be better if Struts populated a new form bean with parameters
of request
IF AND ONLY IF the request comes from JSP form that belongs to the
current action ?

For example:   If we go to EntryAction  then populate the form bean IFF
request goes from
entry.jsp.

 <action   path="/addEntry"
              type="addressbook.EntryAction"
              name="EntryForm"
              scope="session"
              input="/entry.jsp">       
    </action>



I think it's confusing if we have:

public ActionForward perform(ActionMapping mapping,ActionForm form,
        HttpServletRequest request,	 HttpServletResponse response)
{
	String SSN = ((EntryForm) form).getSsn();
	...


But we get SSN not from EntryForm   but from some other form which
accidentally has
SSN field too.


looking forward for your comments,
Maris


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