struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex_Kotch...@divintech.com
Subject Extending ActionMapping in Struts 1.1 - classcast exception.
Date Wed, 06 Nov 2002 02:45:49 GMT
I am working on an app with Tomcat 4.1 and Struts 1.1. I would like  to 
extend an ActionMapping, in order to verify that the user is logged in. I 
extend an ActionMapping, create the getter and setter methods for the 
property that I have added. 

Finally, I change my web.xml and my struts-config.xml files as indicated 
below. However, in my execute ( ...) method, when I cast the ActionMapping 
parameter to a UsersActionMapping, I get a ClassCastException. It seems 
that for some reason it is disregarding the fact that I want it to pass an 
UserActionMapping object , and instead passes me a regular ActionMapping 
object. If comment out the cast to UsersActionMapping, the execute method 
executes successfully.. 

So, my question is.. what am I missing.. what else do I have to do in 
order to get an instance of an UserActionMapping object in my execute 
method, instead of getting the normal ActionMapping object... ? 

Thanks in advance... 

----  web.xml excerpt ---
.........
<servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>5</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>application</param-name>
      <param-value>ApplicationResources</param-value>
    </init-param>
    <init-param>
      <param-name>mapping</param-name>
      <param-value>printrejects.UsersActionMapping</param-value>
    </init-param>
    <init-param>
            <param-name>application</param-name>
            <param-value>printrejects.ApplicationResources</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>
  </servlet>
.......

-------- struts-config.xml excerpt - - - - 
....
<action path="/ClaimList"
            type="printrejects.ClaimListAction"
            scope="request">
            <set-property property="loginRequired" value="true" />
            <forward name="success" path="/claimslist.jsp" />
        </action>
............


----------- ClaimListAction.java excerpt ... 

public ActionForward execute(ActionMapping mapping, 
        ActionForm form, 
        HttpServletRequest request, 
        HttpServletResponse response)
        throws IOException, ServletException {

        String target = "success";
         UsersActionMapping uam = (UsersActionMapping)mapping; 

............. 

Thanks,

Alex Kotchnev
Diversified Information Technologies


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message