Skip navigation

CQ5

paul.bjorkstrand
Currently Being Moderated

How can you point multiple dialog field widgets to the same jcr node field?

Jul 2, 2012 9:23 AM

I am trying to have two fields within the same dialog point to the same field.  Structure:

  • dialog
    • items
      • tab1
        • items
          • field 1.1 (numberfield, points to ./maxResults)
      • tab2
        • items
          • field 2.1 (numberfield, points to ./maxResults)

 

The problem, is that this is being translated into ./maxResults beinf a String[] instead of a String in the JCR node.  The numberfields do not handle String[] very well at all.  Is this by design or could this possibly be a defect?  To me, it would be intuitive for these two numberfields to both be pointing to the same JCR field, and that field's type should be String.

 

I have worked around this by just using separate fields (changing one to maxResults2), but I am just curious as to if this is expected behavior.

 

Thanks,

Paul

 
Replies
  • Currently Being Moderated
    Jul 2, 2012 9:40 AM   in reply to paul.bjorkstrand

    I think this is not a defect. You have two input fields with the same name "maxResults", the sling framework will now asume that the jcr property is of type String[] array, because the SlingHttpRequest contains two Values for the parameter name "maxResults".

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2012 11:50 AM   in reply to paul.bjorkstrand

    In fact it is possible to force a type. You can try following:

     

    Add this to your dialog.xml (if you use xml to define dialogs, if not than you have to create the node maxResultsTypeHint manually)

     

                    <maxResultsTypeHint

                        jcr:primaryType="cq:Widget"

                        ignoreData="{Boolean}true"

                        name="./maxResults@TypeHint"

                        value="String"

                        xtype="hidden"/>

     

    See also http://sling.apache.org/site/manipulating-content-the-slingpostservlet -servletspost.html

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 11:56 PM   in reply to mkiti

    In fact it is possible to force a type.

     

    But you won't have control over which value is written. Since the parameters end up in a hash on the server-side, it could be either value. Unless you make sure they are always identical on the client-side.

     

    However, I think I would rather redesign the dialog to not duplicate the value. Or you have one (extjs) field simply display & update the value of the other one, without actually using a form field that is submitted.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points