Pass data with react-location from one page to another page - reactjs

Heyy,
Currently I am using react-location for routing and I am new with it.
I want to pass data from one page to another.
Is there any way to do it.I have read the documents but i am unable to find solution of my problem.
Thanks in advance.
I used navigation like this,
navigate({to: `/auth/reset-password`})
and with this i want to pass entered email field data.

Related

Use query string in URL or use multiple URL?

If I want to display many posts in my web application but every post have its own type and I want to display each type in single page so, What's the best method to do that? Is put all all posts in one url and use query string to filter the posts upon the type and display it in the page?
For example : axios.get('/posts?type =sport')
Or I have to put every single type in separate Url
For example: axios.get('/posts/sport')
Also one more question please?
use one reducer to manage every posts or create one reducer for each post type?
you can add a dynamic route to every new type.
Ex:
'/transaction' -> component-1
'/transaction/:type' -> component-any (multiple)
welcome to Stackoverflow!
I can imagine you have a web API of some sort serving a URL /posts. You want to consume that endpoint from your web application, and you are using axios to do that. I can assume you are using JSON to return that data. Correct me if I'm wrong.
Now that the basic information is "clear", what data you serve from the endpoint, and how it is requested from the client is up to you. Do you want to ask the server what types are there first, and then do one AJAX request per type? Ok. Do you want to serve all posts independent of their type? Ok. Do you want to accept POST data in your controller so you can filter the results before returning a response? Ok.
If you are looking for a more specific answer, you must give more details, or specify more. But I hope I could be of help.
Edit: complete answer.
If you want to filter the results, you have to send some additional data in your POST request, in this case, your post type. In axios, this could be done like this:
axios.post('https://example.com/posts', {
type: 'sports'
}).then((data) => {
console.log(data);
});
You can obviously get the "type" value from a select input, other variable, even the current router page. I don't know your exact setup, but you can always come back and ask ;)
THEN, in your API controller you have to get that POST parameter type, and use it to filter the results. Again, I don't know your exact setup, but for MySQL if would be a WHERE statement in your query, or similar.

AngularJS - how to use a route with dynamic data for template

I'm not sure what I'm fully after really hence this could easily be a duplicate of another topic - if so please direct me :)
Anyway, what I want to do is something like a shopping page, where there is a page listing out all the items. This part I can do fine :)
The issue I have is I only want one page which "details" each item - as they all share the same layout. So in this case, depending on what's selected, it routes to a details page (maybe with corresponding ID of some sort) that displays the details of whatever clicked.
Is this possible? Hope I've explained this well enough - if not please let me know.
TIA
You don't need to use a route for each item. You can use a route for the page itself (with ngView, for example) to present the details page, and then (assuming you have an object with the data) you present the current item's model appropriately.
If you can present some code I can give you a better idea.

cakePHP Paginator::numbers() function does not include a page:1 parameter in the link for the first page

I have been trying to create a component like the Bakery's Paginator Recall that would allow me to save pagination data for CakePHP 2.4 and run into the following issue.
All solutions involve saving the Paginator parameters in the session and then retrieving and applying them upon returning to that same page without specifying any.
This approach would have worked if only the Paginator helper functions like numbers(), first() and previous() would include the page:1 named parameter in the links that they generate for moving to the first page like the corresponding function of the 1.3 version.
Unfortunately all of these functions create URLs without the page parameter when they refer to the first page, so when users click on the first page link, the component does not find any paging info and hence it returns them to the previous position.
There must be some way to work around this, but for the moment I am completely stuck.
NOT including the page number in the link to the first page is by design.
Read the reason on the CakePHP 2.4 Migration guide.
I would suggest to use the same convention. When you do not have pagination information assume is page one, and do not add it to your URLs.
So all you have to do is code this special case when then pagination is missing. And in this special case your "recall" component will simply not add that page.
I believe that I have managed to create a working solution. Thanks to the advice I have received I have now created a working component like the original PaginationRecallCompoent.
I have written all the details in the following blog post.

How to pass url parameters without showing them to the end user in Salesforce?

I want to pass a url parameter in salesforce, but it shouldn't be visible to the end user in the url. Is it possible? Please suggest if there are any other alternatives? Thanks in advance.
In my scenario, I am dealing with 2 pages with individual controllers. In one of the page I am dealing with apex tabs. So I want to get the current tab name. I found the solution for this as passing it into to the url.
You don't have to pass parameters between pages using the URL, you can do this using form parameters which will "hide" the values from the user (nothing displayed in the URL) like this:
<apex:param name="contIdParam" value="{!cont.id}" assignTo="{!contIdChosen}"/>
This article may be helpful: http://bobbuzzard.blogspot.co.uk/2011/07/passing-parameters-to-apex-method-from.html

DotNetNuke Switching Between Multple Edit Modules

I have a custom module in DNN 7 that has a data structure where items belong to categories (called "sections", not DNN taxonomy, just a simple list of section names). The module edit screens work so that on the view control you may click on an edit link on each category, which loads the category edit screen (passing the category id). This works great, and when you save I use Globals.NavigateURL() to return to the view screen. This all works as intended.
On each category edit screen I also have a list of the items within that category, each with an edit link. Clicking the edit link opens the item edit screen, passing the correct item id, and allowing me to edit that item. This all works great, until you save. The save works properly, but when I want to send the user back to the edit screen for the category it doesn't work. When I use:
Response.Redirect(EditUrl("SectionId", sectionid.ToString(), "EditSections"), true);
...nothing happens. It simply doesn't redirect anywhere. This is exactly the same URL I'm using to get to the category edit page in the first place:
EditUrl("SectionId", Eval("SectionId").ToString(), "EditSections")
And then I use a similar URL to get to the item edit page:
EditUrl("ItemId", Eval("ItemId").ToString(), "EditItems")
I don't understand why using the same URL to navigate to the same page I already navigated to would simply not do anything. For now I am sending them all the way back to the view, but it's painful if you need to add several items to the same category to have to navigate back into the category and add another item, only to be sent back to the view.
Anyone see anything like this before?
Have you tried to use the overload of NavigateUrl instead of EditUrl?
Globals.NavigateURL(TabId, "EditSections", "mid", ModuleId.ToString(), "SectionId", Eval("SectionId").ToString())
I haven't seen that myself but I would have to assume that somehow the context is being lost with EditURL and you're not getting sent to the proper location due to that.
I would suggest you try one of two things (or both).
Debug the URL that EditURL is returning and see if you can find the
difference.
Use NavigateURL for all your links and pass in MID=## for your
moduleid as a querystring parameter, to ensure that the proper
values are being passed.
UPDATE: If you're trying to have multiple edit views, and move between them, you might look at using a "loader" instead of having separate module definitions for the edit controls. Basically have a single Edit.ascx file defined, and it loads other ASCX files within it, injecting into a Panel. The View control on this module http://dnnsimplearticle.codeplex.com/ does that, but I haven't tried it with an edit control before.

Resources