Basic question on Portlet url mapping - portlet

Why the url mapping for a portlet is not specified in portlet.xml? Unlike 'servlet-mapping' in web.xml?
What is the necessity of doing it through the portal console?

The principle behind portlets is that they can be dropped onto portal pages according to the wishes of the portal site designer, or sometimes according to the wishes of the portal user themselves. If a portlet was accessed via a mapping in the portlet.xml file, then you would have to redeploy the portlet application each time you wanted a new mapping. Using a portal console allows you to place the portlet on any one of the portal pages that you create.
Using a portlet-mapping and navigating to it would also suggest that you would only be able to see that single portlet. Some portlets cooperate on a page, and so these wouldn't function properly without being deployed together on a portal page.
If a portlet was accessed directly, then what would the look and feel of the response be? Portals are generally used with themes which control the overall look and feel of the site and allow the portlets in a site to look consistent with each other. Themes often provide you with a standard header and footer etc. A combination of the Portal and the theme often provide you with page navigation too, built up from the pages that are stored within the Portal.
Also, if portlets are allowed to be invoked directly, then you could be able to bypass the Portal Container's security mechanism.
As an 'and finally', some Portlet Containers actually do let you address a portlet directly for certain specific use cases. And some Portlet Containers internally convert the deployed portlets into servlets - and these do have a servlet-mapping that can be accessed directly (although they might break as they may have expectations that the portlet container has put certain attributes in the servlet request).
So it's not a black-and-white answer. Generally speaking, if you're developing a portlet then you're doing so because you do want your portlet to be invoked from a Portal page and you do want all of the value-added stuff that comes from running within a Portal.
If you don't want these things, then maybe the question is should my application be built using portlets?

Related

Share session variables in websphere portal

does anyone know how to share session variables and recover from any portlet in websphere portal, for example I set a session variable (Object) in one portlet and i want to get the value of that variable. How can i do this?.
I'm using Websphere portal 8, and my IDE is RAD 8.5
Regards
If your portlets are deployed in the same webapp, you can use the PortletSession with the scope APPLICATION : portletRequest.getSession().setAttribute("name", "value", PortletSession.APPLICATION_SCOPE).
Otherwise, you need to create your own sharing service that will store variables. It seems that this article could help you : http://www.ibm.com/developerworks/websphere/library/techarticles/0602_hepper/0602_hepper.html
If you want to share objects / state across portlets that are not in the same web module (war file) and you are in WebSphere Portal, you can use a WebSphere Application Server proprietary service called DynaCache. It is mature and commonly used. You can set up a Map object that is shared not only across portlets (really any application code in the same JVM), but can also be set up to share objects across JVMs (like in a cluster). Key programming interface: DistributedMap. Here's a pretty good blog post on setting up a cache instance so your portlets can each look the map up via JNDI and either get or put to it just like any other Map<K,V>.

Is CQ5 used as a backend service?

I have experience with other enterprise CMS's like Teamsite & Tridion, but no hands on experience with CQ5. I'm wondering, how is CQ5 usually integrated with a large site that has content & functionality? Functionality defined as pages are generated with data from a non-CMS repository or webservice.
My question is, is CQ5 content read in as a back-end service? I know the API is http based. But is that API typically called from server or client? For my example, lets say I have a page that is from mostly driven from a web service that is linked to some non-CMS enterprise system, but I want the footer & right rail to be "content" so that the users can change it easily. At what point would the the different page sources typically be combined?
I'm wondering because I work with asp.net. I know the CQ5 is Java, so I would expect that most cusomters are java shops, but I would think that the HTTP would be easy to consume for an ASP.net site, if it is really just another backend webservice.
Your question is really not all that clear to me to be honest. So I'm going to answer this rather broad.
To answer your question about the different page sources:
The client usually initiates a http or json request to the server (although server to server calls are not uncommon in case of extended infrastructure) and the server simply executes the necessary calls (using the apis) and delivers the answer to the request. But at the point of request return, all calls to the api have been made by the server, and the server is just returning rendered html or json, or whatever structured form you want to have your data and/or content in.
A page consists of various components. Some components are fairly static. Others are very dynamic and pull their data for example from a webservice, or external database or even another cms. The combining of these resources happens upon the rendering of the page which in its turn was triggered by a request for that page. The obvious exception is ofcourse the dispatcher caching system which will return a cached version of the page if possible. But in short, all the rendering and api calls are made server side.
CQ5 is fairly flexible since it's split up into 2 instances. The backend (author) which is where the actual authoring of pages happens. And the frontend (publish) which is basically the frontend, and does the actual rendering for a client (usually).
Wether you choose to use the publish instance a backend service is just up to you to be honest. I've seen cq5 used as what it was ment for (cq5 being the frontend), and I've seen cq5 used as a backend service (for example: as a backend service provider for hybris). And I've seen the combination, where one part was used as backend service for another system, and the other part was used for a public website frontend.
CQ's rich HTTP API (based on Apache Sling) gives full access to the CQ content in various formats including JSON and XML, so integrating CQ content in other systems is easy.
In the other direction, you can use Sling's ResourceProvider mechanism to access external content and make it part of the CQ content tree. See "custom resource providers" in the Sling Resources docs at http://sling.apache.org/documentation/the-sling-engine/resources.html .

Is eventing the only way of inter portlet communication

I got the impression from reading articles on jsr286 eventing that the eventing feature enables portlets to communicate with one another if they belong to different .war files.
I just want to confirm that even if 2 portlets belong to same war file, the only way they can communicate is through eventing.
Since the whole request forwarding feature of servlets do not apply to portlets. Is this correct?
Portlets events can be used between portlets in the same wars or in different wars. However, one of the limitations of the portlets events is that the 2 portlets must be on the same page.
There are others ways to communicate between 2 portlets. You can use Public Render Parameters. The idea is that the first portlet sets a parameter, and the second portlet can read it in order to retrieve the value.
You can also use the Application scope of the PortletSession to communicate and share data. The application scope (APPLICATION_SCOPE) of a PortletSession is shared between all the portlets of the same war.

Adding custom metadata in alfresco

I added custom metadata through xml configuration specified in their wiki ... I could see the aspect I added in the /share application in manage aspects but it is not listed in /alfresco app and when i am uploading the document using the rest api it says unable to find the field i added ..
Share and old Alfresco Web Client have different configurations.
Check these resources out for more information:
http://wiki.alfresco.com/wiki/Web_Client_Customisation_Guide
http://wiki.alfresco.com/wiki/Displaying_Custom_Metadata
Please read this tutorial which covers creating custom content types and aspects and exposing those to both the Share (/share) and Explorer (/alfresco) web clients.
It sounds like you may have multiple problems, though, beyond configuration, because the REST API should be able to see your custom model, if it is defined correctly, regardless of whether or not it is configured in either of the two web clients.

General question, what do you want from a web framework?

In a MVC application, what are some of the components that make up the application. What tools and functionality is missing that you would like to have. Regardless of the server-side language, what would you want?
I see a lot in my code where I code some much functionality that it seems should already be there. I looked at Google web toolkit and they seem to get it right. Widgets are widgets and you simply add them to your application.
For example. I work with J2EE apps but in other languages, the components are the same.
Controller Objects
Controller handlers, defined by methods in the controller objects.
Configuration files defining the URL mapping and settings.
Template server page files (e.g. JSP/ASP files).
Configuration files defining O/RM mapping between application objects and the database.
Configuration files defining the database connection properties.
JavaScript libraries (e.g. jQuery)
Logging configuration files
Resource message bundle files
Validation configuration files or code
Middleware components and objects (EJB configurations, JMS/Messaging configurations, etc).
Credit Card or other middleware connectivity APIs and libraries.
Anything else you can think of?
Built-in Unit Testing Component
I think one thing you're missing from that very exhaustive list is the automatic binding of request properties to form objects, and the saving of these objects to the session where appropriate. Form objects here being the object on the server that represents the current state of the HTML-based for displayed to the user.
I think scaffolding and automatic admin interfaces are very nice features too, that I dont want to miss ;)
You've made the assumption that all MVC applications are websites. MVC is widely used for more than just web apps so things like URL mappers, template server pages and "Server side" languages are not associated with the MVC pattern, so much as a particular implementation and adaptation of the MVC for use in web apps.