You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Topley <Jo...@ons.gsi.gov.uk> on 2003/05/23 12:06:44 UTC

DynaActionForm Works, ActionForm Doesn't

Hi,

I'm having a problem with Struts 1.1 RC whereby I get a
ClassNotFoundException when trying to instantiate my form bean. The odd
thing is that if I use a DynaActionForm instead, everything works properly.
I'm using Oracle JDeveloper 9.0.3 with the embedded OC4J container. I've
included the source code at the end of this message.

Thanks,

John

NewTopicForm.java:

package com.company.project.controller.form;

// Imports omitted for brevity.

public final class NewTopicForm extends ActionForm
{
  private String author;
  private String message;
  private String title;

  public String getAuthor()
  {
    return this.author;
  }

  public void setAuthor(String author)
  {
    this.author = author;
  }

  public String getMessage()
  {
    return this.message;
  }

  public void setMessage(String message)
  {
    this.message = message;
  }

  public String getTitle()
  {
    return this.title;
  }

  public void setTitle(String title)
  {
    this.title = title;
  }

  public void reset(ActionMapping mapping, HttpServletRequest request)
  {
    setAuthor(null);
    setMessage(null);
    setTitle(null);
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
  {
    ActionErrors errors = new ActionErrors();

    if ((getTitle() == null) || (getTitle().length() < 1))
    {
      errors.add("title", new ActionError("error.title.required"));
    }

    if ((getMessage() == null) || (getMessage().length() < 1))
    {
      errors.add("message", new ActionError("error.message.required"));
    }

    if ((getAuthor() == null) || (getAuthor().length() < 1))
    {
      errors.add("author", new ActionError("error.author.required"));
    }

    return errors;
  }
}

struts-config.xml:

<form-beans>
    <form-bean name="newTopicForm" type
="com.company.project.controller.form.NewTopicForm"/>
  </form-beans>

  <global-forwards>
    <forward name="topics" path="/Topics.do"/>
    <forward name="newtopic" path="/NewTopic.do"/>
  </global-forwards>

  <action-mappings>
    <action path="/Topics" forward="/WEB-INF/jsp/Topics.jsp"/>
    <action path="/NewTopic" type="org.apache.struts.actions.ForwardAction"
parameter="/WEB-INF/jsp/NewTopic.jsp"/>
    <action path="/NewTopicSubmit" type
="com.company.project.controller.action.NewTopicAction" name="newTopicForm"
input="/WEB-INF/jsp/NewTopic.jsp" scope="request" validate="true"/>
  </action-mappings>



For the latest data on the economy and society 
consult National Statistics at http://www.statistics.gov.uk

**********************************************************************
Please Note:  Incoming and outgoing email messages
are routinely monitored for compliance with our policy
on the use of electronic communications
**********************************************************************
Legal Disclaimer  :  Any views expressed by
the sender of this message are not necessarily
those of the Office for National Statistics
**********************************************************************

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


Re: DynaActionForm Works, ActionForm Doesn't

Posted by Ted Husted <hu...@apache.org>.
The DynaActionForm class is in the Struts JAR, so it would have to be 
able to find that one. If the environment can't find the ActionForm 
class, it's usually because the class isn't on the classpath or hasn't 
been compiled, or the like.

-Ted.

John Topley wrote:
> Hi,
> 
> I'm having a problem with Struts 1.1 RC whereby I get a
> ClassNotFoundException when trying to instantiate my form bean. The odd
> thing is that if I use a DynaActionForm instead, everything works properly.
> I'm using Oracle JDeveloper 9.0.3 with the embedded OC4J container. I've
> included the source code at the end of this message.


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



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