I need an identifier in tabs such that author can specify which tab will open at page load Below is my dialog.xml.
<items jcr:primaryType="cq:WidgetCollection">
<typeconfigs
jcr:primaryType="cq:Widget"
fieldLabel="Accordion"
name="./options"
xtype="customconfigmultifield">
<fieldConfigs jcr:primaryType="cq:WidgetCollection">
<option
jcr:primaryType="cq:Widget"
hidden="{Boolean}true"
name="option_name"
xtype="textfield"/>
<optionval
jcr:primaryType="cq:Widget"
allowBlank="{Boolean}false"
fieldLabel="Title"
maxLength="{Long}60"
name="optionval"
xtype="textfield"/>
<openaccordion
jcr:primaryType="cq:Widget"
name="selectaccordion"
type="radio"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<one
jcr:primaryType="nt:unstructured"
text="Open at Page Load"
value="in"/>
</options>
</openaccordion>
</fieldConfigs>
<limit
jcr:primaryType="nt:unstructured"
maxVal="{Long}15"/>
</typeconfigs>
</items>
But now i am not getting the behavior of radio button, means i can tick all radio buttons inside each tab that i add via dialog. Any idea how can i make that switch possible. Thanks
The radio button, as defined in your current structure needs two options, and the value of the field will toggle between the two options.In case you just want to show one option, I'd recommend using a checkbox.
I've tried to answer your question by assuming you decide to go ahead with a checkbox (which has two states, true and false). In case you decide to add a second radio button, you can change the values of true and false to the values that you have defined; (one of which is in)
What you are looking for is a set of custom listeners that
i) iterate through each multifield item, checking the value of <openAccordion> of the currently clicked multifield item.
ii) Set it to true for the current multifield item
iii) Set the value of <openAccordion> to false for all other multifield items.
The event that you'd require is selectionchanged.
Once you verify that the properties are getting set correctly, all you need is another listener that triggers on the loadcontent event, that looks for the multifield item with the value of <openAccordion> as true and displays that tab, hiding the rest.
As an aside, in my opinion, you might want to restructure your dialog, something similiar to what #Mathew posted in his comment.
<items jcr:primaryType="nt:unstructured">
<tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./options">
<items jcr:primaryType="nt:unstructured">
<wrapper
jcr:primaryType="nt:unstructured"
jcr:title="eon-feh-service-po.components.siteadmin.question.v1.dialog.tab.general.answeroptions.multifieldexpand"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/collapsible"/>
<items jcr:primaryType="nt:unstructured">
<isDropoutOpt
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/radiogroup"
name="./isDropoutOpt"
renderReadOnly="{Boolean}true"
text="Option selection leads to dropdown?">
<items jcr:primaryType="nt:unstructured">
<radioYes
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/radio"
text="YES"
value="yes"/>
<radioNo
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/radio"
text="NO"
value="no"/>
</items>
</isDropoutOpt>
Related
I am setting up a dialog that has the following fields -
1. A field to accept image as an input
2. A field to accept a title
3. A field that will accept richtext.
Please note that I do not want to enable inplace editing. I just want to add a richtext field (with all features enabled) in my dialog and use the data entered in this field in my component.
I am able to implement 1. and 2. but dont know how to go about 3.
Here is my code -
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Section Container"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<Styling
jcr:primaryType="nt:unstructured"
jcr:title="Styling"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<question_single
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldDescription="Please enter the Question"
fieldLabel="Question for Single"
name="./question_single"/>
<question_couple
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldDescription="Please enter the Question"
fieldLabel="Question for Couple Applicants"
name="./question_couple"/>
<page_header
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldDescription="Please enter page header"
fieldLabel="Page Header"
name="./page_header"/>
</items>
</column>
</items>
</Styling>
<image
jcr:primaryType="nt:unstructured"
jcr:title="Image Properties"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
margin="{Boolean}false"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<file
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/fileupload"
autoStart="{Boolean}false"
class="cq-droptarget"
fieldLabel="Image asset"
fileNameParameter="./image/fileName"
fileReferenceParameter="./image/fileReference"
mimeTypes="[image]"
multiple="{Boolean}false"
name="./image/file"
title="Upload Image Asset"
uploadUrl="${suffix.path}"
useHTML5="{Boolean}true"/>
<title
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Title"
name="./image/jcr:title"/>
</items>
</column>
</items>
</image>
</items>
</content>
</jcr:root>
Please ignore the fields in the first tab. richtext field needs to be added to the second tab.
Please help!
Thanks in Advance!
Adobe recommends to use the richtext field using the InPlaceEditing/Full Screen Editing instead of adding the fields in the dialog as the complete functionality is covered by In-place/Full-screen editing.
Click Here for the reference from Adobe Docs.
However, if you really wish to use the RTE field inside your dialog, you can make use of the sling:resourceType="cq/gui/components/authoring/dialog/richtext" property to do the same.
See sample code below (the code refers to a richtext field in the touch UI dialog, simply put this piece of code in your touch UI dialog xml at the relevant place to make the dialog work).
<description
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/authoring/dialog/richtext"
name="./rteTextPropertyName"
useFixedInlineToolbar="{Boolean}true">
<rtePlugins jcr:primaryType="nt:unstructured">
<subsuperscript
jcr:primaryType="nt:unstructured"
features="*"/>
<format
jcr:primaryType="nt:unstructured"
features="*"/>
<justify
jcr:primaryType="nt:unstructured"
features="*"/>
<spellcheck
jcr:primaryType="nt:unstructured"
features="*"/>
<misctools
jcr:primaryType="nt:unstructured"
features="[specialchars]">
<specialCharsConfig jcr:primaryType="nt:unstructured">
<chars jcr:primaryType="nt:unstructured">
<copyright
jcr:primaryType="nt:unstructured"
entity="©"/>
<trademark
jcr:primaryType="nt:unstructured"
entity="™"/>
<registered
jcr:primaryType="nt:unstructured"
entity="®"/>
<emDash
jcr:primaryType="nt:unstructured"
entity="—"/>
<pound
jcr:primaryType="nt:unstructured"
entity="£"/>
<nbsp
jcr:primaryType="nt:unstructured"
entity=" "/>
</chars>
</specialCharsConfig>
</misctools>
</rtePlugins>
<uiSettings jcr:primaryType="nt:unstructured">
<cui jcr:primaryType="nt:unstructured">
<inline
jcr:primaryType="nt:unstructured"
toolbar="[format#bold,format#italic,format#underline,#paraformat,image#imageProps,#justify,#lists,links#modifylink,links#unlink,findreplace#find,findreplace#replace,subsuperscript#subscript,subsuperscript#superscript,spellcheck#checktext,misctools#specialchars]">
<popovers jcr:primaryType="nt:unstructured">
<justify
jcr:primaryType="nt:unstructured"
items="[justify#justifyleft]"
ref="justify"/>
<lists
jcr:primaryType="nt:unstructured"
items="[lists#unordered,lists#ordered,lists#outdent,lists#indent]"
ref="lists"/>
<paraformat
jcr:primaryType="nt:unstructured"
items="paraformat:getFormats:paraformat-pulldown"
ref="paraformat"/>
</popovers>
</inline>
</cui>
</uiSettings>
</description>
P.S.: I have added only a few RTE plugins keeping the length of the sample code in mind. You can add other plugins as needed.
Make sure to provide the correct context if reading the property in sightly (in here html), see below:
${properties.rteTextPropertyName #context = 'html'}
I was developing touch UI component. Below is what i tried and worked at some extent. Below is dialog.xml
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<herotext
jcr:primaryType="nt:unstructured"
jcr:title="Hero Text Properties"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<myradiogroup
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radiogroup"
fieldLabel="Select Fruit"
name="./fruit">
<items jcr:primaryType="nt:unstructured">
<option1
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radio"
cq-msm-lockable="fruit"
renderReadOnly="{Boolean}true"
text="Apple"
value="apple"/>
<option2
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/radio"
cq-msm-lockable="fruit"
renderReadOnly="{Boolean}true"
text="Pear"
value="pear"/>
</items>
</myradiogroup>
</items>
</column>
</items>
</herotext>
</items>
</content>
After this I am able to render the radio selected value on the page. But having below issue.
1) Radio options are coming in vertical direction, but i want them in horizontal.
2) Radio Group Name not display, I want same like as fieldLabel & want to hide hide the border line.
3) When i reopen the dialog, radiobutton is not selected even if the selected value stored in JCR during last submit.
Thanks
For getting the Radio Buttons in horizontal direction use following class as property with coral-RadioGroup--horizontal value. This is the OOTB class provided by AEM, you can also have your custom class to control layout and alignment
For displaying the Radio Button Group label use text property.
On opening the dialog, properties are populating fine. See if you have any other radiobuttongroup in same dialog with same name.
I am designing a dialog in which i want the radio buttons displayed horizontally and not vertically, so that appear in a single line. Any ideas how to achieve this.
Below is my dialog.xml.
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Slider">
<items jcr:primaryType="cq:WidgetCollection">
<typeconfigs
jcr:primaryType="cq:Widget"
fieldLabel="Select Videos"
name="./options"
xtype="customconfigmultifield">
<fieldConfigs jcr:primaryType="cq:WidgetCollection">
<gridlayout
jcr:primaryType="cq:Widget"
itemId="dispotions"
name="selcttab"
type="radio"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<grid1
jcr:primaryType="nt:unstructured"
text="grid1"
value="grid1"/>
<grid2
jcr:primaryType="nt:unstructured"
text="grid2"
value="grid2"/>
<grid3
jcr:primaryType="nt:unstructured"
text="grid3"
value="grid3"/>
<grid4
jcr:primaryType="nt:unstructured"
text="grid4"
value="grid4"/>
</options>
</gridlayout>
</fieldConfigs>
<limit
jcr:primaryType="nt:unstructured"
maxVal="{Long}6"/>
</typeconfigs>
</items>
</tab1>
</items>
Thanks
You can try using ExtJS Layouts for the same. There are various ways of configuring the same, one of which could be using an hbox layout as shown below.
Use the layout config available for Selection Widget and set its value to hbox. Then use the optionsConfig to set the width that applies to each radio box. Since the optionsConfig accepts an object, create it is a child node of your selection and then set the required styles.
Sample Dialog Structure shown below.
<gridlayout
jcr:primaryType="cq:Widget"
itemId="dispotions"
name="selcttab"
type="radio"
xtype="selection"
layout="hbox">
<options jcr:primaryType="cq:WidgetCollection">
<grid1
jcr:primaryType="nt:unstructured"
text="grid1"
value="grid1"/>
<grid2
jcr:primaryType="nt:unstructured"
text="grid2"
value="grid2"/>
<grid3
jcr:primaryType="nt:unstructured"
text="grid3"
value="grid3"/>
<grid4
jcr:primaryType="nt:unstructured"
text="grid4"
value="grid4"/>
</options>
<optionsConfig
jcr:primaryType="nt:unstructured"
width="60" />
</gridlayout>
This solution works in general, however, i notice that there is a custom widget customconfigmultifield defined under which you are configuring a selection field. So you might need to tweak your styles accordingly.
I need to create a component (say componentA) whose aim is to allow a user to add a variable number of components (choosing from componentB and componentC). So componentA is like a parsys which contains others components.
I'm using a multifieldpanel to create a component's dialog with a user controlled number of field. Something like this:
The problem is when I try to eliminate one of the elements added directly from the dialog of componentA: the element is effectively eliminated from the dialog but it actually remains inside the CRX.
My CRX is something like:
componentA
componentASon_0
componentASon_1
If I remove the component (componentASon_0 or componentASon_1) with a "right-click and delete" it works properly.
Any advice?
Here a snippet of the dialog relative to the componentA:
<tabMain
jcr:primaryType="cq:Widget"
title="myPanelTitle"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<settings jcr:primaryType="cq:Widget"
fieldLabel="Payment Settings"
fieldDescription="Click the '+' to add a new block"
name="./settings"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<component
jcr:primaryType="nt:unstructured"
defaultValue="Choose a component"
fieldLabel="Component"
type="select"
value=""
key="componentType"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<componentB
jcr:primaryType="nt:unstructured"
text="ComponentB"
value="/apps/project/components/commons/componentB"/>
<componentC
jcr:primaryType="nt:unstructured"
text="ComponentC"
value="/apps/project/components/commons/componentC"/>
</options>
</component>
</items>
</fieldConfig>
</settings>
</items>
</tabMain>
Every page in CQ5 can have an image attached to it in page properties. I need to add my own image property to be used in a component.
I am able to add small things as a check box using this link but when I add a new image tab in the page properties, even the existing image stops working.
Even if I can add another image dialog in the page, I am unable to fetch the new image. This is the new image dialog I've added. (see attachment)
I just want to use the image in the carousel [maybe fetch it using :
Resource r = page.getContentResource("image1");
Can someone please help me on this ? What properties do I at least need to make it work ?
You need to use an xtype of smartimage (or a version of this, e.g. html5smartimage).
Here's some sample code that will add two images in a dialog — imageOne and imageTwo. You need to make sure that the properties of your new image don't conflict with the existing one — namely the fileNameParameter, fileReferenceParameter, name and the name of the child node resType should be unique in the example below.
<items jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<imageOnePanel
jcr:primaryType="cq:Panel"
title="Image One Panel">
<items jcr:primaryType="cq:WidgetCollection">
<imageOne
jcr:primaryType="cq:Widget"
border="true"
ddGroups="[media]"
fileNameParameter="./imageOne/fileName"
fileReferenceParameter="./imageOneFileReference"
height="300"
hideLabel="true"
name="./imageOne/file"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./imageOne/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</imageOne>
</items>
</imageOnePanel>
<imageTwoPanel
jcr:primaryType="cq:Panel"
title="Image Two Panel">
<items jcr:primaryType="cq:WidgetCollection">
<imageTwo
jcr:primaryType="cq:Widget"
border="true"
ddGroups="[media]"
fileNameParameter="./imageTwo/fileName"
fileReferenceParameter="./imageTwoFileReference"
height="300"
hideLabel="true"
name="./imageTwo/file"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./imageTwo/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</imageTwo>
</items>
</imageTwoPanel>
</items>
</items>
Reusing code from the dialog & not giving unique properties might have caused you issues with adding a second image, though I'm not 100% from the error you're seeing.