xPages Custom Control with Custom Property Group that allows Multiple Instances

后端 未结 2 750
醉酒成梦
醉酒成梦 2021-01-26 09:55

I\'ve create a custom control that has a Property Definition Group. The Group has checked to \"Allow multiple instances\". When I drop the control on an xPage I can through th

2条回答
  •  一向
    一向 (楼主)
    2021-01-26 10:43

    I tend to define a Custom Control Property named "configuration", and set that to be an "object" (you'll have to type that in vs. select it from the dropdown):

    Custom Control Property: configuration

    Now, you can pass an object as your property:

    return {
      "groups" : {
        "groupA" : {
            altName : "A Group",
            members : ["me", "you", "them"]
        },
        "groupB" : {
            altName : "B Group",
            members : ["him", "her", "they"]
        }
    },
      otherOption : "something else"
    }
    

    When viewed in the XPages Source:

    
     
    

    Now, to loop though this, you could easily use an xp:repeat control bound to #{compositeData.configuration.groups}, and then all "child" binding can be done directly to the variable defined for the xp:repeat:

    
      
        
      
      
        
          
            
          
        
      
    
    

    Using this approach, you're not limiting to the size, the scope, nor the content contained within your Custom Control Property.

提交回复
热议问题