I have a static list of drop down,but i want to fetch both value and Text from the drop down in AEM touch UI.
<articleType
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
fieldLabel="Article Type"
name="./articleType">
<items jcr:primaryType="nt:unstructured">
<select
jcr:primaryType="nt:unstructured"
text="Select Icon"
value=""/>
<article
jcr:primaryType="nt:unstructured"
text="Article"
value="article"/>
<video
jcr:primaryType="nt:unstructured"
text="Video"
value="video"/>
<infographic
jcr:primaryType="nt:unstructured"
text="Infographic"
value="graph"/>
</items>
</articleType>
Now I want to fetch it like <i class="article-icon icon" />. I can fetch "icon class" from "value" but i need to always have some test conditions to fetch the text.
So i want a solution for this.
I have used data sources for this kind of requirements. In the example listed below, a jsp file is used. You can very well create WCMUsePojo class and call it in a HTML to refer the dynamic text and value pairs.
Please check:
https://helpx.adobe.com/experience-manager/using/creating-granite-datasource.html
Related
New to AEM, I am trying to programatically populate an fileUpload image dropzone, and silently triggered its drop event as if user had manually drop an image asset to it. Is there a way to do this?
Say I have a cq_dialog with two fileUpload image fields (set to no upload, only droppable from asset allowed), one was already populated prior, the other is empty. Upon dialog load, I want to populate the empty one with the image asset from the populated one as a default.
The snippets of the cq_dialog looks like this:
<imageontopWrap
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container"
class="layout-showhide-targets"
showhidetargetvalue="imageontop">
<items jcr:primaryType="nt:unstructured">
<image1
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/authoring/dialog/fileupload"
autoStart="{Boolean}false"
allowUpload="{Boolean}false"
class="cq-droptarget"
fieldLabel="Image Asset"
fileReferenceParameter="./myImageTopPath"
mimeTypes="[image]"
multiple="{Boolean}false"
name="./myImageTop"
title="Upload Image Asset"
useHTML5="{Boolean}true"/>
<altText1
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Alt Text"
name="./myImageTopAltText"/>
</items>
</imageontopWrap>
<imageonleftWrap
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container"
class="layout-showhide-targets"
showhidetargetvalue="imageonleft">
<items jcr:primaryType="nt:unstructured">
<image2
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/authoring/dialog/fileupload"
autoStart="{Boolean}false"
allowUpload="{Boolean}false"
class="cq-droptarget"
fieldLabel="Image Asset"
fileReferenceParameter="./myImageLeftPath"
mimeTypes="[image]"
multiple="{Boolean}false"
name="./myImageLeft"
title="Upload Image Asset"
useHTML5="{Boolean}true"/>
<altText2
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Alt Text"
name="./myImageLeftAltText"/>
</items>
</imageonleftWrap>
I had created a clientLib for this cq_dialog, just wasn't sure the js codes to copy the image reference and trigger the drop using script.
Any help is much appreciated.
Here is the mechanism through you can achive what you require I hope. I am not sure about the exact js code though for which you have to do some googling on listners.
On dialog load, store the reference of the first image drop container in a js variable.
Then find the path of the image that is being stored/authored in the first image container.
Populate the same path in the second image drop path.
As I said, above is just a mechanism to help how you can achive your requirement.
I'm currently using Rich Text Editor (RTE) in my AEM 6.2 project. I would like to configure RTE to use blockquote tag. How can achieve this?
<blockquote>
Component code:
<paraformat jcr:primaryType="nt:unstructured" features="*">
<formats jcr:primaryType="cq:WidgetCollection">
<p jcr:primaryType="nt:unstructured" description="Paragraph" tag="p"/>
<h1 jcr:primaryType="nt:unstructured" description="Heading 1" tag="h1"/>
<h2 jcr:primaryType="nt:unstructured" description="Heading 2" tag="h2"/>
<h3 jcr:primaryType="nt:unstructured" description="Heading 3" tag="h3"/>
<h4 jcr:primaryType="nt:unstructured" description="Heading 4" tag="h4"/>
<h5 jcr:primaryType="nt:unstructured" description="Heading 5" tag="h5"/>
<blockquote jcr:primaryType="nt:unstructured" description="Block Quote" tag="blockquote"/>
</formats>
</paraformat>
Reference:
RTE in JCR
Dialog View
Thanks.
You can add a new block element by following the instructions at official documents:
Adding custom paragraph formats to RTE
Basically, you overlay the RTE and extend the paraformat plugin by introducing the new elements. Summary steps are:
Overlay your RTE
Create cq:EditConfig/inplaceEditing/paraformat/format node under your RTE control.
Create a node for your style, name it blockquote and give it the following properties -> Description: Block Quote & Tag: blockquote
Make sure you add all other default formats like p, H1, H2 etc.
That's it. You should see your new paragraph style available in the paragraph styles dropdown.
This is a summary as all the pictures will make this post too long but a detailed post can be found at: http://www.aemcq5tutorials.com/tutorials/configure-rte-plugin-in-touch-ui/
Optionally, you will need to check if blockquote element is allowed by inspecting your /libs/cq/xssprotection/config.xml file. The file is self explanatory with lots of comments but in general you should check under <tag-rules> to ensure that your tag is supported. OOTB AEM 6.2 allows blockquote element but some upgrades might have lost it.
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 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>
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>