This passage is straight from the struts javadoc The key passed into the validator is the action element's 'name' attribute from the struts-config.xml which should match the form element's name attribute in the validation.xml Take a peek at how to configure struts-config.xml at http://www.reumann.net/do/struts/lesson3/step4 which details the form bean name type (with the fully qualified package name) and the column form-property Keep me apprised, Martin ----- Original Message ----- From: "Pedro Salgado" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, December 31, 1969 7:05 PM Subject: Re: Please Help - ClassCastException
> On 04/01/2004 05:04, "Caroline Jen" <[EMAIL PROTECTED]> wrote: > > > Thank you for trying to help. I have added > > import org.apache.artimus.message.PostForm; > > to my action class. I do not fully follow what I > > should check in the struts-config.xml file. And > > should I use name="postForm" with lowercase 'p' or > > uppercase 'P'? > > > > In my struts-config.xml file, I have: > > > > <form-bean > > name="postForm" > > > > type="org.apache.struts.validator.DynaValidatorForm"> > > Here is the problem. Replace > > org.apache.struts.validator.DynaValidatorForm > > for > > org.apache.artimus.message.PostForm > > That should work > > Pedro Salgado > > > > <form-property > > name="receiver" > > type="java.lang.String"/> > > <form-property > > name="sender" > > type="java.lang.String"/> > > <form-property > > name="title" > > type="java.lang.String"/> > > <form-property > > name="postTopic" > > type="java.lang.String"/> > > <form-property > > name="postBody" > > type="java.lang.String"/> > > </form-bean> > > > > and > > > > <action > > roles="administrator,editor,contributor" > > path="/message/NewTopic" > > type="org.apache.artimus.message.StoreMessage" > > name="postForm" > > scope="request" > > validate="true" > > input=".message.Form"> > > <forward > > name="success" > > path=".article.View"/> > > </action> > > > > Do you see any problems? > > --- Pedro Salgado <[EMAIL PROTECTED]> wrote: > >> > >> On your struts config file check if the form bean > >> for StoreMessage action > >> is of type pkg.pkg.PostForm and if the action name > >> is pointing to the > >> correct form bean... It also seems to be missing the > >> import of the PostForm > >> on your action class. > >> > >> Pedro Salgado > >> > >> On 04/01/2004 03:22, "Caroline Jen" > >> <[EMAIL PROTECTED]> wrote: > >> > >>> The statement shown below encountered a > >>> ClassCastException: > >>> > >>> PostForm postForm = ( PostForm )form; > >>> > >>> I cannot figure out the reason. Please help. > >>> > >>> Allow me to show more code of the class where the > >>> exception occurred: > >>> > >>> ... > >>> > >>> import org.apache.struts.action.Action; > >>> import org.apache.struts.action.ActionForward; > >>> import org.apache.struts.action.ActionMapping; > >>> import org.apache.struts.action.ActionForm; > >>> import org.apache.commons.beanutils.BeanUtils; > >>> import javax.servlet.http.HttpServletRequest; > >>> import javax.servlet.http.HttpServletResponse; > >>> > >>> import org.apache.artimus.message.PostBean; > >>> import org.apache.artimus.message.ThreadBean; > >>> import > >> org.apache.artimus.message.utility.DateUtil; > >>> > >>> public final class StoreMessage extends Action > >>> { > >>> public ActionForward execute(ActionMapping > >> mapping, > >>> ActionForm form, > >>> HttpServletRequest > >>> request, > >>> HttpServletResponse > >>> response) > >>> throws Exception > >>> { > >>> > >>> int parentPostID; > >>> int threadID; > >>> int postID; > >>> String postCreationIP; > >>> String memberName = request.getRemoteUser(); > >>> Timestamp now = > >>> DateUtil.getCurrentGMTTimestamp(); > >>> > >>> parentPostID = Integer.parseInt( > >>> request.getParameter( "parent" ) ); > >>> > >>> PostForm postForm = ( PostForm )form; > >>> .... > >>> .... > >>> > >>> } > >>> } > >>> > >>> __________________________________ > >>> Do you Yahoo!? > >>> Find out what made the Top Yahoo! Searches of 2003 > >>> http://search.yahoo.com/top2003 > >>> > >>> > >> > > --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: > >> [EMAIL PROTECTED] > >>> For additional commands, e-mail: > >> [EMAIL PROTECTED] > >> > >> > >> > > --------------------------------------------------------------------- > >> To unsubscribe, e-mail: > >> [EMAIL PROTECTED] > >> For additional commands, e-mail: > >> [EMAIL PROTECTED] > >> > > > > > > __________________________________ > > Do you Yahoo!? > > Find out what made the Top Yahoo! Searches of 2003 > > http://search.yahoo.com/top2003 > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]