i am new in playwright. is there any way to send all data to the server? or we have to fill the web page field step by step. i can't understand route.fulfill or other expressions like that.
example for more information:
in below we have a form that have many fields:
enter image description here
can we send all data to the server or we should fill them one of one?
how do "route.fulfill" or other expression like that, work?
Related
I'm sorry for that title is so long.
I have a question about multiple query in one request
Assume that you should upload one picture and its title.
so you could use two mutations in one request like under example.
(explicit mutation)
uploadPicture(File) : String
uploadPictureTitle(String) : String
so I wonder if after getting first URL from uploading picture to storage, i could get URL from first mutation and update title and URL in my database.
I'm looking forward to taking good advice. Thank you!
Current Situation
I have a Web App with an example URL that looks like this
https://script.google.com/a/domain.com/macros/s/Adlksjflf09_LEg8kdlf9/exec?ID=1
This Web App has a doGet(e) function that redirects it to a Google Form URL. Using the example above, it would look like this
https://docs.google.com/forms/d/e/1FAIpQLSfi8jWUK2N4y03N4YYJ9p8Cyr2x06b1C6WgS_TcV98WM_ACtQ/viewform?ID=1
This ID field does not pre-fill any of the questions in the Google Form. Essentially, it's meant to hold information.
When a user submits a form response, I'm combining information from the query parameters as well as the form response and sending it as a payload to a webhook URL.
How I do that is by using CacheService. When a user opens the first URL, the doGet(e) function stores the e.queryString as a Hash in the cache. Then when a user submits the form, I can get the information from the cache and combine it with the formResponse.
The issue I have now is related to concurrency. There will be a case where more than 1 user has opened the first URL. This results in Hash['queryString'] to be overwritten in the cache which is not what I want.
Actual Question
Is there a way to take query parameters from an onFormSubmit from a form and combine it with the form response without using CacheService since my current solution does not support concurrency?
From my understanding, the onFormSubmit trigger doesn't have an e (event variable) for me to do something like a e.queryString to get the query parameters. I may be wrong, need someone to confirm.
OR
Is it possible to cache information in such a way that I can keep track of whose query string is whose and then pull the appropriate information when submitting the form.
I'm developing a form with Symfony2 : several text inputs and one file input (for one picture). I have defined some asserts (maxLength, minLength...) in my entity in order to check the form (isValid).
My problem is : if the user puts bad data in text input (text too long or too short...), he still can submit the form, and error and printed but the user have to re-choose his picture.
As I think it's impossible to keep the picture in the form after bad validation, I should maybe check the form in client side (javascript), before submit.
So, is there an automatic way to do this (to forbidden submit until data are correct)? Can we get the assert minLength, maxLength value in twig ?
Thank you !
Ben.
You can use js validation before submitting the data, using some js form validation tools, but this way you need the replicate the validation logic from the server, so if validation rules changes, you need to modify on both server and client side. I recommend this method to reduce the traffic between client-server.
If you don't want this, use ajax form submitting (example here). You still validate the form using symfony, but the page won't refresh, so you won't lose the attached file. But this generates additional traffic to server, and you also need to implement error displaying using javascript.
I want to insert an image to database and display it in another page. I am using the PostgreSQL database.
My guide suggests that I insert the image with its file path in the database. When displaying, in place of the src attrib of img tag put the path from database. So can I get any help for this .
Please guide me for this or give me link for similar kind of problem.
(I'm a final year student, and feel that this project requirement is difficult).
Your guide is entirely correct. Part of what you are supposed to be learning is problem solving: how to break a big problem down into many smaller, simpler problems you can solve piece by piece. It sounds like it's hinting at this, but expects you to be able to do that yourself, which is pretty reasonable.
You need to break this down into steps, and do each step in isolation. That's how anything but the most trivial programming task must be done.
(It isn't clear if you want to store the image data in the DB, or just a file system path, by the way, so I'm assuming you want to write the file to the local file system and just store the path in the DB).
Anyway, this should be fairly simple JSP. To display:
One JSP that:
Examines the query parameters for the image ID
Uses JDBC to fetch the associated path of the image on the file system from the database (a simple SELECT using the image ID as a query parameter)
Opens the image on the file system as a binary stream; also stats it to get its size
Sends appropriate HTTP headers eg Content-Type: image/jpeg and Content-Length: image-length-in-bytes to the client
Copies the raw image data from the image input stream to the output stream that sends to the client
Another JSP that generates the HTML and has an <img src="/the/image/jsp?imageid=blah"> link in it.
If you're required to submit just one JSP file, you can combine the two by having the JSP show a HTML page if it doesn't receive any query parameters, and send an image if it does receive an image id as a query parameter.
To insert:
One JSP that displays a HTML form with a file upload link if it doesn't get called with any HTTP POST data
If the JSP does get called with HTTP POST data:
** Issue a JDBC INSERT to create a record for the file in the database, but do not commit
** Access and decode the POST data using the methods provided in JSP
** Extract the desired file name from the form data and open a binary output stream to a file on the filesystem with that name
** Copy the image bytes into that output stream, url-decoding if required (the HTTP POST form handling code in JSP is likely to decode it to a byte stream for you, though)
** Flush and close the output stream
** Commit the transaction with the JDBC INSERT.
You should be able to find numerous examples of both with a quick Google search. If you can't, adapting examples from other programming languages should be easy enough.
For inserting you must think carefully about the error cases. That's a large part of proper programming.
I am intentionally not showing you code examples. You should be able to do this yourself if you're a final year student. You won't know everything you need, but by now you should know how to find out what you don't know when you need to know it. Tutorials. Documentation. Google. Writing test programs to figure things out. Method name autocomplete in NetBeans / Eclipse. Adapting sample code. You've got lots of options.
I am trying to link up Mturk to my external Website
I am using the external survey Hit on the GUI requester page
I know that I need to generate the code myself, but I do not know how the code is validated.
In what form or fashion do I, or the Amazon site validate this code? and how do I implement this.
For example: A person gets a code from my website, and pastes it into the box of their amazon hit on the amazon website. Who is that code validated by? and if amazon how to I tell them which codes have been generated?
Thanks in advance!
You would do it yourself. you will find the code that the worker enters on the HIT page in your results file. Than you compare the results file with the list of codes you generated, and approve the correct codes.
A method is described on my blog which is ideal for surveys with lots of participants. Basically, you export the data from both your survey and Mechanical Turk, then you put the code columns side-by-side for comparison, and then you use a formula that takes each row of one column of codes and performs a lookup in the other column of codes. For example, you could use a COUNTIF formula in Excel, which returns a 1 if there is a single match, and a 0 otherwise.