CQ5: Inheriting/Extended Dialogs - aem

For reference, I'm on CQ5.5
I am curious if there is any way to extend upon an inherited dialog, without overwriting it's parent dialog.
For example, have a structure as follows:
base-page-template
- dialog
- title
- description
inerited-from-base-page
- dialog
- custom field
--------------- [inherited from parent]
- title
- description
What I'm trying to avoid is for example: I need to add a new property to base-page that should show up on all page templates that extend from base-page. My current solution is to add that property to all dialogs separately. So for example, in the above structure I would have to add the new "default property" to both the base-page and the inherited-from-base-page dialogs.
The only other option I could think of was creating a panel node that represents "base page" and then including that panel w/ an xtype:cqinclude node.
Before going with the latter route I'm curious if anyone has extended their dialogs in the fashion I'm describing above.
Any help is greatly appreciated, Thank you,
Brodie

No, there is no way to directly inherit dialogs. The best you can do is to include the dialog tabs using path property.
You should create your tab your tabs in a different location and you can include it in your dialog using path property like shown below:
<items jcr:primaryType="cq:WidgetCollection">
<tabs jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Widget"
path="/apps/myproject/tab1.infinity.json"
xtype="cqinclude"/>
<tab2
jcr:primaryType="cq:Widget"
path="/apps/myproject/tab2.infinity.json"
xtype="cqinclude"/>
</items>
</tabs>
</items>
Where tab1 and tab2 are tab panels.
So, in your case it will be something like this :
base_page_dialog_tab
- dialog
- title
- description
inherited page-dialog-tab
- custom field
base-page-template
- include base page dialog tab here.
inerited-from-base-page
- include Tab 1 - inherited page-dialog tab using path property
- include Tab 2 - base page dialog tab using path property.

The above answer provided by Rajesh is correct w.r.t to dialog.xml written for classic UI interface in AEM.
The touch UI equivalent of cqinclude is sling:resourceType="granite/ui/components/foundation/include".
Example:
<basic
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/include"
path="foundation/components/page/cq:dialog/content/items/tabs/items/basic"/>
With touch UI in AEM, A different kind of dialog inheritance is possible using the sling:resourceSuperType property, however please note that this does not inherit dialog properties from its live copy parent. The dialog is inherited from its sling resource super-type.
I understand that this feature is not a solution to the problem described above, Just wanted to point out that dialog inheritance is possible with the new TOUCH-UI authoring.
Following is an example.
base_page_dialog_tab (sling:resourceType='A')
- dialog
- title
- description
page-dialog-tab (sling:resourceSuperType=sling:resourceSuperType='A')
- custom field
In the above example, the page-dialog-tab would have the following four properties in its dialog.
- dialog
- title
- description
- custom field
A few useful config options available like sling:hideProperties, sling:hideResource, sling:hideChildren and sling:orderBefore to hide and order properties in the dialog.

Related

AEM: Responsive Grid does not show layout mode

I posted AEM related question in Adobe forums but I have still not able to resolve the configuration problems.
One is that I would like to show ruler and responsive emulator menu at the top of editor.html
Second is that I would like to components to have customizable with. For example, if you drop text component on a page at editor.html, you can adjust the width of the component with drugging blue dot on the side.
The original question in Adobe forum has my current configuration which is not quite working with screenshot and details.
Original question: https://forums.adobe.com/thread/2376694
Would anybody help me resolving the issue that I have?
There's several things you need to do to enable the ruler and layouting mode in AEM.
Ruler (Emulator)
make sure /libs/wcm/mobile/components/simulator/simulator.jsp is in the head of your page
register the page component with a MobileEmulatorProvider. For example:
com.day.cq.wcm.mobile.core.impl.MobileEmulatorProvider-alias.xml:
mobile.resourceTypes=[geometrixx-media/components/page]
add the cq:deviceGroup property to the root content node (i.e. /etc/mobile/groups/responsive)
Note: the ruler will not show up unless the page is treated as “responsive”. The “emulators” property must not be blank at http://localhost:4502/libs/wcm/core/content/pageinfo.json?path=<path to page>
Layouting Mode
add the cq:responsive node to the root content node (just grab it from geometrixx-media). For example:
<cq:responsive jcr:primaryType="nt:unstructured">
<breakpoints jcr:primaryType="nt:unstructured">
<phone jcr:primaryType="nt:unstructured" title="{String}Phone" width="{Decimal}768"/>
<tablet jcr:primaryType="nt:unstructured" title="{String}Tablet" width="{Decimal}1200"/>
</breakpoints>
</cq:responsive>
if not inheriting from the foundation page component, add /libs/foundation/components/page/cq:infoProviders/responsive node to page component
change the "par" parsys to be of type wcm/foundation/components/responsivegrid
include the responsive css client lib in the project (see below)
More info: https://docs.adobe.com/docs/en/aem/6-2/author/page-authoring/responsive-layout.html

why do we need to inherit parbase component for all image components

According to Adobe's documentation for AEM development, we should inherit parbase component for all image rendering components.
Could anyone please share a rationale behind this necessity? and also Could anyone please point to other alternatives to this (if any)
Please have a loo at the Adobe AEM Forum Post:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__3vh2-why_do_we_needtoin.html
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.
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.
"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).
Documentation link:- https://docs.adobe.com/docs/en/cq/5-6-1/wcm/default_components/designmode.html#parbase
I hope this helps.
Thanks and Regards
Kautuk Sahni
parbase has a img.GET.java file which will handle all requests that have the 'img' selector. If you call 'component.img.png' the image will be handled. If you don't inherit from parbase you'd have two options: implement the img.GET.java for your component or save in the component the resource type for the image. I usually do the later when I have a component which store the image data in sub-nodes.
If I want to save the image in a sub-node called image, this is what I add in dialog.xml:
<image
jcr:primaryType="cq:Widget"
cropParameter="./image/imageCrop"
ddGroups="[media]"
fileNameParameter="./image/fileName"
fileReferenceParameter="./image/fileReference"
mapParameter="./image/imageMap"
name="./image/file"
requestSuffix="/image.img.png"
rotateParameter="./image/imageRotate"
title="Image"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<restype
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./image/sling:resourceType"
value="/libs/foundation/components/image"
xtype="hidden"/>
</items>
</image>
this approach is discussed, for example, here: AEM Page Image in Page Properties Doesn't Apply a sling:resourceType

How to edit querybuilder to include a cq:page

I created a form and added it in geometrixx-gov folder under the dam (/content/dam/formsanddocuments/geometrixx-gov) as shown in the image below
However, this form isn't showing up when I go to http://localhost:4502/editor.html/content/geometrixx-gov/en/allforms.html
The allforms.html page is using a querybuilder to fetch all the forms in /content/dam/formsanddocuments/geometrixx-gov. Below is that query from the page
<querybuilder
jcr:created="{Date}2014-02-17T22:47:37.361+05:30"
jcr:createdBy="admin"
jcr:lastModified="{Date}2014-03-28T17:52:05.245+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="fd/fp/components/querybuilder"
customStylePath="/etc/designs/geometrixx-gov/form_portal_default.css"
customTemplate="/etc/designs/geometrixx-gov/fp/card/template.html/jcr:content"
disableSearch="true"
folderPaths="/content/dam/formsanddocuments/geometrixx-gov"
portalTitle="All Forms"
renderType="[PDF,HTML,GUIDE]"
singleView="Card"
style="Custom Style"
viewSwitch="true">
<view
jcr:primaryType="nt:unstructured"
sling:resourceType="fd/fp/components/lenses/view"/>
<textbar
jcr:primaryType="nt:unstructured"
sling:resourceType="fd/fp/components/predicates/textbar"/>
<left
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys">
<propertiespredicate
jcr:created="{Date}2014-03-28T17:45:35.478+05:30"
jcr:createdBy="admin"
jcr:lastModified="{Date}2014-03-28T17:50:01.642+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="fd/fp/components/predicates/propertiespredicate"
searchOptionsPredicates="\{"preducateType":"title","statusFilter":"active","captionText":"Title","defaultFilter":"","enabled":true}"
title="Properties"/>
</left>
<searchAssets
jcr:primaryType="nt:unstructured"
sling:resourceType="fd/fp/search"/>
</querybuilder>
Question
What can I do so that the form I added (DORUsingSchema) also shows up in the All Forms page?
How did you create DORUsingSchema Form?
If the form is being created using Forms Manager - http://localhost:4502/aem/forms.html/content/dam/formsanddocuments there are nodes created at two places.
/content/dam/formsanddocuments// - This node contains metadata of the form.
/content/forms/af// - This is actual form having the same relative hierarchy.
You have copied the node from /content/forms/af/[project-folder]/[formName] to /content/dam/formsanddocuments/[project-folder] which is incorrect, Form Manager take care of creating these nodes.
To show the form in your portal, you need to modify properties predicate applied on the form portal component in allforms.html page. This properties predicate shows all appliations starting with title "Application For", Either you can update your application title or update properties predicate to list down your form in the form portal.
To open properties dialog in authoring mode, click on Search icon located at the leftmost position of search box.

AEM Page Image in Page Properties Doesn't Apply a sling:resourceType

Using Adobe Experience Manager 5.6.1 (AEM) (Formerly CQ5) I am trying to create a new tab similar to the Image tab in Page Properties. It would be titled "Logo".
I basically just copied the Image tab to create a logo tab and renamed the paths to reflect the logo purpose. For instance, I set the fileReferenceParamater to ./logo/fileReference and requestSuffix to /logo.img.png.
When I edit the properties, I can drag an image into the tab just as I can with the "Image" tab, however, the image never appears there. I am guessing this is because the default image handler is not picking up the request. The error is:
Cannot serve request to
/content/my-site/home-page/en_us/jcr:content/logo.img.png in
org.apache.sling.servlets.get.DefaultGetServlet
When I looked at the content node there was no sling:resourceType. When I added a resource type of foundation/components/adaptiveimage then it worked. However, I noticed that the "Image" node didn't have a sling:resourceType. I guess the img.png.java servlet in the foundation page is handling that request.
I tried creating a logo.img.png.jsp file in my page component to handle the request, but that didn't seem to work.
How can I get AEM to either add the sling:resourceType or to handle the request?
I was facing the similar problem and I found a simpler way to resolve. All you need to do is to add a hidden xtype under the your logo image as below:
<yourlogo
jcr:primaryType="cq:Widget"
<-- other properties -->
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./logo/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</yourlogo>
Well, after some time experimenting, this is what I ended up doing to get this to work. If there is an easier way, I would be happy to know it.
First, I copied the /libs/foundation/components/page/img.png.java file and added it to my compiled package with some modifications.
#SlingServlet(
resourceTypes = "sling/servlet/default",
selectors = "imgnode",
extensions = {"png","jpg","jpeg","gif"},
methods = "GET"
)
public class SimpleImageServlet extends AbstractImageServlet {
Where img.png.java had the following line:
Image image = new Image(c.resource, "image");
I changed it to:
Image image = new Image(c.resource);
This relies on SCR annotations to generate the OSGi configuration so that this servlet will handle image requests having the imgnode selector. Instead of looking for a child image node it just expects the current resource to be an image.
Second, I added a component to the body.jsp overlay of the page component, like so.
<cq:include path="logo" resourceType="/apps/my-site/components/logo" />
This maps the logo path to a component for rendering.
Third, within the logo.jsp on the component I set the selector to imgnode rather than img.
Image img = new Image(resourcePage, "logo");
img.setSelector("imgnode");
I believe this step would be similar if the adaptiveimage were overlayed. You just need to render out URLs that include the imgnode selector.
Fourth, I setup the logo image dialog tab in page properties to use the expected requestSuffix and set the other properties to point to the logo sub-node.
Examples:
requestSuffix = "/logo.imgnode.png"
fileReferenceParameter = "./logo/fileReference"
Fifth, I made sure that the image dialog tab for the /apps/my-site/components/logo component pointed to itself.
Examples:
requestSuffix = ".imgnode.png"
fileReferenceParameter = "./fileReference"
Now whether it is in page properties, component editing, or final rendering, the image is handled appropriately.
this is a bit of a nuisance with using the image widget controls--only the image component nicely handles the data, and the servlet that handles ".img" is tied to the image component resourceType.
the easiest thing is to just use the value of the fileReference property instead of referencing the image as part of the page. since you're using assets from DAM, this is a reasonable approach.
this doesn't address the issue with a user uploading an image directly. i wanted to suggest having a hidden field like "./logo/sling:resourceType", but testing that locally resulted in an error when trying to save the dialog.
another approach is the following:
<sling:include resourceType="foundation/components/adaptiveimage" resource="${resource.path}/logo" />
(assuming resource is jcr:content). this is effectively the same as adding a sling:resourceType, but there are at least 2 downsides:
the image becomes authorable at that point as opposed to in the dialog
this method only works for rendering a normal tag. it won't work for any sort of background image

How to display different labels for the same action in the a Project Explorer context menu item depending on the nature of the project selected?

I want to add an action on the Project Explorer context menu. Is is possible to display different labels according to the nature of the project selected if the action is defined via org.eclipse.ui.popupMenus?
I tryied defining 2 contributions and try to hide one according to the nature, but I did'n find a way to test the project nature.
You can try the method outlined in http://timezra.blogspot.com/2007/12/dynamic-labels-for-eclipse-context.html
Which is simply to create a dynamic contribution where you will get a method to return the IMenuContribution[] list, and in the code you can check on whatever condition you want and return the appropriate contribution.
Another approach is outlined in http://wiki.eclipse.org/Menu_Contributions#State_associated_with_the_command_is_propogated_to_UI_visible_elements
to have a NAME state associated with the command and update it as needed, I haven't tried it, but it seems more inline with what you ask.
<state id="NAME" class="org.eclipse.jface.menus.TextState" />