I have converted an MVC application to .net6. The controllers have attributes [AutoInvalidateCacheOutput] and InvalidateCacheOutput[...]. How do we effectively replace those attributes in .net6? The documentation doesn't seem to include a replacement
Related
In order to allow us dynamic control over labels and error messages, we created a custom DataAnnotationsModelMetadataProvider. In a Display attribute we store the key in the Name property and using the custom DataAnnotationsModelMetadataProvider we substitute the key for a string value from our custom CMS. The problem is that we now have two sets of values. One for Web views and one for mobile views. At runtime we check if the client is on a mobile device and substitute the values accordingly.
After test running this setup I came across a strange issue. When the AppDomain is first created and the Name properties of the different data annotations are replaced with the string values, everything works fine. In debug, when I enter the custom DataAnnotationsModelMetadataProvider for a second time, I see the name properties already populated with the values I had substituted the previous run. This was strange to me, since it was my understanding that data annotation propeties could not be chnaged at runtime. It now seems like there is a model metadata cache happening somewhere. Since I based my custom solution on replacing the values each time the DataAnnotationsModelMetadataProvider is called upon, I would like to disable this caching, if possible.
For now I started using the ShortName property as my key storing property and I replace the Name property, and this way I can repopulate the strings on each run. But this was not the initial design and I don't have such a key store property for ValidationAttributes.
So is there a way to disable this cache? I don't need the cache for the sake of caching, since all CMS data is cached in memory in another layer anyway.
I'm trying to made my project class diagram diagram. In my project, text contents are converted to visuals, i had used strategy and factory pattern for visuals, but currently i'm using php code igniter at server end and i'm not very much aware of mvc pattern in class diagram. so my question is how can i combine them?
Edit: IVisual is used here for strategic pattern (TimeLine, GeoLocation, Relationship sheet are all strategies), and VisualFactory is used as factory class which creates any type of visual.
MVC is designed to separate your concerns between your model(data), your view(html rendered) and your controller (the request/response engine, in your case php controllers).
Your view will contain all the classes that carry your data, for example you will need one or many classes that carry the geolocation of Country XYZ is Latitude:XX and Longitude:YY
Your controller is simply the gateway between your model and your view. for example, the controller will receive a request to http://myapp.com/page1, then the controller connects with the database, brings a model with it and passes it to the view, then the view will recognize that you need to represent the geolocation data and will render the html.
MVC is in a higher hierarchy of software design, usually is embedded in the framework that you use
hope it helps,
I have an idea to read an XML document from the database and generate simple CRUD screens (via Grails) based on the data defined. My application will call RESTFul services to persist the data so I don't need Hibernate on the client side. I have ideas about how to generate the UI but where I'm stumped is in how to perform the validation.
I'll have a single, generic domain/command object that contains only the fields that are common for all instances of this "runtime" data type. All other fields are defined via the XML found in the database. I need something like this:
String xml // defines the fields, constraints, UI information for this data type
def constraints = {
callMyCustomValidator(obj)
}
and in my callMyCustomValidator method, I'll extract the xml for obj and perform my validation as needed.
Note: We have a working example of this in a different app (written in java/servlers/jsp) and without any formal "framework" this isn't difficult to do. Why do I need this? We need to add simple datatypes on the fly (via script) without a release.
You can use the validator to add custom validation to your domain class. Just add this to some of your common fields.
the wicket internationalization example available has the following file structure
HomePage.java
HomePage.html
HomePage.properties
WicketApplication.java
HomePage_nl.properties
Now when creating a project with multiple HTML pages, for example i have
HomePage.html and Login.html, is there a way that i can save all key-value pair in single property for a particular language
or
i will have to have to create all these files
HomePage.properties
HomePage_nl.properties
Login.properties
Login_nl.properties
Wicket will try to find message resources using the following rules:
Wicket will try to find the message starting from the Page and drilling down to the specific Component through the component hierarchy of the Page. Notice this is a top-down search.
When a message is not found in the component hierarchy, it will be looked for in the Application class.
The lookup for a resource in every class works in the following way :
Localised searches appending the locale to the file name (Login_nl.properties, then Login.properties), just like Java's ResourceBundles do.
Down-top through the class hierarchy. That means that if a resource is not found in a class, it will be searched in its superclasses all the way until it hits java.lang.Object.
So, in your specific case, if Login is a Panel inside HomePage, you can just define the resources in HomePage(_nl).properties. Also, if there are specific application-wide messages, remember that you can define them in WicketApplication(_nl).properties.
You might find the following Wicket wiki page : Everything about Wicket internationalization useful, it elaborates on this matter.
(...). This is facilitated by first looking up the message
(following the algorithm above) for every parent in the component
hierarchy (aka page hierarchy). Every component can override the
messages of its child components, so the search starts at the page's
properties and then trickles down to the component that uses it (yes,
its top-down). In order to make overrides specific to a certain child
component, you can prefix the message key with the component id of the
child. See ComponentStringResourceLoader for more details.
If no message was found in the page hierarchy, another search starts
which will look at your application class and its super classes. So
Wicket first looks at MyApplication.properties (provided MyApplication
is the name of your application) and then up the class hierarchy,
passing org.apache.wicket.Application, up to java.lang.Object. This is
how Wicket provides its many default i18n texts.
I have an existing application with a datalayer (primary EF4), a businesslayer (custom code) and a windows application - now I want to create a webapplication using ASP.NET MVC but I am not sure exactly what to do especially in my models.
When my data and business logic already exist how should I structure my Models and Controllers compared to a referenceproject like MVC Music Store v2.0 (http://mvcmusicstore.codeplex.com/)? All my entities are stored in my datalayer and all my methods and logic are stored in my businesslayer so I guess I need no Models (unless I need specific web Models) and I guess my controllers will only need to call the methods in my businesslayer as I would to in a normal webform application?
Another question, if I need to display 2 lists with data from 2 different entities on 1 page I guess I need to create af Model with 2 properties (one for each entity)?
The last one for now, if, for some reason, e.g. a Get method from my businesslayer returns an exception how should this be handled in my Controller/View?
It depends on the complexity of your application. I would at the very least introduce ViewModels for each view so you can supply the view with the data that is required. If your application is light weight it might be fine to use your business layer in the controller. However, you might want to introduce a service layer that interacts with your business layer just to keep the controllers thin.
As for exception handling, you might want to look into the HandleError attribute.