Expand my Community achievements bar.

SOLVED

MultiField Widget (When Author enters only one value)

Avatar

Level 4

dialog.xml

                    <values

           jcr:primaryType="nt:unstructured"

                        fieldLabel=“Values”

                        name="./values"

                        xtype="multifield"/>

JSP 

    <c:forEach items="${properties. values}" var="value" varStatus="loop">

        <c:if test="${loop.index == 0}">

            ${value}

        </c:if>

        <c:if test="${loop.index != 0}">

            and ${value}

        </c:if>

</c:forEach>

 

For this multi-field when author enters only one Value as "Some text , Some text2" 

JSP displays : "Some text  and Some text2" . Adding ',' in the single multifield value converts it to an array (I think) . Is this the default implementation for multifield ? 

But When Author Enters two separate values  for Multi-field :  

"Some text , Some text2  "

"Some text , Some text2 "

JSP displays it correctly : Some text , Some text2 and Some text , Some text2

1 Accepted Solution

Avatar

Correct answer by
Level 8

It's a pretty easy fix - in your dialog, change the definition to this:

<values jcr:primaryType="nt:unstructured" fieldLabel=“Values” name="./values" typeHint="String" xtype="multifield"/>

Note the "typeHint" - this forces the value to be saved as a string array when used in a multi-field.

View solution in original post

2 Replies

Avatar

Level 10

Yup,

I guess we faced similar issue with multifield long back, It would be great to raise a day care ticket for this, seems to be a bug

Avatar

Correct answer by
Level 8

It's a pretty easy fix - in your dialog, change the definition to this:

<values jcr:primaryType="nt:unstructured" fieldLabel=“Values” name="./values" typeHint="String" xtype="multifield"/>

Note the "typeHint" - this forces the value to be saved as a string array when used in a multi-field.