Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 03 JUN 2020 03:47:59PM Mihyar Al Masalma wrote:

Hello all,

I have the following code generated by O4W:

<form id="formmainSection" action="O4W_UPLOAD_DOCUMENTS_INTERFACE" method="post">

    <table id="fileTable" class="table-disable-hover">

        <thead></thead>

        <tbody>

            <tr>

                <td><span class="label">FileName</span></td>

                <td><input type="file" name="FILENAME" id="FILENAME" class="o4wfile"><input type="hidden" name="FILENAME_destination" id="FILENAME_destination" value="upload"></td>

            </tr>

            <tr>

                <td><span class="label">Title: </span></td>

                <td><input type="text" name="FILETITLE" id="FILETITLE" class="normalinput InputWidth"></td>

            </tr>

        </tbody>

    </table>



    <div id="uploadedfiles"></div>

    <table id="buttonTable" style="width:100%;" class="table-disable-hover UNNAMED_32">

        <thead></thead>

        <tbody>

            <tr>

                <td style="text-align:center;" class="UNNAMED_33" id="buttonTable_1x1">

                    <input type="button" id="lnkclose" name="lnkclose" class="buttondlcancel ui-state-default ui-corner-all" value="Close" style="display: none;">

                </td>

            </tr>

        </tbody>

    </table>

    <div id="lnksave_div" class="UNNAMED_35">

        <input type="button" id="lnksave_file" name="lnksave_file" value="uploadhidden" class="ui-state-default ui-corner-all">

    </div>

</form>

when the form is submitted it get submitted twice, the first time with the file info in the Request, the second time is empty.

any idea why is this happening?

cheers,


At 04 JUN 2020 09:04AM bshumsky wrote:

Hi, Mihyar. Can you post the O4W code that you're using to generate the HTML shown above?

O4W sends form data to the host whenever an event happens, but that data does NOT include the file (since doing a file upload of potentially many megabytes whenever a "lost focus" happens, for example, would not be efficient) until it actually gets a 'submit' button. But O4W should only send the data in the current "section" of code, which it tries to figure out for you.

I'm guessing it's related to that functionality. Perhaps by looking at the O4W code, I can tell for sure.

Thanks,

- Bryan Shumsky

Revelation Software, Inc.


At 04 JUN 2020 10:03AM Mihyar Al Masalma wrote:

Hi Bryan,

the following is the O4W code that generate the form above

O4WSectionStart(prefix:'mainSection', O4WMarkedOptions(1))

	destination:= "\":O4WSessionId%:"^.$"

	

	* Use a table to align everything neatly

	O4WTableStart("fileTable","table-disable-hover")

	RowNo= 1



	O4WSetCell(RowNo,1,"","")

	O4WText("FileName" , "", dlweb_classlabel$)



	* upload control	

	O4WSetCell(RowNo,2,"","")

	length			= ""

	name 			= FileUploadId

	id				= FileUploadId

	style			= ""

	O4WUPLOADBOX("", destination, length, name, id, style)

	

	RowNo+= 1

	

	IF Documentflag$ THEN

		* Only show title if document is to be created

		O4WSetCell(RowNo,1)

		O4WText("Title: ", "", dlweb_classlabel$)

		O4WSetCell(RowNo,2)

		O4WTextbox('', '', '', TitleId, TitleId, classinputwidth$)

		RowNo+=1

	END	ELSE

		O4WStore('', TitleId, TitleId)

	END	

	

	* End the table	

	O4WTableEnd("fileTable")



	* info boxes		

	O4WTEXT('', FileIdError, "")

	O4WTEXT('', FileId, O4WTextOptions("", "", 1):@SVM:O4WRawStyle("","margin",0))		;* <p></p> instead of <span></span>



	* Use a table to align everything neatly

	O4WTableStart("buttonTable","table-disable-hover":@SVM:O4WRawStyle("","width","100%"))

	

	RowNo= 1

	

	O4WSetCell(RowNo,1,"",O4WRawStyle("","text-align","center"))

	O4WButton("Close",  prefix:"lnkclose", "buttondlcancel":@SVM:O4WMarkedOptions(0))

	O4WQualifyEvent(prefix:"lnkclose", "click")

	O4WQualifyEvent('', "HIDE", prefix:"lnkclose")

	

	O4WTableEnd("buttonTable")

	

	* hidden upload button.  If the browser does not support <canvas>, then this is the submit button.

	O4WSectionStart(prefix:"lnksave_div", O4WRawStyle("","display","none"):O4WMarkedOptions(0))

		O4WButton("uploadhidden",  prefix:"lnksave_file")

		O4WQualifyEvent(prefix:"lnksave_file", "click")

	O4WSectionEnd(prefix:"lnksave_div")





O4WSectionEnd(prefix:'mainSection')

At 04 JUN 2020 02:15PM bshumsky wrote:

Hi, Mihyar.

What is this block of code for?

* hidden upload button. If the browser does not support <canvas>, then this is the submit button.

O4WSectionStart(prefix:"lnksave_div", O4WRawStyle("","display","none"):O4WMarkedOptions(0))
	O4WButton("uploadhidden",  prefix:"lnksave_file")
	O4WQualifyEvent(prefix:"lnksave_file", "click")
O4WSectionEnd(prefix:"lnksave_div")

Thanks,

- Bryan Shumsky

Revelation Software, Inc.


At 04 JUN 2020 04:23PM Mihyar Al Masalma wrote:

Upload button will only show when a file is added, there is a JS code that makes it visible when a file is chosen


At 05 JUN 2020 08:36AM bshumsky wrote:

Upload button will only show when a file is added, there is a JS code that makes it visible when a file is chosen

OK, thanks. I've got a couple of questions:

- When you originally asked about the 2x form submission - are you seeing your O4W code getting called twice, and that's the problem? If so, what event(s) are you seeing get passed in? Or are you just "aware" that the form is submitted twice through some other means (for example, watching in the debug console of the engine server, or the browser's debug controls)?

- Have you tried a simple, straightforward O4W test (with just an upload control and a button, and without your extra hidden button and javascript to show/hide it) to see if that makes any difference?

Thanks,

- Bryan Shumsky

Revelation Software, Inc.


At 05 JUN 2020 09:05AM Mihyar Al Masalma wrote:

Hi Bryan,

- I have a debug in the click event that I have the button qualified for , this is getting two engines spawned almost at the same time, one of which has info from the form in the request variable, the other doesn't.

- Yes, I actually did. I still got the same results.

Thanks,


At 05 JUN 2020 09:30AM bshumsky wrote:

Hi Bryan,

- I have a debug in the click event that I have the button qualified for , this is getting two engines spawned almost at the same time, one of which has info from the form in the request variable, the other doesn't.

- Yes, I actually did. I still got the same results.

Thanks,

I don't know if I missed it, but what version of OI are you testing this with?

Thanks,

- Bryan Shumsky

Revelation Software, Inc.


At 05 JUN 2020 10:07AM Mihyar Al Masalma wrote:

Hi Brayan,

That would be OpenInsight 9.4.0


At 08 JUN 2020 03:05PM bshumsky wrote:

Hi Brayan,

That would be OpenInsight 9.4.0

Hi, Mihyar. I think the problem is that the way O4W has persuaded browsers to do file uploads (separate from the rest of the form) has, after many years, changed. I have updated the underlying code to use a more "modern" solution (something that's been available since IE 10, 8+ years ago, so not TOO modern). This code is located in one of the javascript libraries that O4W includes. If you would like to give it a test, please send an email to [email protected] to my attention, and I'll arrange to get you a copy. Assuming it all works as designed, I'll then go ahead and post it in the Works download section for general availability.

Thanks,

- Bryan Shumsky

Revelation Software, Inc.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/e8c4a902ee6ec04eaf9f755207650bd8.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1