I'm looking for guidelines for how to best implement web page navigation logic for a Spring based web application. For example: I have a web page 'C' where if I click ok, I want flow to return to page 'A' if that was the previous page, or page 'B' if that was the previous page. I am currently using hidden fields on a page to track from which page I arrived...but I think there must be a better way...
You can use flash scope bean for saving the view Url from which you are redirected.
You can read about flash scope from this page:
http://blog.smartkey.co.uk/2011/01/implementing-flash-scope-in-java-web-applications/
See me response from this post. it Explains how to implement Flash Scope in SPring MVC environment.
Spring MVC custom scope bean
with this scope you can alway retrieve the URL form which you will redirected and then build link form the value retrieved.
Hope it helps.
My suggestion would be to use Spring Web Flow (http://www.springsource.org/webflow).
It's intended to do exactly what you want. Control the flows between pages.
I start using it a couple of month ago and I love it.
Related
ASP.NET 4.51, MVC 5
Have read Integrating a CMS into an established application-centric MVC website
We have a number of MVC applications that serve as public facing websites. The applications were built using MVC as that was the technology stack understood by the developers and primarily the content that was being delivered was based on business process data.
However more and more we are being asked to add "another page" to the websites which for all intents and purposes is a plain old static content page. This ultimately involves:
Adding a new route
Creating a view with the required HTML
We have various "home grown" solutions which now pull HTML from the database for these views. However this means we are writing custom back end data entry screens as well as 1 & 2 above.
So.... There must be a better way. Has anyone got any practical experience or suggestions on how to add simple CMS functionality that we can give to end users, plugged into our MVC application? We need to provide the following functionality to the end user:
Create new pages, edit pages using WYSIWYG
Add meta tags and canonical tags for SEO
Specify the url portion of the uri for SEO purposes
All insights appreciated.
Is it feasible to do the following:
Have a database table to house the content for these pages. e.g. title, summary, description, url, meta, image(s) etc...
In the front end have a template for these pages. The database data fills in the placeholders within this template.
Perhaps hold all the pages on a base URL like www.yoursite.com/page/dynamic-page-url-from-db
You can use the Remote attribute validation on the url field to make sure they are all unique in the database.
With this in mind, create a single Route to catch the requests and filter valid/invalid requests in the Page controller based on the URL provided with the db. If non-existent throw new HttpException(404, "Page Not Found"); and have an error handler pick that up and deliver your 404.
META could be set via ViewBag or a dedicated section that alters the _Layout file at the point of rendering the view.
TinyMCE is a decent WYSIWYG editor. You can even add dynamic image gallery functionality to it if you want to embed images within the main body of the pages.
I'm working on making a CMS currently used in a demanding production environment into a product. I've just (as of 20 Jan 2015) made a NuGet package which installs the CMS into an MVC project which should be possible to add to any existing MVC site without breaking it. CMS functionality can then be added where needed. Currently I'm looking to work with some users to help them get the CMS into production on their sites, however this may have changed by the time you read this. Look at http://www.lynicon.com for more information and to sign up to a Slack community where I can give you access to the NuGet package.
I am doing a small ASP.NET 2.0. site refactoring.
Currently there is the following folder structure:
/siteroot/services/home/service1
/siteroot/services/home/service2
/siteroot/services/home/service3
...
all the folders (service1, 2, 3) contain an almost identical default.aspx, with the different content hardcoded into the web form declaration.
My idea is to create one service.aspx and serve custom page (with the same template) on a particular URL request.
My question is:
How can I redirect all request to ../services/home/service1,2,3 to one particular handler/aspx page?
Preferably not to have those folders in the project structure at all, but intercept a requests that are headed to them.
If you are able to implement ASP.NET 3.5 (runs on the 2.0 CLR), then Routing sounds perfect for what you need to achieve. With this you can intercept URLs based on a particular format and then route them through to a single page or handler. You won't need a folder structure for each of your services.
Here's a few links on how to get going with it in ASP.NET WebForms. It's pretty quick to implement:
http://msdn.microsoft.com/en-us/magazine/dd347546.aspx
http://msdn.microsoft.com/en-us/library/cc668201%28v=VS.90%29.aspx
http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx
http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx
One way:
Create a custom handler class that implements IHttpModule
In Init(HttpApplication application), register a method for application.AuthorizeRequest
In this method, parse ((HttpApplication)sender).Request.Path as appropriate, using HttpContext.Current.RewritePath if necessary to point to a "real" service.aspx page.
Then register your custom handler in <system.webServer><modules>.
Another way is to use the MVC-style routing, which works without MVC just fine. Details are in the answer to the question here: custom URL Routing in asp.net.
I am building a website, within a large intranet, that wraps and adds functionality to another site within the same intranet. I do not have access to the other site's source and they do not provide any api's for the functionality they provide. I need to, somehow, have my server-side code go to that site, fill in some forms, then press a submit button.
Is this possible? If so, how can I accomplish this?
Note: I am working in asp.NET if that matters at all.
Not the most efficient, but maybe WatiN can get you started:
http://watin.sourceforge.net/
Just look at the URL the form is supposed to submit to and the method it employs (POST or GET) and then send a request to that URL using the same method and put the field you want as parameters
Your server-side code is basically a web client to the other web site. You will need to write the code to send the HTML form data to the other web site and process the response. I would start with the System.Net.WebClient class. Take a look at System.Net.WebClient.UploadValues. That class/method will enable you to POST the form data to the web site via a NameValueCollection.
Here is the scenerio:
We have an application running on Webphere Portal Server 6.1 and Spring MVC. There is a page with a single portlet that shows a grid full of records. Once one of those records is clicked, it must navigate to another portlet that resides on a different page - possibly even a different portlet application on the same portal server - and display that specific record.
Here's the question:
I've read that, through the use of Portal 2.0's "Public Render Parameters", you can share data between portlets - and that should solve most of my problems. The trouble is, I cannot find how that works when using Spring MVC. I can't find a reference to "Public Render Parameters" in the spring MVC technical documentation, yet some people have said they have it working. Can someone show me specifically where the detailed documentation on this is, or give me small code snippit of an example that shows how I can access these public render parameters in my controller classes? Also, if there is a better way to achieve this in my environment, what is it and where can I find an example? Please don't answer with, "If you need to do this, you shouldn't be using a portal" or "If you use XYZ technology instead, then you can do this and that". I cannot change the environment - it is what it is - I just need to make it work! :) Thanks!
You can use public render parameters in the same way as you use your own
render parameters. You just have to declare them in your portlet.xml.
Just be aware that you are not allowed to have public render parameters that
have the same name as "private" render parameters.
You only need to add something like this to your portlet.xml:
<public-render-parameter>
<identifier>myParam</identifier>
<qname xmlns:x="http://sun.com/params">x:myParam</qname>
</public-render-parameter>
and add the following line to your portlet descriptor:
<portlet>
. . .
<supported-public-render-parameter>myParam</supported-public-render-parameter>
</portlet>
Then you can use the regular getRenderParameter calls for "myParam" in all portlets that have this entry in their portlet descriptor.
For more information:
http://blogs.oracle.com/deepakg/entry/jsr286_public_render_parameter_feature
In an ASP.Net MVC 1.0 applicati0n, is it possible to access the application settings (MyProject.Properties.Settings.Default.*) from inside my View (aspx page)?
I've tried but the intellisense and compiler don't like it. It says that it is inaccesible due to the protection level.
I had a similar issue to Saajid Ismail where my settings were in the namespace.Properties.Settings.Default.Setting they were there as they are strongly typed..
To make them accessible I simply had to change the access modifier
Your View should only be responsible for rendering data given to it by the Controller. It's responsibility is for layout. So I would recommend passing the Application data to the view from within your Controller action.
Having said that, the technical answer to your question is that ViewPage derives from Page, so you can simply do this:
<%= Context.Application["setting"] %>
But again, I don't recommend it.