What is the use of Parbase component: - aem

I couldn't understand the need for a parbase component in CQ5. From what I read in CQ5 documentation, parbase is a component that can extend from other components. But all the components can extend other components by specifying sling:resourceSuperType property. So what is the need for a parbase component?

As per the Day documentation, "The parbase allows components to inherit attributes from other components"
If you check under "/libs/foundation/components", most of the authorable and draggable components have 'parbase' set as their 'sling:resourceSuperType' so that they can inherit the image and text rendering properties when added to a Paragraph system (Parsys Component).
This is a standard followed by all the Out-Of-the-Box components in CQ5.
While creating your own components, you don't need to add 'parbase' as a supertype, unless your components need to be enabled with drag-drop in a parsys.
AFAIK, the parbase component is never used explicitly, but only facilitates the rendering of a component when added in the Parsys.

Parbase is just a component from which you extend to get some OOTB functionality.
If I can say in technical language, Parbase is a key component as it allows components to inherit attributes from other components, similar to subclasses in object oriented languages such as Java.
For example, when you open the /libs/foundation/components/text node in the CRX Explorer, you see that it has a property named sling:resourceSuperType, which references the parbase component. The parbase here defines tree scripts to render images, titles, and so on, so that all components subclassed from this parbase can use this script.

Related

Nested lightning components in Salesforce communities

Salesforce communities provide native lightning components with the capability of allowing a user to drag and drop components into them. Not all components are allowed (i.e. A tab component cannot contain another tab component, but can contain a list view component). I have this very simple component:
<aura:component implements="forceCommunity:availableForAllPageTypes,forceCommunity:layout" access="global" >
<aura:attribute name="detail" type="Aura.Component[]">
<p>default paragraph1</p>
</aura:attribute>
<aura:set attribute="detail"></aura:set>
Default value is:
{!v.detail}
</aura:component>
This component implements forceCommunity:layout, so I can create a page using it as a layout. When I do, components can be dragged in to where the '{!v.detail}' is. When I drag the component into an already-existing layout, I lose that functionality. Is there any way to do this?
You need to edit template settings rather than drag it into the community builder.
If you want to add them programmatically, you'll need to do that inside a lightning component.

in aem in touch ui using sightly to a parsys component if i add some image or anything next parsys should be after that one not below it

in aem in touch ui using sightly if I add a parsys component with some width(ex:30%) and after adding some component to it next parsys should come after that one not below of the previous component. How can I do that one?
There is not something like "fixed-fluid layout" in AEM.
You should create a layout before drop the components, you can use column control to achieve this, take a look to the documentation: https://helpx.adobe.com/experience-manager/using/custom_columns.html

Cq Parsys with a Parsys

I would like to create a component which is a parsys and can hold some specific components only. I have copied the parsys component from the foundation, and create a new component drag-drop-parsys, but when I drag it on the page, that on the parsys, I can see the green-surronding bar for "drag-drop-parsys". Can some one please let me know what should I do.
Parsys with in Parsys (drag-drop-parsys) and which can hold specific components.
Thanks for all your help.
-MG
Could you clarify why you are created an entirely new paragraph system? Generally to limit certain components to a certain parsys, you would use the "Design", a configuration that specifies exactly that. You specify in the design that X, Y, and Z components (or component groups) are available in any parsys named "your parsys name" per page component.
Here's the documentation:
http://dev.day.com/docs/en/cq/current/developing/designer.html
One solution would be to create a NEW component "my-parsys" that inherits from the system parsys component. Then the new component could restrict allowedChildren to the desired set of draggable components. Theoretically, this wouldn't require any JSP's - just the settings around your draggable parsys.
NOTE: generally, it doesn't make sense to drag a parsys directly into another parsys - that is just nesting lists of components. However, we have created "wrapper" components that themselves may have their own parsys for components inside themselves.

AEM/CQ5 how to share component values?

I want to have a header component that is shared across multiple page rendering components. The header component has a text label. How do I make the value of this text label available to all page components.
Do I have to make the path in the <cq:include> to a common format?
Design mode, if properly understood, can work quite well. However, it doesn't replicate content in the same manner as page activation, and thus can be confusing for your authors. Also, the sharing model is limited to the exact page type - which may or may not be the granularity you desire.
From CQ5's Best Practices (https://dev.day.com/docs/en/cq/current/developing/developing_guidelines_bestpractices.html), they strongly encourage the paragraph system (iparsys to inherit/share). iparsys named the same can be shared across different page templates (while design mode will only apply to a single template type).
I can archive that by creating a design dialog that is similar to dialog (http://dev.day.com/docs/en/cq/5-6/developing/components.html#Dialogs) under the header component. You add the text label field to design dialog. And to enter value for the field, you switch the page to the design mode and click on Edit button on the top of the component. The entered value will be available to all pages that contain the header component.
Note: design dialog will be named as design_dialog
This functionality is now offered in ACS AEM Commons as Shared Component Properties - http://adobe-consulting-services.github.io/acs-aem-commons/features/shared-component-properties.html
Supports standard content activation and internationalization (values stored below the homepage) and anything else you would expect from content.
If the component is baked in the template(i,e page rendering component), yes you can make the <cq:include> path attribute to point to some common place where the data for this is stored and all the pages irrespective of , type of the template can get the values configured.
You can create header component and then include it using <cq:include> in base template/page. This base template/page will be inherited by all other templates. This way the header once configured in base page is availble through out different templates/page components.
If the goal is to share "across multiple page rendering components" the design dialog will only help if the page share the same rendering component.
If you want to have the header component displayed in a page and all its subpages, then you should use iparsys.
If you just want to reuse the properties of that header component, then it needs to have a fixed path (cq:include in a page component) and then you can reference the properties you need in other page rendering components. I would not suggest that approach since it breaks the idea of having a component. Everything becomes tightly coupled.
What you could also do is save those properties at the page level (some top parent page) and then use InheritanceValueMap in the subpages to read those properties.

Inheriting dialogs in Adobe CQ5

I'm trying to implement a component dialog by inheriting a dialog of a base component. I'm having troubles with dialogs when used twice.
BASE COMPONENT
dialog
text (name: "./text/content")
OTHER COMPONENT
dialog
text (inherited from base)
text (inherited from base)
settings
other
The problem with this is that it inherits the name as well and it doesn't look like you can override it. How can I make my jsp print out the two rich-text if they get inherited with the same name? Does CQ5 provide an index so that they can be referenced in the JSPs?
If your plan is to have two rich text areas in the dialog of components that inherit from the base, then you must include two rich text areas with unique names in the base component dialog.
Each input field of a dialog must have a unique name otherwise they will point to the same property path relative to the jcr:content node of the component when used on a page.
As mentioned above, Each input field of a dialog must have a unique name otherwise they will point to the same property path relative to the jcr:content node of the component when used on a page. Here, this will confuse the CRX while recognizing the textArea to be referred and the second one will not be referred.