I am trying to save the value entered by an Author in a NumberField as a 'Long' instead of 'String'. Is there a way to configure this or do I have write something custom?
You can use TypeHints. Add a hidden field (xtype:hidden) with name = <numberField'sName>#TypeHint and value= Long
Add as below for double value and its failing for decimal value i.e. its not allowing decimal values
<price jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/numberfield"
fieldLabel="Product Price"
name="./price"/>
<priceHint jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden"
name="./price#TypeHint"
value="Double"
defaultValue="Double"/>
This works fine for me. :)
<noOfViews jcr:primaryType="cq:Widget" fieldLabel="No. of Views" name="./noOfViews" xtype="numberfield"/>
<noOfViewsHint jcr:primaryType="cq:Widget" defaultValue="Long" name="./noOfViews#TypeHint" value="Long" xtype="hidden"/>
Related
I have datpicker in multifield.
But on opening the dialog the authored values are not getting displayed.
When i do inspect element on dialog field it comes as
*<input class="coral-InputGroup-input coral-Textfield" type="text" value="">
<input type="hidden" name="./date" value="2016-06-01T00:00:00.000+05:30">*
Can you please suggest what can be the issue and how to resolve it?
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/fieldset"
eaem-nested=""
fieldLabel="Click on the + button to add Fields"
name="./admission">
<layout
jcr:primaryType="nt:unstructured"
sling:resouceType="granite/ui/components/foundation/layouts/fixedcolumns"
method="absolute"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<date
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/datepicker"
fieldLabel="Date of Event"
name="./date"
type="date"/>
<startTime
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/datepicker"
fieldLabel="Opening time of event"
name="./startTime"
type="time"/>
<endTime
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/datepicker"
fieldLabel="Closing time of event"
name="./endTime"
type="time"/>
<dayname
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/hidden"
fieldLabel="Dayname"
name="./dayname"/>
</items>
</column>
</items>
</field>
First of all, you have a misspelling in sling:resouceType="granite/ui/components/foundation/layouts/fixedcolumns". You effectively don't have a sling:resourceType set.
However, there's also a more important issue. The Granite Multifield component doesn't work this way. Reading the documentation on the granite/ui/components/foundation/form/multifield we can see exactly how the data is saved and repopulated on subsequent dialog openings.
The field to be included is defined in the subnode named field.
Regardless of the component used, Multifield assumes they all write to
the same property (defined by the name property of the field subnode)
thus the resulting value will always be multi value.
When rendering existing entries, the Multifield will iterate over the multi value, get each value, set it in the field and let the field render it.
In order to accomplish what you're looking to do, you will have to write some custom code. A quick Google search revealed this two blog posts that can help you:
http://experience-aem.blogspot.com/2015/06/aem-61-touch-ui-composite-multifield-store-values-as-child-nodes.html
http://experience-aem.blogspot.com/2015/02/aem-6-sp2-touch-ui-multi-field-component.html
To reiterate, if you fix your typo, the fieldset and datepickers will show in your multifield. However, even though the dialog will display correctly, you won't be able to save or retrieve the data in this manner.
I use xtype 'multifieldpanel' from ACS.CQ library for 'multifield configuration'. And I can't set size for 'pathfield' in my dialog. I need 100% (fixed size in 'px' doesn't work too) similar with 'textfield'. I have tried all cases (width, boxMaxWidth, autoWidth), what I do wrong??
<links
jcr:primaryType="cq:Widget"
fieldLabel="Items Location"
itemId="links"
name="./links"
xtype="multifield">
<fieldConfig
jcr:primaryType="nt:unstructured"
xtype="multifieldpanel">
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
allowBlank="{Boolean}false"
fieldLabel="Title"
width="100%"
key="title"
xtype="textfield"/>
<url
jcr:primaryType="cq:Widget"
allowBlank="{Boolean}false"
fieldLabel="URL"
boxMaxWidth="100%"
key="url"
xtype="pathfield"/>
</items>
</fieldConfig>
In the dialog,you have to give properties for pathfield as follows
name:width
type:Long
value:(as required) for ex:500
Similarly for textfield also you can follow the above procedure
1.Create a node in your component of type cq:EditConfig and name cq:editConfig, this should be a sibling of the dialog node.
2.To the cq:editConfig node add a property with name “cq:dialogMode”, type “String” and value “floating”
3.To your dialog node add two properties of type Long, name height and width and value to what the you want the size of the dialog to be.
try autoWidth="true" style="width: 90%"
I have 3 checkbox widget in my dialog & and on the basis of no of selection code perform the logic, Issue is when i tick option1 option2, then they set their value in the content node to "ON". But if i edit the same component option1, option2 are select , i unselect the one and click ok, Still in the content node property exist with value "ON".
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Dialog"
title="dialog"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Select Options">
<items jcr:primaryType="cq:WidgetCollection">
<facebook
jcr:primaryType="cq:Widget"
fieldLabel="Facebook"
name="./facebook"
xtype="checkbox"/>
<twitter
jcr:primaryType="cq:Widget"
fieldLabel="Twitter"
name="./twitter"
xtype="checkbox"/>
<linkedin
jcr:primaryType="cq:Widget"
fieldLabel="Linkedin"
name="./linkedin"
xtype="checkbox"/>
</items>
</tab1>
</items>
</items>
</jcr:root>
I have not had a lot of success with the checkbox xtype. Rather, try the selection xtype, with a type of checkbox.
<facebook
jcr:primaryType="cq:Widget"
fieldLabel="Facebook"
name="./facebook"
type="checkbox"
xtype="selection"/>
the problem you have is that when you uncheck the checkbox, the form is simply not sending that field into the POST, so Sling simply does not modify that property at all.
To be able to persist the unchecked state you need to add default values. You can do that with Sling Suffixes.
parameter#Delete, causes a property to be deleted from jcr if no other value has been sent. in your case you could interpret no property as unchecked
parameter#DefaultValue can be used to send a default value in case parameter was sent without any value
parameter#UseDefaultWhenMissing = true, can be used to force Sling to use the default value when the parameter was not sent at all.
So, in your particular case, add hidden fields (xtype:hidden) with the following names & values.
./facebook#DefaultValue="off"
./facebook#UseDefaultWhenMissing="true"
That would make sure that the value "off" is used when the checkbox is unchecked.
ps-Yes, it is that annoying to use checkboxes in AEM/CQ
I'm having difficulty on how to add options to a selection for dialog.
The Adobe notes I'm reading are here: CQ.form.Selection
Scrolling down to options : Object[]/String will show you two ways to reference the options to provide the said selection, via object or string. I am trying to use the object method. The format example they provide is sufficient.
[
{
value: "pink", // all types except "combobox"
text: "Pink",
qtip: "Real Pink" // "select" and "combobox"
}
]
However, CRXDE Lite does not allow me to select or type Object when adding a new property, and this is where I am at a loss. Is there another way to enter a complex value?
Adding options as an Object[] would be done via a child node, rather than properties. (In fact anywhere you see an Object in the API, think node rather than property.)
In your dialog.xml file, this would be done as follows:
<selectList
jcr:primaryType="cq:Widget"
defaultValue="0"
fieldLabel="Number"
name="./number"
type="select"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<one
jcr:primaryType="nt:unstructured"
text="One"
value="1"/>
<two
jcr:primaryType="nt:unstructured"
text="Two"
value="2"/>
<three
jcr:primaryType="nt:unstructured"
text="Three"
value="3"/>
<four
jcr:primaryType="nt:unstructured"
text="Four"
value="4"/>
</options>
</selectList>
In CRXDE, this can be achieved by creating the same hierarchy:
Right-clicking your selection node and choosing Create > Node.
Give this node a jcr:primaryType of cq:WidgetCollection. This will hold your option values.
Individual options can now be added as child nodes of this, with a jcr:primaryType of nt:unstructured.
Place your properties (value, text, qtip) on these child nodes.
The widget API suggests that you can change the default wrapping tag for the rich text editor content via the DocType object on the HtmlRules object under a rich text editor:
defaultEditBlock : String
The default edit block type to use; defaults to "p" Added in CQ 5.4.
I need to change this so that I can include the content of a rich text editor field within a p tag which has a particular class (you cannot put one p tag inside another so the automatic wrapping breaks out of my predefined p tag).
Unfortunatly it would seem that this node is being ignored.
What do I need to do to remove the p tags or if not that then change them to something that would go inside a p tag?
The following is the xml for the rich text editor, the rtePlugins node seems to work correctly but not the htmlRules node.
<introText
jcr:primaryType="cq:Widget"
allowBlank="{Boolean}false"
fieldLabel="Intro text"
name="./introText"
xtype="richtext">
<htmlRules jcr:primaryType="nt:unstructured">
<docType jcr:primaryType="nt:unstructured"
defaultEditBlock="span">
</docType>
</htmlRules>
<rtePlugins jcr:primaryType="nt:unstructured">
<edit jcr:primaryType="nt:unstructured"
features="[cut,copy,paste-default,paste-plaintext]"/>
<format jcr:primaryType="nt:unstructured"
features="[]"/>
<justify jcr:primaryType="nt:unstructured"
features="[]"/>
<lists jcr:primaryType="nt:unstructured"
features="[]"/>
</rtePlugins>
</introText>