Tuesday, March 28, 2006

HTML A tag vs. POST

Just an observation. If it is so damned important that GET operations be non-state changing and idempotent (blah blah caching, design of HTTP, firewalls, etc.) ... if it is so damned important that you never change anything expect using POST (and then send a redirect afterwards) ... tell me why the <a> tag does not support a METHOD attribute, the way <form> does. I mean, think back a few years, at all the crazy tags Netscape and Microsoft put into their browsers, and they miss this? Still?

I mean, this hasn't changed in years, and has consistently held web development hostage to the use of JavaScript to keep any non-trivial page from featuring a big old submit button. Apparently, the Powers That Be are afraid that without a big old submit button, we won't realize that hitting the "delete" key is going to delete something.

Sure JavaScript is all pervasive now, and you can force a form to submit using JavaScript ... and the use of Ajax will eventually mean that any non-trivial operation will be coded using XmlHttpRequest (which will do a post). Someday. For users with JavaScript enabled. But I just want to be able to write:

<a href=". . ." method="post">delete this report</a>

10 comments:

  1. Anonymous10:16 PM

    Just to mention: there is FormLinkRenderer on t-deli that allows you to do things like
    <span jwcid="@DirectLink" renderer="ognl:@org.mb.tapestry.link.FormLinkRenderer@RENDERER">
    and have your link submitted using POST if you have JavaScript.

    But I completely agree -- <a> should have had a method argument, especially with the limitations in URL size.

    ReplyDelete
  2. Anonymous11:25 PM

    I've often wondered about the same thing :-/

    ReplyDelete
  3. Anonymous11:38 PM

    Well, it isn't that strange considering that HTML was created for document markup primarily. Right now we are all using it for application front-ends. Hopefully future specifications from W3C will cater for this (you may want to check out XHTML 2 and the Xforms module ready for use by 2010 or so).

    Rails actionview helper methods handles a delete button by creating a minimal form around an ordinary "input type=button" element.

    ReplyDelete
  4. Anonymous11:46 PM

    Nice rant there Howard

    ReplyDelete
  5. Anonymous12:29 AM

    There is a workaround though - you could style a submit button to look like a link, or even hide it completely if you just want to trap keyboard shortcuts.

    ReplyDelete
  6. Anonymous12:46 AM

    Amen

    ReplyDelete
  7. Just playing Devil's Advocate for a minute, looking at the opposite point of view: we've done fairly well without this for a while now, so why add it? Wouldn't it be bloat? What does it enable that you absolutely couldn't do otherwise?

    (I don't have a particular opinion, just curious to hear your reasoning)

    ReplyDelete
  8. Anonymous1:02 PM

    yoav, read again howard's post! there are so many useless tags, while this little "method" argument would have saved so much time without being "bloat". why use javascript "workarounds" (the real "bloat") while a simple attribute could do the same?

    howard, that was a good one!

    ReplyDelete
  9. Anonymous2:11 PM

    Now you could use some CSS-fu to style a button like a link... like this (it doesn't quite work in IE, though):

    <html>

    <head>
    <style>
    body {
    margin: 0;
    padding: 0;
    text-align: left;
    }
    a, .sublink {
    border: 0;
    background-color: #fff;
    text-decoration: underline;
    color: #00f;
    font-size: 12px;
    font-family: Verdana, Arial, sans-serif;
    cursor: pointer;
    padding: 0;
    margin: 0;
    }
    .sublink:active {
    padding: 0;
    }
    form {
    margin: 0;
    padding: 0;
    }
    </style>
    </head>

    <body>
    <p><a href="test.html">test link</a><br /></p>
    <form>
    <input type="submit" class="sublink" value="test button" />
    </form>
    </body>
    </html>

    ReplyDelete
  10. Anonymous3:18 AM

    Amen!

    That forms cannot be nested makes using a proper POST damn near impossible on many designs.

    ReplyDelete

Please note that this is not a support forum for Tapestry. Requests for help will be deleted. Please subscribe to the Tapestry user mailing list if you are in need of support, or contact me directly for professional (for pay) support.

Spammers: Don't bother. I delete your comments and it's a waste of time for both of us. 垃圾邮件发送者:不要打扰。我删除您的评论和它的时间对我们双方的浪费