I have a route with a component that displays some form data. When I hit the submit button, I'll navigate to a different route that contains a receipt. If the user hits the back button, I want to remember what was entered in the form. How can I achieve this when using react-router-dom?
What you need is some type of data/state management for your react application.
Mobx is a good example for this. Search up how mobx works and how you can use this together with react.
With Mobx, you can store the user's form inputs in some type of class that you can decorate with mobx (for example DataStore class), which you can then read on your other page when you navigate there with router.
Related
I have some questions about routing using Node.js and Express.
I have a running application where you can add items in different ways (e.g. via 'URL'). Let´s describe that further:
I have to different routes:
/create: Choose adding option in a form with dropdown list (e.g. via 'url')
/create/validate: Form which shows the retrieved data
/create:
When pressing the "Add" button on my main page an GET request on this route will render a form where you can choose the inserting option.
In this form you can choose in a dropdown list one option (e.g. 'URL') and press the "Submit" button. The POST request collect the entered information which are available inside the req.body.
Before sending the entered data to my database I want to perform a validation. That means, the entered data is rendered in a validation form (which is shown to the user) on route /create/validate.
The problem here is, that I can´t send the entered data from /create POST request to the /create/validate GET request for the form.
Right now my /create POST request is redirecting to the /create/validate route and saving the url content in a local variable, which can be then accessed in my /create/validate GET request for further processing.
So summing up:
I want the entered data of the /create POST request available in the /create/validate GET request.
Is there any other way instead of saving the content to a local variable?
The best way is just keep a global variable somewhere outside your http handlers. That data will stick around, between request, on the server side, as long as the node process is running.
Otherwise an other solution is using localstorage for node.js
https://www.npmjs.com/package/node-localstorage
I'm on the web page with the url=x
The url of that particular web page doesn't change after giving my preferences(like selecting options,..) or after clicking the button on that web page.
Problem:
Before performing the above mentioned actions i will not be displayed with any data; but post actions the web page displays the data.
Context:
I'm trying to scrape data from a web page using python
And i'm struck at providing the request_url with the above mentioned specification
if i'm providing request_url=x it is fetching no data because i have provided no specifications
How to provide those specifications while requesting with the url?
kindly address the specification of pressing the button also
Sounds like you're trying to scrape data through real navigation actions, like filling form data and clicking on buttons and/or posting some data, considering whatever javascript scripts contains in the page, but you don't have the specifications to post the data.
My approach would be automating a real browser using selenium, finding the button via xpath or id and calling a click function to it.
driver.get("http://www.google.com")
# Assume the button has the ID "submit" :)
driver.find_element_by_id("submit").click()
I have a nav bar view in my node app which puts the bar across the top of the screen on every page in the site. I would like to allow the user to access their profile from this nav bar, and display the username.
I am aware that I can use app.locals to get a variable from any page, but I want this to be different for different users. Do I need to just pass the username and profile link manually in every route?
You can use res.locals, which is scoped to the current request (as opposed to app.locals which is scoped to the entire app).
Hi i have this application that needs a user to login.
Once the user is logged in, he is redirected to a page displaying documents for that user.
To display that information, I call the correct action on the controller and i pass my user-object. This object contains username and password.
When i look at my url it looks like :
http://localhost:53703/Documents?UserName=bart&UserId=10&Password=AllPhi%242015
Is there a way that I can hide those querystring-values (UserName=bart&UserId=10&Password=AllPhi%242015)
I can not object strongly enough to sidestepping the built in auth-mechanisms, but to answer the question: You cannot hide the query-string.
If you want to hide data when you are sending from a client you need to do a post request instead of a get, but the post-data is still visible in the request (in plain text)
But in this case it seems you want to pass data between actions, and then you want to use tempdata. Look here for reference: http://rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications
What would be the best way to construct a contact form in Drupal 6 for each node of a particular type? I have some CCK nodes of type "profile" which have email address as a field. I want to have a view for each node with a contact form that users can fill out and send with their own email address as a return address (so that further contact is being done offsite).
Basically I just want that initial email contact to be done through my site, and when the recipient replies it just goes to the address that the sender entered when they filled out the contact form.
You might be asking yourself why I don't use the personal contact form that comes baked into Drupal. The issue is that the way my institution deploys their Drupal instances to use the local Kerberos logins, the user accounts it creates in Drupal do not have email addresses. They just get a basic skeleton account with username. I don't really want to force users to go through another hoop of editing their user account info, because they most likely just won't do it.
There is nothing to do particularly with node itself, all you need for this - is form with fields (from, to, subject, message) and custom submit handler for this form.
you can implement all this in custom module using forms API to create form and write custom submit for it. And in this submit you need to send email via drupal_mail() - take a look at this, it is provides examples as well. That topic can help you with forms.
Then, if you need to place this form within a node, you can do the following:
via hook_nodeapi, on "view" operation, add form you've created before, you can check for particular node_type and use existing field values (you mentioned cck field with email) to pre-fill form. So that every time user views node, he sees this form.
as logical continue of your task, I suggest it makes sense to take a look at menu system and create local task (tab) for the node, where you'll display email form.
In general, that's all. There are of course other ways of implementing this, however I think this one is the easiest for understanding.
Regards, Slava