You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/04/20 22:15:44 UTC

DO NOT REPLY [Bug 19183] New: - DynaValidatorForm and Normal ActionForm

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19183>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19183

DynaValidatorForm and Normal ActionForm

           Summary: DynaValidatorForm and Normal ActionForm
           Product: Struts
           Version: Nightly Build
          Platform: All
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Controller
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: ralphschaer@yahoo.com


I have two form definitions with the same name in two config files.

in struts-config-admin.xml:
<form-bean name="logonForm" 
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="userName" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>

and in struts-config.xml:
<form-bean name="logonForm" type="myapp.LogonForm"/>  

When I try to call an action with the admin logonForm this error occurs:
java.lang.ClassCastException
	at org.apache.struts.util.RequestUtils.createActionForm
(RequestUtils.java:719)
	at org.apache.struts.action.RequestProcessor.processActionForm
(RequestProcessor.java:364)
	at org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:253)
	at org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1480)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)


The problem is the recycle code in RequestUtil:
        if ("request".equals(mapping.getScope())) {
            instance = (ActionForm) request.getAttribute(attribute);
        } else {
            session = request.getSession();
            instance = (ActionForm) session.getAttribute(attribute);
        }

        // Can we recycle the existing form bean instance (if there is one)?
        if (instance != null) {
            if (config.getDynamic()) {
                String className = ((DynaBean) instance).getDynaClass().getName
();
                if (className.equals(config.getName())) {


The cast to DynaBean is not working because instance is type myapp.LogonForm

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