Express redirect to a results page after a form post - express

I am currently working on an express application that uses handlebars to render templates for html to be delivered to the browser.
On one of the pages I have a form, this form data needs to be posted to a route in express, once the form data is received I then build a new object so I can then do a further post from express to an api, this api should then return some data back to the express app for me to then render this new data to a new view.
So post from form to a route say '/searh'.
In the search route I build a new object with the submitted for data.
This new object is then posted to an api.
This api should return some data.
With this new data I will pass this to my handlebars template to
render a new page showing these results
e.g. the search page is '/search' and I need to show the results in '/resuls'
I am just now sure how I can achieve this in terms of rendering a new page based off of the returned results.
Any help greatly appreciated.
Thanks,

Related

Net Core 6 - posting between razor pages

Is there a way to post between razor pages without disabling the Anti-forgery Token? I appreciate that sounds stupid, but what I'd like the user to be able to do is submit a mini version of the contact us form on one page and the submit action takes them to a different razor page where they can continue to fill in the rest of the form. It's essentially so we can include a mini contact us form in the footer of all pages as a view component. The view component can't handle the post because there is no endpoint for the view component. Whereas this could probably be achieved by carrying the form data on the query string, that then exposes their name/email data which is undesirable. Adding the [IgnoreAntiforgeryToken] attribute on the contact us page works, but is there a way to make it work without removing the validation/checks?

I am needing to do an internal link that is in FAQs on a site using Vue 3 and Inertia.js?

I have an array of content coming from a database that will be displayed on a page as a group of FAQs. Some of the content will have links to other internal pages on the site. How do I link to the pages using Inertia's link component so that a full page refresh doesn't happen?
It depends on what is returned after using the link. If you return a full view in the response, the page is reloaded. If you return a small JSON object or something else, you can process it without full loading.

I need to display data form API in tabular form in wix

In my website i have to show data in tabular form which I am getting from API. I successfully integrated API and I am getting response from that API but the problem is I don't know how to show it in a tabular form in Wix.
I tried dynamically adding HTML code in script file but it is not working. Please let me know if there is a way I can do it.
You can put your data in a table element using the rows property.

Programatically render template area in Magnolia CMS

I search for rendering specific content in Magnolia like components with Render Engine So I found this topic on stackoverflow : Programatically render template area in Magnolia CMS
My question is about the structure of the following classes : FilteringAppendableWrapper and
FakeResponse : used to put fake Http Response in the AppendableFilteringResponseOutputProvider
Thanks for any help.
What about it do yo want to ask? Why he didn't use the real response? Because he was faking whole (web) request to a page too and then getting output from his "FakeResponse" and adding it to json array to fill in body of the response of a request that came over REST.
Personally, I think such solution is overkill for the job and if I had to do the same, I would probably simply register variation template for a component or whole page and when requesting page w/ e.g. .ajax extension I would have my variation to kick in and rendered whole page (or area or component) as a json array.
HTH,
Jan
There is no need for fake response. This simple code work well :
Session session = MgnlContext.getJCRSession("website");
Node content = session.getNode("/protoTest/content/01");
componentDefinition = templateDefinitionAssignment.getAssignedTemplateDefinition(content);
OutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(outputStream);
appendable = new AppendableOnlyOutputProvider(writer);
renderingEngine.render(content, componentDefinition, new HashMap<String, Object>(), appendable);
((Writer) appendable.getAppendable()).flush();
System.out.println(outputStream.toString());

Get the HTML output data from a wicket component

I'm currently writing a web widget, and I would like to fill the content of this widget with some HTML data generated by a wicket component on my server.
To do that, the server will output the HTML data via JSONP. So far so good.
However I need to get this HTML data. How can I get on the server the HTML output from some wicket component?
I dont know if this can be applied to your configuration, but I am using a view lines of code to retrieve rendered html which I wrote some time ago for building html based emails to be able to use wicket components in it
protected final String renderPage(Component page) {
final Response oldResponse = RequestCycle.get().getResponse();
BufferedWebResponse tempResponse = new BufferedWebResponse((WebResponse) RequestCycle.get().getOriginalResponse());
try {
RequestCycle.get().setResponse(tempResponse);
page.render();
}
finally {
RequestCycle.get().setResponse(oldResponse);
}
return tempResponse.toString();
}
As this rendering is made within an actual webapplication cycle but independently from the actual requestcycle, it is recommended to preserve the original requestcycle. The page will be rendered in your temporary webresponse from which you can retrieve the rendered html output.
Hope this may be what you are looking for
You might find everything you need in this Wicket Wiki article and the linked source code: Use wicket as template engine
Although I must admit that I never tried that, just read it and remembered for further reference...