A slightly better way is to use the html:rewrite tag to generate the action URL in a JS function.

<script>
      function swapAction(control) {
        formAction = document.getElementById("empForm").action;
        if (control.checked)
          newAction = '<html:rewrite page="/CreateEmployee.do"/>';
        else
          newAction = '<html:rewrite page="/UpdateEmployee.do"/>';
        document.getElementById("empForm").action = newAction;
      }
</script>
<html:form styleId="empForm" action="/UpdateEmployee">
    New Employee: <html:checkbox property="create"
      onclick='swapAction(this)"'/><br />
...

That way if you are URL rewriting instead of cookies you don't lose the session.
- Bill Siggelkow



Jason King wrote:

Rick,
Changing the action via js is fairly straightforward and works across any 4+ version browser.
Assuming your form is like so:
<form action="/something.do" name="myForm" method="post">
your javascript would be:
var a = document.myForm.action; // a is easier to type
document.myForm.action=a.substring(0,a.lastIndexOf(".")) + "else.do" ; // replace something.do with somethingelse.do
Rick Reumann wrote:


Jason King said the following on 9/9/2004 2:42 PM:

I'm new to struts but the environment I'm coming from Oracle Designer Web PL/SQL generator has a way to deal with this sort of thing that I'm likely to be using in Struts. Every form has a hidden field in it named z_action and the buttons all have some js in the onclick that populates z_action.



Yes that's what you'd use for a conventional DispatchAction and it works well (and it's what I've always used up until now), but I like the basic behavior of the MappingDispatchAction and want to leverage that as well so I really need an Action that behaves both ways:) (which is why I came up with approach in the getMethodName I described).





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to