This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 14, 2011, 10:38 PM
8 Posts
topic has been resolvedResolved

Dynamic value binding

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: Dynamic Design,datasource
  • Replies: 5
 I've tried the 'Define dynamic value binding for a field at development time in the XML source' (http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_documents_and_fields_on_the_XPage) inside a repeat control containing a Edit Box. What I find is the control renders in a SPAN tag instead of an INPUT tag when the value computes the item name.
 
So if the formula is value="#{dominoDoc['field1']}", the HTML displays an INPUT element. However, if the formula is value="#{dominoDoc['field'+rID]}" where rID is a string element, the HTML displays in a SPAN tag. I have tried many variations on this form, and nothing seems to work. Am I being dense? or is this a problem?
Jun 15, 2011, 5:30 AM
129 Posts
Re: Dynamic value binding
Probably an Expression Language limitation when you compute the name of the field inside the value binding.
 
It probably won't work, but have you tried: 
value="#{dominoDoc[('field'+rID)]}" 
Jun 15, 2011, 12:49 PM
8 Posts
Re: Dynamic value binding
 Thanks for the suggestion, Tommy. Yes, tried that, no difference. I'm puzzled insofar as the example given used a scope variable, and that supposedly works. I tried to compute the variable name outside the main expression like this
fN = 'field'+rID 
value="#{dominoDoc[fN]}" 
and that didn't work either. I've used a bunch of print statements to verify the field name binding is correct, which it is, at least the print outputs the expected field name. This has me stumped - any suggestion is appreciated.
Jun 15, 2011, 5:37 PM
129 Posts
Re: Dynamic value binding
What is the repeat control value binding?
Jun 16, 2011, 1:04 PM
23 Posts
Re: Dynamic value binding
 
I have many controls that do this and I have tried several different techniques over the years based on what I saw on blogs, presentations, etc.

Here is what is working for me...
 
1. Put the field on a Custom Control
2. Add string property to the Custom Control
3. Set the binding to get the field name from the property.
4. Provide the value to the string property when it is used (works fine in a repeat control).

Example:
 
<xp:radioGroup id="radioGroup2">
        <xp:this.value><![CDATA[#{document1[compositeData.fieldName]}]]></xp:this.value>
        <xp:selectItems id="selectItems2">
            <xp:this.value><![CDATA[#{javascript:@DbLookup(blahblahblah)}]]></xp:this.value>
        </xp:selectItems>
    </xp:radioGroup>
 
 
I know others have said you could also  dynamically set the data source but I have tried many different versions of that and have not been successful.
 
If anyone has  a working bit of code they could post that would be fantastic.
Jun 21, 2011, 10:14 PM
8 Posts
Re: Dynamic value binding
One idiosyncrasy that I found maddening ... to successfully bind the data source you need to specify as a simple binding. As such, this works fine   
 
<xp:this.value><![CDATA[#{document1[compositeData.fieldName]}]]></xp:this.value>
 
Whereas this does not 
 
<xp:this.value><![CDATA[#{javascript:document1[compositeData.fieldName]}]]></xp:this.value> 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal