When you use the formBean attribute on the <bean:struts> tag, you are
defining a bean which corresponds to the ActionFormBean instance for your
form bean definition (i.e. the <form-bean> entry) in struts-config.xml. You
are not defining a bean corresponding to your ActionForm bean itself.

If your form bean exists in some scope already (i.e. either Struts put it
there when processing a request or you put it there when processing an
action), then all you need is:

<bean:write name="yourFormBeanName" property="keyword"/>

where "yourFormBeanName" is the name of the attribute used to store the
bean. If Struts created the form bean for you, the attribute name is the
name you specified in the <form-bean> entry in your struts-config.xml file.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Christophe Saudubois" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 23, 2001 6:56 AM
Subject: Access to form data.


> Hello,
>
> I am in a jsp preceded by an action and I want to display the form of
> the action but not within form html tags.
>
> For instance :
> My Form :
>
> public class SearchForm extends ActionForm {
>     public SearchForm() {}
>     private String mKeyword = "";
>     public String getKeyword() { return mKeyword;}
>     public void setKeyword(String pKeyword) { mKeyword = pKeyword;}
> }
>
> My Jsp :
>
> <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
> <bean:struts id="form" formBean="searchForm"/>
> You searched : <bean:write name="form" property="keyword" />
>
> I've got this exception :
> javax.servlet.jsp.JspException: No getter method for property keyword of
> bean form
>         at javax.servlet.jsp.JspException.<init>(JspException.java:73)
>         at
> org.apache.struts.taglib.template.InsertTag.doEndTag(InsertTag.java:132)
>         at
>
root.store._0002froot_0002fstore_0002findexsearch_0002ejspindexsearch_jsp_0.
_jspService(_0002froot_0002fstore_0002findexsearch_0002ejspindexsearch_jsp_0
.java:371)
>         at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> ...
> 
> The object form is really a SearchForm (getType method of the form that
> is working).
> thanks,
> Christophe Sauldubois.


Reply via email to