FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Oct 4, 2011, 5:31 PM
64 Posts

How does one use computed data for a multi-value custom control property?...

  • Category: Other
  • Platform: Windows
  • Release: 8.5.1
  • Role: Developer
  • Tags: custom control,property,computed
  • Replies: 2
- I have this custom control that has a multi-value property.  That multi-value property is a group, so it contains subordinate custom properties.  This works well for hard-coding:
 
<xc:control>
  <xc:this.multiValueProp>
    <xc:multiValueProp subProp1="first" subProp2="second" />
    <xc:multiValueProp subProp1="eins" subProp2="zwie" />
  </xc:this.multiValueProp>
</xc:control>
 
What I need to do is replace <xc:this.multiValueProp> with a computed expression that passes data to the custom control in a way that it understands.
 
- Inside the custom control, compositeData.multiValueProp is an array, and each element of that array has subProp1 & subProp2:
 
   compositeData.multiValueProp[0].subProp2 is "second".
 
So far I've only gotten one element to pass in when computed:
 
<xc:control>
  <xc:this.multiValueProp><![CDATA[#{javascript:
var oneEntry = { subProp1: "first", subProp2: "second" };
return oneEntry;
  </xc:this.multiValueProp>
</xc:control>
 
The above works, but so far I have been unable to add more than one entry.
 
var twoEntries = { { subProp1: "first", subProp2: "second" }, { subProp1: "eins", subProp2: "zwie" } }
return twoEntries;
^^-- Fail with : expected after first {
var twoEntries = [];
twoEntries.push( { subProp1: "first", subProp2: "second" } );
twoEntries.push( { subProp1: "eins", subProp2: "zwie" });
return twoEntries;
^^-- Fail without error, but without data in xc:control, either
var twoEntries = new java.util.Vector();
twoEntries.add( { subProp1: "first", subProp2: "second" } );
twoEntries.add( { subProp1: "eins", subProp2: "zwie" });
return twoEntries;
^^-- Fail at add() because the JSON isn't recognized.
 
- Any thoughts on doing this?  Thanks for your time...
Oct 5, 2011, 1:50 AM
56 Posts
Re: How does one use computed data for a multi-value custom control property?...
Hello David,
 
I dont know whether I understand your problem correctly, but I think you're making it harder than it has to be for you.
 
My suggestion:
Create a property called whatever you want, set the type to arrayand allow multiple instances of this property.
Then you create your array(s) and pass some of them to the custom control.
 
var array= {
  propertyOne: true,
  propertyTwo: false
};
 
var array2= {
  propertyOne: true,
  propertyTwo: false
};
 
Oct 5, 2011, 10:45 AM
64 Posts
Re: How does one use computed data for a multi-value custom control property?...
- Hmmm.  I could add a property that's only used when the data are computed.  One of the goals of this custom control is it should leverage the DDE click-fest Design tab, so one should be able to add static data easily using Properties without having to resort to code or data structures.  I'll try a dedicated computed property and see how that goes.
 
- I sure wish I could see the post I'm replying to.  I can't remember if the person was Matthew or Mathias (or another M entirely).  A mind is a terrible thing.
 
EDIT:
 
- Ha.  After I submit I can see, and edit:
 
Thanks Matthias!...

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.