May 3, 2020
Estimated Post Reading Time ~

Using DigitalOlson’s cq-component-plugin and @DialogFieldSet

DigitalOlson (formerly Citytech) has a great plugin that automatically generates AEM dialogs. However, the docs are incomplete. One thing my team discovered was the @DialogFieldSet annotation. This allows you to pull in dialog items from referenced subclasses or composited classes.

In this example, we have a CtaButton class that we want to include in our dialog. Using the dialogfield set, this all is generated and mapped correctly.

@DialogField
@DialogFieldSet(namePrefix = "cta_", title = "CTA Button", collapsible = true)
private CtaButton ctaButton;

/**
* Click to Action Button
*/
public class CtaButton {

/** Defines whether to not CTA button displays */
@DialogField(fieldLabel="CTA Button Visibility", name = "cta_visible")
@CheckBox(title = "Visible", text = "Check make the button visible")
private boolean visible;

/** CTA text for button */
@DialogField(fieldLabel="CTA Button Text", name = "text")
@TextField
private String text;

/** CTA button link */
@DialogField(fieldLabel="CTA Button Link", title = "CTA Button URL", name = "url")
@PathField
private String url;

/** Defines whether CTA will open in current or new window */
@DialogField(fieldLabel="Open in new window", name = "newWindow")
@CheckBox(title = "Open in new window", text = "Check to open link in new window")
private boolean newWindow;
}

Field(fieldName = "included", xtype = "cqinclude", suppressTouchUI = true, additionalProperties = {
@Property(name = "path", value="/apps/blablabla/test.infinity.json")
})
private String included;

<included allowBlank="{Boolean}true" disabled="{Boolean}false" hideLabel="{Boolean}false" jcr:primaryType="cq:Widget" name="./included" path="/apps/blablabla/test.infinity.json" xtype="cqinclude"/>
Written By: Brenn

Source: https://aemmastery.com/using-digitalolsons-cq-component-plugin-and-dialogfieldset-e11141b18e2f


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.