On Mon, 2002-07-22 at 00:04, Matt Feifarek wrote:
> | 1. Multiple submit buttons on the same page and submit with "Enter".
> | Problem: Browsers have undefined behavior with regard to multiple submit
> | buttons on the same form.  Some of them provide the name=value pair of
> | the first submit button of the form some don't provide any name=value
> | pair of the submit buttons.
> 
> That's weird. If a form was submitted, the relevant submit button should
> show up in the fields. I've never seen this. Can you tell me a little more?

If you are on a text field and press enter and the form submits, the
behavior is inconsistent between browsers.  Some pass the first submit
button of the form, some pass no submit button key,value pairs.  So I
wanted to also force the user to press a button to remove ambiguity
about which action was intended.

> 
> 
> | 2. Unable to use JavaScript to define the _action_methodName style
> | actions.
> 
> Why not just use multiple submit buttons? Barring that, you could have the
> value of _action_methodName be something like "save" or "delete" or
> whatever, and do your logic inside of servlet.methodName().
> 

I am using multiple submit buttons on the form.  The above explains why
I'm having issues.   If a user presses enter, then it is undefined which
action is sent to the server.

[...]
> 
> If you HAVE to use forms (even POST submit types) just do this:
> 
> - put an "onClick()" on the submit button
> - triggered from that event, change the target action of the relevant <form>
> tag to
>    "target?_action_someArbitraryAction=1"
> - run myform.submit() from your script.
> 

I was under the impression that query strings for form actions wasn't
exactly legal HTML.  This would/could cause problems with action="get"

<snippet from http://www.w3.org/TR/html401/interact/forms.html>

* If the method is "get" and the action is an HTTP URI, the user agent
takes the value of action, appends a `?' to it, then appends the form
data set, encoded using the "application/x-www-form-urlencoded" content
type. The user agent then traverses the link to this URI. In this
scenario, form data are restricted to ASCII codes.

</snippet>

> Bingo. I do this a lot, too.
> 
> By the way, if you're interested in forms and webware, check out either Ian
> Bicking's "FunFormKit" http://funformkit.sourceforge.net/ or my own
> "FormKit" http://dalchemy.com/python/formkit.

I've looked at these, but have yet to invest the time necessary to grok
them completely.

> 
> | Proposal:
> | [...]
> 
> The problem with the "old" way is that one would then have to put the value
> of a submit button as the action to be called. Unfortunately, HTML wants the
> "value" of the submit button to be what effectively is the button label. SO,
> what if you wanted your button to be [ Make a new Sailboat ]? Obviously,
> that's not a valid python methodname.
> 
> 

Here was my solution, and my reason for asking for the change in the
action handling in Page.py.

<script language="JavaScript">
    function checkForAction(form){
        return form.elements["_action_"].value.length > 0;
    }
    function submitFormWithAction(btn){
        var el = document.forms["leadCreateForm"].elements["_action_"];
        //alert(btn.name);
        el.value = btn.name;
        document.forms["leadCreateForm"].submit();
    }
</script>
<form method="post" name="leadCreateForm" action="LeadInformation"
onSubmit="return checkForAction(this)">
<input type="hidden" name="_action_" value="">
<input type="text" name="first_name" value="Joe">
[...]
<input type="button" name="changeLeadInformation"
onClick="submitFormWithAction(this)" value="Update All Sections">
[...]
<input type="button" name="changeLeadContactInformation"
onClick="submitFormWithAction(this)" value="Change Contact Information">
</form>


The only problem that I have with the current action handling is that
the "old style" is handled differently that the _action_methodName
style.  My proposal is that the "old style" section is changed into a
configurable option, and that support for "old style" is added to the
logic for _action_methodName style actions.

This would mean that the now configurable "old style" section moves
above the current _action_methodName section, and the _action_methodName
section now looks for 

req.hasField('_action_') and action == req.value('_action_')

This would consolidate the action handling and still allow anyone using
TRUE "old style" actions to turn that functionality on.

--Karl

> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
-- 
Karl Putland
Director of Technical Operations
ShipEze Inc



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to