You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by KEBE Cheikh Silÿffffffffffe8ye <ga...@yahoo.fr> on 2004/07/08 11:14:10 UTC

can someone help me?

hi,
i have an action class that calls a business object
(prospect). And i want to display the information for
a prospect in a form in jsp file (prospect.jsp)
 Here is my struts-config.xml
<form-bean name="prospectForm"
type="com.youcompany.struts.form.ProspectForm">
<form-property name="emailDtP" type="java.lang.String"
/>
<form-property name="emailRhP" type="java.lang.String"
/>
<form-property name="phoneP" type="java.lang.String"
/>
form-property name="nameP" type="java.lang.String" />
<form-property name="addressP" type="java.lang.String"
/>
<form-property name="faxP" type="java.lang.String" />
<form-property name="emailGenP"
type="java.lang.String" />
<form-property name="idA" type="java.lang.String" />
<form-property name="emailDcP" type="java.lang.String"
/>
</form-bean>
<action name="prospectForm" path="/editprospect"
scope="request"
        
type="com.youcompany.struts.action.EditprospectAction"
validate="false">
<forward name="prospect" path="/prospect.jsp" />
</action>

here is my prospect.jsp file

 <html:form action="/majprospect" name="prospectForm"
type="com.youcompany.struts.form.ProspectForm">
		     <table border="0" width="100%">
		 
		
		       <tr> 
		           <th align="right">  
		        	   nameP 
		        	</th> 
		        	 <td align="left">
		        	      <html:text property="nameP"  
readonly="false" size="16"
maxlength="30"/><html:errors property="nameP"/>
		        	 </td> 
		       </tr> 
		       <tr>
		        	<th align="right">  
		        	       emailGenP 
		        	 </th> 
		        	 <td align="left">
		        	      <html:text property="emailGenP"
size="16" maxlength="30"/><html:errors
property="emailGenP"/>
		        	 </td>
		       </tr>	
		        <tr>
		        	<th align="right">
		        	   phoneP 
		        	</th> 
		        	<td align="left">
		        	     <html:text property="phoneP" size="16"
maxlength="15"/><html:errors property="phoneP"/>
		        	 </td>
		        </tr>
		         <tr>
		            <th align="right">	
		        	   emailRhP 
		        	</th>
		        	<td align="left">
		        	   <html:text property="emailRhP" size="16"
maxlength="30"/><html:errors property="emailRhP"/>
		        	</td>
		        </tr>
		        <tr>
		            <th align="right">
		        	    addressP 
		        	</th>
		        	<td align="left">
		              <html:text property="addressP"
size="16" maxlength="50"/><html:errors
property="addressP"/>
		            </td> 
		         </tr>	
		         <tr>
		             <th align="right">
		        	    emailDcP 
		        	 </th>
		        	 <td align="left">
		                <html:text property="emailDcP"
size="16" maxlength="30"/><html:errors
property="emailDcP"/>
		             </td>
		         </tr>	
		         <tr>
		             <th align="right">
			           emailDtP 
			          </th>
			          <td align="left">
			            <html:text property="emailDtP"
size="16" maxlength="30"/><html:errors
property="emailDtP"/>
			          </td>
			      </tr>  
			      <tr>
			         <th align="right">
			           faxP 
			         </th> 
			         <td align="left">
			           <html:text property="faxP" size="16"
maxlength="15"/><html:errors property="faxP"/>
			         </td>
			       </tr> 
			       <tr>
			          <td align="right">
			               <html:submit/>
			           </td>
			           <td align="left">
			               <html:cancel/>
			           </td>
			       </tr> 
			    </table>
		      </html:form>


In my editProspectAction.java, i do 

public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {
ProspectForm prospect=new ProspectForm();
// here, i ask my db for retrieving a prospect 
.....
....
form=new ProspectForm();
form=prospect;
request.setAttribute(mapping.getAttribute(),form);
return (mapping.findForward("prospect"));
}


when i do editprospect.do, the prospect.jsp is
displayed but the prospect data are not pre populate.
can someone help me?
thant

=====
Cheikh Silèye KEBE



	

	
		
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: can someone help me?

Posted by Denis Avdic <de...@gmail.com>.
What is your action mapping for majprospect action?

Since your form is going to be submitted to majprospect.do (you need
to add .do in there)  your action mapping should basically have a
name="prospectForm" in it.

Also, to make sure your form is being named correctly:

request.setAttribute("prospectForm", form);  
(if you are setting the form in request, make sure that the action
mapping for majprospect also has scope="request" otherwise it will be
looking for the form in the wrong scope)

I assume that the form has values prepopulated  already and that you
have checked that before you exit that action all the values that need
to be there are there.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: can someone help me?

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "KEBE Cheikh Silÿffffffffffe8ye" <ga...@yahoo.fr>
> In my editProspectAction.java, i do
> public ActionForward execute(
> ActionMapping mapping,
> ActionForm form,
                       ^^^^^

Populate the 'form' that is passed into the method, don't create a new one:

> form=new ProspectForm();
> form=prospect;
> request.setAttribute(mapping.getAttribute(),form);

Actually I'm not certain what's going on in those three lines.  Take a look
at the struts-example webapp, it shows how to pre-populate a form using
BeanUtils.copyProperties.

It goes something like...
1. read Value Object from database
2. copy matching properties over to form bean
3. forward to JSP

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org