Looking at a xaf web app, and click any menu item, and you rewarded with a huge url, directly naming the view AND the business namespace of the BO. WHY? This seems like a carry-over from early days of prototyping xaf. Clients need not see this. Surely we can databaze-ize the static urls, perhaps provide a friendly url text and do a lookup each time? Shove it into an in-memory cache to not impact naviagtion, but surely this has been discussed internally?
thanks for listening.
How to provide short and user-friendly URLs for XAF Web Views
Answers approved by DevExpress Support
Hello,
We've simplified URL customization for ListViews and DetailViews in Web apps with the new RouteManager API in v19.1. For example, you can now customize URLs to match the following highly requested format:
BEFORE:
*/Default.aspx#ViewID=Contact_ListView
*/Default.aspx#ViewID=Contact_DetailView&ObjectKey=ContactId
AFTER:
*/Contact_ListView/
*/Contact_DetailView/ContactId/
To make sure that our future implementation meets your business requirements, we would greatly appreciate it if you test our early access preview version. Read this knowledge base article to learn more about this new capability.
If you have any feedback on this new capability, feel free to post a comment to the T725330 ticket.
Thank you for your time and cooperation,
Arkady
Could you make it configurable for each view by Model (and maybe an attribute)?
Also for default views, could you remove the _ListView and _DetailView suffix?
Following the before, can you provide a convention for variant views, let's say for Contact_ListView_Varied to have the URL Contact/Varied
Does it accept the value of the FriendlyKey for the ObjectKey?
Hello Santiago,
I've created a separate ticket on your behalf (T725330: Web - Suggestions for User-Friendly URLs for Views).
Other Answers
UPDATED by Dennis (DevExpress Support):
To simplify your current solution, we have provided two overridable methods in the built-in DevExpress.ExpressApp.Web.DefaultHttpRequestManager class starting with v15.1.8+:
public virtual string GetQueryString(ViewShortcut viewShortcut) { … }
public virtual ViewShortcut GetViewShortcut(string queryString) { … }
That means that in the simplest case it would be sufficient to inherit from DefaultHttpRequestManager and override these two methods (no need to re-implement IHttpRequestManager from scratch) that will help you cut the amount of code written in FriendlyUrlHttpRequestManager in several times. As before, you will be able to supply a custom DefaultHttpRequestManager descendant in the overridden CreateHttpRequestManager method of the WebApplication descendant. You can find a ready sample in the T406218 ticket.
=========================
I have been mining in the source code to find where could I change the URL creation behavior.
The way I followed was to create a descendant from DefaultHttpRequestManager and override WriteShortcutTo and GetViewShortcutFromQueryString.
I couldn't get rid of the # symbol, because that implied modifying some javascript files, but still I got urls that are quite a lot cleaner.
Attached is the sample project. (I work on VB.NET, sorry no C# version)
Highlights:
Include ModelExtenders\IModelClassFriendlyUrl.vb in the platform-agnostic module project.
Include Utils\FriendlyUrlHelper.vb in the platform-agnostic module project.
Include FriendlyUrlHttpRequestManager.vb in the WebApplication project.
Copy this inside the platform-agnostic module class
Visual Basic Public Overrides Sub ExtendModelInterfaces(extenders As Model.ModelInterfaceExtenders)
MyBase.ExtendModelInterfaces(extenders)
extenders.Add(Of Model.IModelBOModel, ModelExtenders.IModelBOModelFriendlyUrls)()
extenders.Add(Of Model.IModelClass, ModelExtenders.IModelClassFriendlyUrl)()
extenders.Add(Of Model.IModelView, ModelExtenders.IModelViewFriendlyUrl)()
extenders.Add(Of Model.IModelDetailView, ModelExtenders.IModelDetailViewFriendlyUrl)()
extenders.Add(Of Model.IModelListView, ModelExtenders.IModelListViewFriendlyUrl)()
extenders.Add(Of Model.IModelDashboardView, ModelExtenders.IModelDashboardViewFriendlyUrl)()
End Sub
Copy this inside the WebApplication class
Visual Basic Protected Overrides Function CreateHttpRequestManager() As IHttpRequestManager
Return New FriendlyUrlHttpRequestManager()
End Function
Optionally (but recomended) change the FriendlyUrl property of a class (or DC) from the model or apply the new FriendlyUrlAttribute
Optionally (but recomended) change the FriendlyKeyPropertyName of a class (or DC) from the model or applying FriendlyKeyPropertyNameAttribute included in the framework
Friendly List URL:
~/DefaultVertical.aspx#user=list
Old List URL:
~/DefaultVertical.aspx#ShortcutViewID=SecuritySimpleUser_ListView&ShortcutObjectClassName=DevExpress.ExpressApp.Security.SecuritySimpleUser
Friendly Detail URL:
~/DefaultVertical.aspx#user=DOMAINNAME\username
Old Detail URL:
~/DefaultVertical.aspx#ShortcutViewID=SecuritySimpleUser_DetailView&ShortcutObjectKey=4868e72d-e7ea-4844-93f9-77e960697804&ShortcutObjectClassName=DevExpress.ExpressApp.Security.SecuritySimpleUser&Shortcutmode=View
Note:
I've just taken this from the oven, it's still hot. I havent thoroughly tested it yet, so I could be a little buggy.
I'll appreciate any feedback.
Hi,
Attached are the 2 classes that i added to my project:FriendlyUrlHelper.vb and SuiteHttpRequestManager.vb
And in the module.vb i added this method:
Public Overrides Sub ExtendModelInterfaces(extenders As Model.ModelInterfaceExtenders)
MyBase.ExtendModelInterfaces(extenders)
extenders.Add(Of Model.IModelBOModel, ModelExtenders.IModelBOModelFriendlyUrls)()
extenders.Add(Of Model.IModelClass, ModelExtenders.IModelClassFriendlyUrl)()
extenders.Add(Of Model.IModelView, ModelExtenders.IModelViewFriendlyUrl)()
extenders.Add(Of Model.IModelDetailView, ModelExtenders.IModelDetailViewFriendlyUrl)()
extenders.Add(Of Model.IModelListView, ModelExtenders.IModelListViewFriendlyUrl)()
extenders.Add(Of Model.IModelDashboardView, ModelExtenders.IModelDashboardViewFriendlyUrl)()
End Sub
That doesn't show how you show the popup.
Also wich version of DevExpress are you using?
I'm using dev express 16.1.5
The popup is a popup action inside a view controller.I added the action normally to the view controller and the code on the execute event of the action.
The popup is showing as a detailview with save,new,save and close… and not as a normal popup with just an ok and cancel buttons.
Attached are 2 pics:the correct one is when i stopped the code in web application.vb,the false one is when i called the method :
Protected Overrides Function CreateHttpRequestManager() As IHttpRequestManager
Return New SuiteHttpRequestManager()
End Function
I think the problem is on the methods:GetPopupWindowId() ,GetPopupWindowShowActionId(),etPopupWindowQueryString()
But if i put this functions as comment to stop adding shortcut for the popups,i got an error that i should implement these methods…