What is the difference between ContentPartRecord and regular MVC model object? - orchardcms

I was fairly confused on the difference between ContentPart and regular MVC model object.
I was going through PluralSight Advanced Orchard course.
It went through how to create MovieContentPart and Actor object.
I understood that MoviceContentPart has a movie part record that associates the records in the database table.
However, Actor object can also do the same thing outside of Orchard approach.
So what is the benefit of using Orchard approach?

A ContentPart and a regular MVC model are very similar concepts. One way to see Orchard is as a composition engine over MVC. Let me explain...
In a traditional MVC application, you have a very simple pipeline: request comes in, is routed to a controller action, which uses the request to build a model and return a result, that is then typically used to hand a view model over to a view. The HTML rendered by the view is then sent to the browser. This is a simplification but it's the general idea.
In the case of Orchard, many different modules will contribute to any single page. There is a controller, but it's deep in Orchard and you should pay no attention to it (in typical cases). The model is actually composed dynamically by all those modules, in a collaborative and decoupled process.
The reason why Orchard needs to do things this way comes from the realization that most content is made of small composable parts. For example, a blog post is made of a title, a body, a slug, an author, a list of tags, and comments (which are themselves content items made of parts: title, author, text, etc.).
Each of those parts comes from some module, and is managed by a "part driver" which is what really is the closest thing you have to a controller, but that acts at the level of the part, which is the one that makes sense for Orchard, much more so than the request. The driver is responsible for creating a "shape" from the part, which is similar to creating a fraction of a view model. The shape will later get rendered by a template (which is a fraction of a view), and the resulting HTML will get composed into the larger page to be sent to the browser.
So to summarize, the advantage of the Orchard model over a plain MVC app is that instead of a simple request -> controller-action -> view pipeline, you get a richer, composable, parallel and very decoupled pipeline to render a page from reusable parts. This is not always appropriate, which is why Orchard still allows for simple controllers to be implemented by modules, but for content-based web sites or sections of web sites, it's extremely powerful and allows for advanced scenarios that would be much more difficult to implement from scratch in a traditional MVC app.

Related

Composition relations with jHipster

I am learning jHipster. My entity relationship model has projects and files. A project can have zero to many files, and a file always belongs to exactly one project.
project <(1:1)-----(0:*)> file
Users interact with the application similar to using an IDE. First, after opening the initial website they always have to select which project they want to work in. (Of course they can also create new projects, or perhaps delete an old one.) Only then they get access to all resources added to a particular project such as files.
As a consequence, my REST API should logically look like this (to get a single file):
GET /projects/{:projectId}/files/{:fileId}
In the backend, depending on whether fileId is a UUID or not, I might even have a method:
findFileByIdAndProjectId(String fileId, String projectId)
The problem is that jHipster creates all entities in a "flat way". Each entity seems to have its own REST API without nesting, and there is simply a reference to an other entity rather than proper composition. Adapting the generated code is quite a bit of work as it requires lots of changes both on the frontend and the backend, but more importantly, it probably breaks the ability to re-create my code when an entity has changed.
I am curious: What different options do I have, and which one would you guys recommend?
Custom code is the way to go though there are few tricks that can help you:
Using DTOs so you can aggregate entities in service layer
Extending generated classes both in backend and frontend so that you don't change generated code, see excellent talk, slides and code samples from Antonio Goncalves

Lotus Notes XPage to display within Frameset

[Disclaimer: I am new to Notes, and am picking up a project that was started by someone else, so I'm not sure if this is the best approach, and with that out of the way ....]
We have a Notes 9.0 frameset, which is being driven by a couple of databases. There are 4 parts to the frame set, with the primary one being the selection of a client. This populates the second frame with their information, and the third frame with any related clients - such as business partners, associates, etc. The fourth frame would be any and all correspondence listed with the related clients (either one or many) which has been placed into an XPage. We cannot, though, load the XPage inside the frame, having tried multiple instances of .urlopen(XPage location) and trying to open the notes:// source, http:// source, and setting the target frame in both the inline URL and as a .SetTargetFrame("frame") fashion.
Is it possible to open an XPage from with a Frameset, or is there a better approach to this?
Thanks
Integrating or embedding XPages into a traditional Domino web application is a common approach and straightforward because it's the same protocol with the same authentication. Integrating XPages into a standard Notes Client design element is challenging for a variety of reasons, not just the URL required but also because authentication to the client is via Notes ID stored on the PC, authentication to the XPage is via HTTP protocol.
If you're wishing to display a list of the correspondence in a standard Notes frameset in the Notes Client, the approach I'd take is just to point to a View or embedded view set to a single category based on the client selected. If it's a server within a decent connectivity range, view performance will be better. If it's just a list, the data should be available for a view. If it's to navigate into the documents and you want to open the correspondence in an XPage, that's achievable from a view by setting the property on the Form to open in a specific XPage.
I'm not certain, but it sounds like your choice to use the XPage was because someone had already developed an XPage of that information for web access, possibly for the external clients themselves. While re-using the previous code may seem a good approach, the challenges of integrating one technology into another (as you see) counter the benefits.
This isn't about XPages itself, it's about embedding technologies that are not really designed for that level of integration. Similarly if the correspondence was an Angular front end using REST services to pull the information from Domino, you would have similar issues integrating it into the Notes Client application (authentication, running code on the client to run code on the server to get data for the client to process - when Notes is already designed for good nrpc communication).
There may be benefits in time of migrating all of the frameset to an XPages application or a specific set of use cases that won't require users switching between browser client and Notes Client. But if that's not the approach for now, integrating the XPage into the frameset is likely to be a challenge, no least in terms of look and feel, that may not result in a good user experience.
You can integrate an XPage into a Notes client, but it will require to learn about a number of moving parts. Instead of a Frameset you would use a composite application (same idea, more possibilities) and show various composites: Views, Forms, Pages, XPages, Navigators etc.
However you might consider reversing the process. When the XPages application in the browser works well, you could use the XPiNC feature (XPages in Notes Client) to show the same UI in the Notes client (presuming you have a current Notes version).
You will find some articles here: https://www-10.lotus.com/ldd/ddwiki.nsf/xpSearch.xsp?searchValue=%20XPages%20in%20the%20Notes%20client
My thought: what possibly makes you problems opening XPage in frameset (either with http:// or notes:// protocols) is incompatible browser (that one in client).
You can workaround this problem if you do not need all the bells & whistles of standard XPage - Dojo, events, themes...
So, what about making that XPage as simple as possible: make it stateless, disable Dojo, do not use any events (buttons, actions), in other words just plain HTML/CSS with no JS. That should work inside frameset. All the backend stuff - SSJS, datasources and so on is OK, of course.
Edit: another hint to make it work inside frame/internal browser. Sometimes XPage fails in XPiNC mode because of wrong datasource definition. When viewed from http of Domino server, all local databases are the server ones. But in XPiNC all local databases are treated as local replicas (usually nonexistent) and therefore fail to open. Possible solution:
run XPages from server (https://superuser.com/a/586602/17277)
redefine datasource: include server name in database property (hint: remember server!!database.nsf convention)
That's just a hint, I am not sure it will work for you.

How do I create transferable dll's for a specific website functionality?

VS2013 update 5, MVC5 using Areas
I have a stand-alone function programmed for a website. The functionality is a specific user interface to collect survey responses in a particular way. It has several controllers, a model and a group of views. The functionality is completely contained in an Area of the project, except for the Shared _Layout file that provides the main menu for consistency.
'Is it possible for me to' / 'how do I' compile this Area into a single or set of .dll file(s) that I could then add conveniently to other websites? I'm assuming creating something for transfer/download is very standard functionality. For example, I used Elmah.MVC for this site. What I want to do is pretty much create a package that can be downloaded in a similar way to how we integrate Elmah.MVC into a site. (Be certain I'm not talking about creating error logging software, I'm only using Elmah.MVC as an example of software that is easily integrated into other website applications.)
I've never compiled any website functionality into a .dll(s) for use elsewhere and would appreciate either some specific guidance, or perhaps what would be easier is to provide a link with a good step by step tutorial or explanation for how to do this. Most of what I've found on the web describes bits and pieces of doing this, but it's not enough for me to feel confident with it.
It seems to me there are a lot of 'moving parts' to taking a particular piece of an MVC application and turning it into something that is easily added to other projects.
A particular issue I don't quite grasp is the difference in downloaded packages between getting code and getting just the .dll(s). For instance, when I download an MVC5 site, I get controllers, models and views, but when I download Elmah I get a .dll and no code files. Also, I do understand the concept of transforms, but I'm just struggling right now with even getting from my programmed application into a 'package' regardless of the transforms that make it easy to integrate into another website.
These are just some of my questions I have about how to perform this particular process in developing deliverable and/or shareable software.
What you are looking to do is create a portable MVC Area project. A Portable Area is a set of reusable multi page functionality can be dropped into an application to provide rich functionality without having to custom build functionality that is literally the same in every application. An MVC Portable Area is really just a dll that contains the views, controllers, scripts, etc… needed to use in a website that is either a Web Forms website or an MVC website. A developer can use them for a reusable widget or a complete engine. I have actually used them for both. Here is a link with some basic info to get started. http://elegantcode.com/2012/04/06/mvc-portable-areas/

Customizing the front end of maximo anywhere apps

I have been working on maximo anywhere apps recently and have a requirement to completely change the look and feel of the work execution app, the oslc layer which talks to maximo in the backend remains the same and all the functionalities are the same but there are some new buttons, notification messages and all sorts of UX aspects to be added to the app, I have just started looking at the architecture and code of the app but does anyone know how can I make changes to the front-end or is it even possible? I could find very few documents available online and all of them spoke of customizing features and functionalities but I coudlnot find any document for adding UX aspects.
It would be great someone could point out any documents or kick-off points which I can start looking into.
Thanks.
Thanks for asking, if you're just talking about adding new fields, layouts, screens to the UI, you can do that all through the app.xml, and there are lots of examples on our knowledge center, for example this one:
http://www-01.ibm.com/support/knowledgecenter/SSPJLC_7.5.2/com.ibm.si.mpl.doc_7.5.2/config_apps/t_add_rw_fields.html?lang=en
If you're talking about changing the "look" of the existing widgets, this can all be done through css, by overriding our out of the box css classes. Use Chrome inspector to figure out which css class is being used for each element type, and just override it through standard css approaches.
If you're talking about more advanced customization, for example adding your own new widget types to our screens, it is possible to programmatically instantiate/destroy your own widgets through javascript and add them to our standard application views. This code is usually hooked on the initialize and back event of our views. But you'll be responsible for writing the code to synchronize the data layer with your custom widget. We unfortunately don't have a published example of this customization usecase yet.
We always adding new widget capabilities to our Anywhere UI framework, so I'd love to hear feedback on the new widget types you're interested in.

Using Orchard CMS is it possible to build an interface for fast list entry?

I'm digging into orchard CMS, but I'm a little bit skeptical that I might not have the ability to do something like create new content items quickly without posting back to the server.
For example. Let's say I define a content type for a product. One property a product might have is a collection of variations or similar products that can maybe be sorted by relevance. (Think a comic book with variant covers)
Could you build an interface for this where you enter a new product, and search for and include multiple variant products all from the same client interface without ever having to post back or do a hard page refresh?
I guess maybe, what I'm really asking is if it would be easy to expose the content through Web API or something like that, and from there you can really just build anything.
I'm a little worried about starting down the road of using a nice framework like this, only to find half-way through that I'm limited by the framework itself.
Think about OrchardCMS as a super set of ASP.NET MVC. You can build a custom controller to handle your own types or even content types (see OrchardServices)
In your case, just make a custom controller which will handle via actions the ajaxs requests to create, update, get related items and so on.
You should read the Sipke post series, in particularly this one: (http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-6) Another useful resource is the course of pluralsight.

Resources