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.
Related
Instead of reading data out of 2sxc, I want to pump a list of data into a 2sxc stream. As all should run on the server-side within a razor script, I don't want to use WebApi and post every single entity.
It is possible to do CRUD operations within a razor script? Any example/demo available?
I found the page, which might interest you (official GitHub of 2sxc):
https://github.com/2sic/2sxc/wiki/razor-dnn
Finally I found it in the documentation:
App.Data.Create(contentTypeName, values, userName)
App.Data.Update(entityId, values, userName)
App.Data.Delete(entityId, userName)
https://2sxc.org/en/docs/Feature/feature/3360
https://github.com/2sic/2sxc/wiki/razor-app
Our project in WebSphere Portal 8.5 have a few portlets (JSR 286).
Portlet A for example contains pages with description of some goods, and tools for the editing this description.
And Portlet B contains tools for create orders for these goods (this is a very simplified, but it should be enough to understand the problem).
We need to create link from one portlet to another with the passing some parameters both in one direction and vice versa. How we can do this?
It would be very useful to see simple code examples for a better understanding
Thank you
Well your most basic approach is to use public render parameters
https://www.ibm.com/support/knowledgecenter/en/SSYJ99_8.5.0/dev-portlet/pltcom_pubrndrprm.html
Set it up in the portlet.xml
<portlet>
...
<supported-public-render-parameter>custID</supported-public-render-parameter>
</portlet>
<public-render-parameter>
<identifier>custID</identifier>
<qname>x:customerID</qname>
</public-render-parameter>
and then you can get it liket his
String customerID = renderRequest.getParameter("custID");
If you need something more complex, you could put items into application scope in the session and share them that way and when the page renders again both have access to it
or you could use the url generation apis but that would be the last thing I would recommend
I build a web app using sails.js and I have few questions about the design of the app:
Should I create controllers for each page, component, or model? I saw in the documentation and at some tutorials that they create controllers for each model. That looks nice but if I have a complex page/component and I want to create view with multi models (and data) it doesn't help me.
Where should I put the business logic part of a component or feature? I read about Serivce but I'm not sure that this is the right place.
To sum up, I saw that in sails the code is arranged like the models (you have model, controller and view for each model) but what if I want to arrange it by features or components or pages?
Thanks!
Basically you should have Controller for each Model (but if you don't need specific controller and it would be empty you don't need to create it). It's just a good practice to have a Controller for each Model.
If you use some part of code in many places and it is not connected with one specified Model it should be Service (like sending emails, notifications, logging, images processing). Read about DRY
Controller should be as simple as possible. It should contain call of Model and Service and callback with rendering output. All business logic should be in Models.
I created some additional 'helper' Models for more complex Models like Users or so to make Classes bit shorter.
To sum up. Core of your application is Model. It's not only responsible for database layer, bur also business layer of your app. Later there is Controller. It gets data from Model and it passes it to Views which is responsible for presentation of data taken from Model.
Answer to First
Sails is for REST API it has nothing to do with view.
you just need to know what MVC is and what REST is....
In one Controller you can invoke multiple models or one model can be invoked in multiple controllers.
In one page you can fetch data from two different API's which may be from different controller or Even they can be of different server.
for Example:
In the page you are getting data directly from ellasticsearchAPI(say esAPI1)
You are getting data from sails API(sAPI1).
You are getting data from other sails API(sAPI2).
Answer to Second
For neatness you should try to keep controller as clean as possible. So for the same sailsJS provide you services. Where you can write Common functionalities which are to be used in multiple controllers.
See the codes for example
Codes
here is the controller:
//TestController
module.exports = {
action1:function(req,res){
Model1.find().exec(function(err,data1){
if(err)
return res.negotiate(err);
res.ok(data1);
});
},
action2:function(req,res){
Model2.find().exec(function(err,data1){
if(err)
return res.negotiate(err);
res.ok(data2);
});
},
action3:function(req,res){
var hash=SomeService.getMeHashCode(req.query.text)
res.ok({hashedData:hash});
}
};
And this is service.
//SomeService.js
module.exports = {
getMeHashCode:function(strinToBeHashed){
var hash=doSomeThingToHash(strinToBeHashed);
return hash;
}
};
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
I have run some mvc 3 applications with custom memberships but for ASP.NET MVC 4 i can not find any example how i do a custom membership provider with MySQL.
Not any example for custom membership i can find, do anyone has any idea?
You do it exactly the same way as MVC 3, however you have to disable the use of SimpleMembership by removing the [InitializeSimpleMembership] attribute on the RegisterModel class.
You also have to remove all the boiler plate that uses SimpleMembership from the AccountController if you generated a sample applciation.