Opened 11 years ago

Closed 10 years ago

Last modified 8 years ago

#8117 closed defect (duplicate)

dijit.form.Button causing item to appear in HTTP post content sent to server

Reported by: scott.a.jenkins Owned by: bill
Priority: high Milestone: tbd
Component: Dijit - Form Version: 1.2.0
Keywords: dijit.form.Button, HTTP post Cc:
Blocked By: Blocking:

Description

Summary: dijit.form.Button has a dummy input control somewhere which is posting data to the server.

Details: In a Domino based web application using Dojo, in troubleshooting a bug where the server is not accepting the data posted by the web form, I discovered that an unnamed item is being sent in the post data.

By unnamed, I mean in the raw HTTP post, it is sent as

&=value

where there is no text between the ampersand and the value.

The value being posted is:

<SPAN class="dijitReset dijitInline" _zipIdx="2" dojoAttachPoint="iconNode" unselectable="on"><SPAN class="dijitReset dijitToggleButtonIconChar" _zipIdx="2" unselectable="on">â??</SPAN></SPAN><SPAN class="dijitReset dijitInline dijitButtonText" id=pickPersonButton_label _zipIdx="2" dojoAttachPoint="containerNode" unselectable="on">Pick Person from Address Book</SPAN>

This appears to be generated by a dijit.form.Button control on the page, whose source is:

<button dojoType="dijit.form.Button" id="pickPersonButton" onclick="pickPerson();">Pick Person from Address Book</button>

Note: I had also tried this with <DIV> tags and the result is the same.

I am attaching the full source of the page as generated by the Domino server--it uses some pretty large Dojo based tools in the mojo namespace, which is my private namespace. I can provide that source if asked, but I am pretty sure that most of the mojo namespace code has no effect, since it is all about doing AJAX calls to fill the inputs on the form.

Due to the way Domino's autogenerated code interacts with dijit.form.Form, I have not used that widget. Instead, that code is simulated, by binding mojo.form.validate() to the submit action of the form domNode.

I am attaching the source code for mojo.form.validate as well, in case it is relevant.

I will try to follow up with a simpler test case, but I wanted to get all of the base information in this ticket.

Attachments (3)

pageSource.html (22.2 KB) - added by scott.a.jenkins 11 years ago.
validate.js (2.0 KB) - added by scott.a.jenkins 11 years ago.
Source code to mojo.form.validate() method
testButtonSubmission.html (1.7 KB) - added by scott.a.jenkins 11 years ago.
Trivial test case source page

Download all attachments as: .zip

Change History (10)

Changed 11 years ago by scott.a.jenkins

Attachment: pageSource.html added

Changed 11 years ago by scott.a.jenkins

Attachment: validate.js added

Source code to mojo.form.validate() method

Changed 11 years ago by scott.a.jenkins

Attachment: testButtonSubmission.html added

Trivial test case source page

comment:1 Changed 11 years ago by scott.a.jenkins

I now have a much simpler test case, which demonstrates that there is no interaction with the mojo tools or Domino server generated code.

This trivial form generates the following post data:

=%3CSPAN+class%3D%22dijitReset+dijitInline%22+_zipIdx%3D%222%22+dojoAttachPoint%3D%22iconNode%22+unselectable%3D%22on%22%3E%3CSPAN+class%3D%22dijitReset+dijitToggleButtonIconChar%22+_zipIdx%3D%222%22+unselectable%3D%22on%22%3E%E2%9C%93%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN+class%3D%22dijitReset+dijitInline+dijitButtonText%22+id%3Dverify_label+_zipIdx%3D%222%22+dojoAttachPoint%3D%22containerNode%22+unselectable%3D%22on%22%3EVerify+Dojo%3C%2FSPAN%3E&testInput=default&=%3CSPAN+class%3D%22dijitReset+dijitInline%22+_zipIdx%3D%223%22+dojoAttachPoint%3D%22iconNode%22+unselectable%3D%22on%22%3E%3CSPAN+class%3D%22dijitReset+dijitToggleButtonIconChar%22+_zipIdx%3D%223%22+unselectable%3D%22on%22%3E%E2%9C%93%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN+class%3D%22dijitReset+dijitInline+dijitButtonText%22+id%3DsetTestinput_label+_zipIdx%3D%223%22+dojoAttachPoint%3D%22containerNode%22+unselectable%3D%22on%22%3ESet+Test+Input%3C%2FSPAN%3

Note the empty inputs from each dijit.form.Button in the post.

I am attaching the trivial test case html file.

comment:2 Changed 11 years ago by bill

Owner: set to Douglas Hays

It's natural for buttons (even vanilla <button> nodes) inside of a form to appear in the post to the server; The reason it's "unnamed" is because you don't have a name= parameter to the dijit.form.Button. So this doesn't seem like a bug. Why don't you add a name= parameter to the button?

comment:3 Changed 11 years ago by Douglas Hays

Owner: changed from Douglas Hays to bill

So native submit buttons do not submit anything to the server if the name attribute is omitted. However, the dijit Button template (as well as all form elements) have name=${name) which will cause the server to receive a string of "=value" when no name is specified in markup, but type=submit. So this is bigger than Button but also applies to all TextBox? widgets. The biggest problem is that name must be specified at node creation time and cannot be deleted on IE. In order to fix this, we would have to add a hook into the template processing. Normally this isn't a problem on the server to receive several unmamed key/vaue pairs since they are almost always ignored (except in this 1 case).

comment:4 Changed 11 years ago by bill

Resolution: wontfix
Status: newclosed

I see. Given the IE problems I don't see a good solution to this. I'm going to mark it as wontfix, with the workaround listed above, that the user needs to specify name=xyz on buttons. That will solve the problem w/your web server.

comment:5 Changed 11 years ago by scott.a.jenkins

Resolution: wontfix
Status: closedreopened

I disagree with your decision to simply mark won't fix for two reasons, although I understand the actual behavior may be a result of a browser bug in IE:

1) The domNode that Dojo is synthesizing is getting a (very large) value attribute from Dojo, which is being sent to the server. Even if no other fix is implemented, then the value should be the empty string to reduce the bandwidth of posts to the server, especially from forms with large number of dijit.form.Button's on them.

2) If the name attribute is required, perhaps dojo should synthesize it (using the ID attribute) if it is not there, to make this more transparent to the naive coder who simply uses the widgets. After all, we use Dojo in part to mask the complexities of the various browsers.

Thank you very much for your feedback on this issue.

comment:6 Changed 10 years ago by bill

Resolution: duplicate
Status: reopenedclosed

Looks like Doug has summarized this issue in #8484, closing this as a dup.

comment:7 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.