I have two separate projects "CRM" and "WebSite" and with a different databases.
From a view of "CRM", I want to have access to a controller of "WebSite" so how can I do it in eclipse ?
I'm using springMVC4, maven3 and hibernate4.
Suppose you have 2 web application (let's say CRM.war and WebSite.war) and their context are
someDomain/crm
someDomain/website
From view no difference what to call e.g. by AJAX url would be
http://domeDomain/crm/mapping for controller
and you can pass all necessary parameters adding ?someParam=someValue
Related
I have created web application - Asp.Net MVC in .NET Core.
This application contains some Razor Views but I would like to share these views to another application like for example with DLL or like middleware.
Here is some information about example with distribution Controllers but around Views nothing special - https://learn.microsoft.com/en-us/aspnet/core/mvc/advanced/app-parts
I've tried add Controller like this:
var assembly = typeof(Project.HomeController).GetTypeInfo().Assembly;
services.AddMvc()
.AddApplicationPart(assembly);
This works very well, but I don't know how add the Views.
How can I distribute the Razor Views to another application? Is it way import them like a middleware to the MVC middleware?
You can create a normal netstandard1.6 library-i.e., where your controllers are, and embed the view resources into that dll in your csproj using the following:
<ItemGroup>
<EmbeddedResource Include="Views\**\*.cshtml" />
</ItemGroup>
After that, you can then register these using the RazorViewEngineOptions:
// Add views provided in this assembly.
services.Configure<RazorViewEngineOptions>(options =>
{
options.FileProviders.Add(
new EmbeddedFileProvider(typeof(ClassInLibrary).GetTypeInfo().Assembly));
});
Where "ClassInLibrary" is a class in your library that you can then get the assembly information from.
Comrades, I have had issues implementing yii2 basic but I'm yet to give up. I have successfully installed yii2, activated pretty url and created the .htaccess file in the root folder. The Home, About, Contact and Login urlswork fine.
i. I have created a new model, InstTypes with the CRUD. Why does http://localhost:8081/we#ss/instTypes/create return Not Found (#404)?
ii. I have also created a module instClients. I can access the index action in the DefaultControler. I have a model Insts with its CRUD under this modules. Why does http://localhost:8081/we#ss/instClients/insts/create return Not Found (#404)?
I tend to think that this could be due to the removal of the import and autoload from the config.
Could someone demonstrate how they've created a new model and CRUD and successfully accessed its actions?
Thanks in advance
I have created a new model, InstTypes with the CRUD. Why does
http://localhost:8081/we#ss/instTypes/create return Not Found (#404)?
You cannot access a model directly, the only way to interact with a model is via a controller which will intern interact with the model and the view. By initializing the model $model = new YourModelNmae(); or by rendering a view.
From your URL
http://localhost:8081/we#ss/instTypes/create
InstType should be your controller while create is an action under InstType
Using Yii2 Gii tool to generate a CRUD do the following : -
Generate your model
Generate your CRUD
go to
http://localhost:8081/we#ss/yourController/YourActionOnYourController
Refer to this youtube link for more detail https://www.youtube.com/watch?v=6B52-li6IgU
Happy coding :)
Just to add to the other answers, your url isn't working because it's camelCase. You need to make it hyphenated, so
http://localhost:8081/we#ss/instTypes/create
will become
http://localhost:8081/we#ss/inst-types/create
You're getting the 404 because you're trying to access instTypes, it should be inst-types.
this solved my problem. I needed to add the controllers to the controller map.
I have done a RegisterAppStart<FirstViewModel>() in the Core App.cs, now I navigate to FirstViewModel, then SecondViewModel and finally ThirdViewModel using ShowViewModel(),
Is there a way I want to navigate to the viewmodel which has been registered using RegisterAppStart<>(), I mean is this persisted or saved somewhere during run?
All I want is to get this value at runtime.
If you want to use a singleton instance of a view model then you can do this using a custom view model locator - see the wiki - https://github.com/MvvmCross/MvvmCross/wiki/Customising-using-App-and-Setup - "overriding view model location and construction"
i'd like to know if i can call a controller action inside a template, and inside another controller in fatFree framework (F3).
I'm not sure if i understand you corrently, but calling a Class method in Template would go like this:
{{ MyConroller->doSomething() }}
Of cause you could call one controller within another too... just use raw php
$obj = new MyController();
$obj->foo();
or use the F3 call method $f3->call('MyController->doSomething');
Also check out the new API docs.
http://fatfreeframework.com/base#call
It's still under construction, but hopefully you'll find more information about this or any other framework part very soon.
Many MVC purists would balk at the idea of a View (template) calling methods on the Controller. They would say that the controller needs to provide the data that the view needs, or at least give it the Model, so that it can retrieve data from there.
Furthermore, the View probably shouldn't be doing anything (or asking another component to do anything), other than generating the display. But can query the Model for data. But maybe by doSomething() you do mean getSomeData().
While I'm not an MVC purist I do agree with the idea of keeping logic and functionality out of the view if at all possible.
I have Three projects in one solution (two are asp.net MVC type and last one is class type); call it EmployeeMVC Proj and TimeSheetMVC Proj (To manage the views) and Third one EntityLib proj.
Now from EmployeeMVC Proj; I would like to pup-up a page from TimeSheetMVC Proj and perform some operations. Let's say from EmployeeMVC Proj Post Time-Sheet Data in JSon format to TimeSheetMVC Proj and get back the result.
How can we achieve this?
Many thanks,
Jigar
Presumably the the two MVC projects will be hosted in their own web applications so the EmployeeMVC application can just post a form to an action on a controller in the TimesheetMVC application.