0
votes

I would like to create a custom control which shows 3 columns, column 1, value selected from checkbox (this is ok) column 2, editable box , this is showing but not working 100% column 3, a button to remove the row (still to be done)

So far: After selecting the options, click "Create Rows" button and 1 row appears for each selected option.

Problem: Only last value in editable box, is used, how can I get the value from each box ? getComponent("inputText1").getValue() only shows the last value.

Example code is on this URL:

http://snipt.org/AAgd3

2

2 Answers

3
votes

You bind the column values to array variables. Exercise 23 has a complete working example: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Tutorial-Introduction-to-XPages-Exercise-23

You just need to adjust it to the source/destination of your data. Let us know how it goes

0
votes

If you want to bind them dynamically, you can also do this with expression language. It takes a bit of getting around in order to get the fields editable, but the way I've resolved it is to pass a calculated ID into a custom control, then using that for the binding.

For example: If I'm Working with a list of Unique Part Names, I may pass into my custom control a variable for a Comment. If I pass this in as fieldNameComment to my custom control, I can dynamically bind it to an inputText element through the following code.

I'm using a DominoDocument passed in as the dataSource.

Calling the Custom Control:

<xp:repeat var="CurrVal" value="#{DataSource}">
    <xc:DynamicTableRow dataSource="#{EmissionsDocument}">
       <xc:this.fieldNameComment><![CDATA[#{javascript:CurrVal+"Comment"}]]></xc:this.fieldNameComment>
    </xc:DynamicTableRow>
</xp:repeat>

Inside the Custom Control:

<xp:inputText id="inputText5" 
    value="#{compositeData.dataSource[compositeData.fieldNameComment]}">
</xp:inputText>

As long as (for some reason) none of the string calculations are performed within the expression language syntax, this will yield an editable field. In my testing, if I tried to calculate a value by concatenating any strings, the field would be bound, but not appear as editable under any circumstances. If you want to bind directly to fields, this may be a good approach, but if you want to save your array and parse it through java, then Stephan's solution also works great Hope this helps!

Appended: Added repeat control to show iteration through the data source. Each iteration of the Data Source yeilds a value, CurrVal, to which the string "Comment" is appended. This creates a series of FieldNames based on the Values in the DataSource that are bound to inputs within the custom control called DynamicTableRow