Frank,
I did the same thing as you but could not get the set-property tag to work within the <action> </action> tags. It never called the setter.


-Richard

At 08:12 PM 11/18/2003, you wrote:
Ok, I found something that works, although I'm not really happy with it. I took the suggestions of subclassing ActionMapping and specified it in my action-mappings declaration. This seems like poor design from the struts end since my HackMapping class now has to contain all initialization variables for all defined actions. Struts should support a way to set properties on the Actions themselves. Sounds like an enhancement request. Anyway, thanks to all that helped.

struts-config.xml
<action-mappings type="mapping.HackMapping">
[action definitions snipped]
</action-mappings>

HackMapping.java
public class HackMapping extends ActionMapping {
  public boolean passwordDisabled     = false;
  public boolean getPasswordDisabled() {
    return passwordDisabled;
  }
  public void setPasswordDisabled(boolean aValue) {
    passwordDisabled = aValue;
  }
}

LoginAction.java execute method
System.out.println("pd: "+((HackMapping)mapping).getPasswordDisabled());

Wendy Smoak wrote:
From: Frank Maritato [mailto:[EMAIL PROTECTED] I think the real problem is that it is trying to call setPasswordDisabled on
org.apache.struts.action.ActionMapping instead of my LoginAction class.

I remember being confused about this, too. When struts-config.xml gets run through the Digester, an <action> tag causes the creation of an ActionMapping object. So any properties you specify in <action> are part of an ActionMapping object. An ActionMapping has a 'type' property that is the class name of the Action that will be created. (Type actually comes from ActionConfig.) Later, some other part of Struts will call getType() on the ActionMapping object and will instantiate your Action class. How do you create your own ActionMappings? I know I read it somewhere... It's covered in chapter 7 of "Struts in Action" but I can't find more than this in the Struts docs: http://jakarta.apache.org/struts/userGuide/building_controller.html I generally just use <context-param> (in web.xml) and context.getInitParameter().


---------------------------------------------------------------------
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]



Reply via email to