Experiences with CQ/CRX

01.04.2009

Custom Validation Function In Dialogs

Filed under: Development — daygrep @ 15:48

Sometimes it is desirable to have a particular input widget in a CQ5 WCM dialog to be fitted with a custom validation. Imagine you have two password fields and you would like to validate that the passwords match prior to saving the dialog.

The Dialog
The following is a simple dialog that features two input widgets for passwords:

<?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"
    xtype="panel">
    <items jcr:primaryType="cq:WidgetCollection">
                <password
                    jcr:primaryType="cq:Widget"
                    fieldLabel="Password"
                    name="./password"
                    allowBlank="false"
                    xtype="password"/>
                <passwordConfirm
                    jcr:primaryType="cq:Widget"
                    fieldLabel="Confirm Password"
                    name="./password"
                    allowBlank="false"
                    validator="function(value) { verifyPasswords(value) }"
                    xtype="password"/>
    </items>
</jcr:root>

Notice the validator property on the passwordConfirm input. It specifies a function that is evaluated and itself references a function, that you can easily define in a custom JavaScript file included in the head of your page in authoring mode.
(more…)

Opening a Page in CQ5 WCM without Content Finder

Filed under: Configuration, Development — daygrep @ 10:07

In a CQ5 WCM authoring environment, when you open a page via double-click, by default the Content Finder is loaded and the actual content page displayed in a frame. While this is desirable in most cases, the are pages whose functionality does not require the presence of the Content Finder, e.g. tool templates that don’t allow content creation, like adding new paragraphs.

In order to prevent a page opening in the Content Finder view, choose from the following two options:

  • On the page component’s definition, set the following property:
    cq:defaultView="html"
    This is probably the preferable way, as renouncing the content finder in most cases pertains to all pages based on a template and thus page component.
  • On any content page, e.g. on /content/geometrixx/jcr:content, set the following property:
    cq:defaultView="html"
    This is the way to specifically set an exception where otherwise the page component would allow the content finder view (implicitly: cq:defaultView=”contentfinder”).

Blog at WordPress.com.