I'm trying to add the following value to a computed field:
var b = #Subset(#Unique(#DbColumn (#DbName(),"vwNrRegistru",1)),-1);
if (#Elements(b)<1){return 10001; }
else { return (b+1);}
But, I want the computed field to be binded to a datasource field:
<xp:text escape="true" id="computedField1" value="#{Contr.txt_nrcontractcv}">
I would use an inputText, but everytime I open the doc. for editing, the value increments, that's the reason I would like to go for a computed field. How can I achieve this?
You want to take the value from an existing Notes field, then do some calculation on that, then display the result, right?
You might want to bind your comp. field to a scoped var. Then do the basic calculation beforePageLoad and put the result into the scoped var. You can easily control when the calculation takes place, e.g. only for new docs, or on specific times of day or whatever
Create a inputText with style="display:none;", so that it is always rendered*, but never shown on the screen and a 'computed field' (text) that simply is equal to the value of the non-displayed field.
when they chose to label the value in properties as "Visible" they made a mistake. They really ought to have called it "Rendered" in the properties. It might also have been useful for them to have a "Displayed" property to allow you to control the display style, but that would have been mixing too many things.
Related
I have a repeat control that is gathering its data from a view. Displaying in a table is one column from the view. These entries can be variable. For each entry in the repeat control I would like to have a couple of user editable fields (comments and checkboxes). Since the amount and names of entries are dynamic I think dynamic field binding is the way to go. The problem is I have been struggling with it for a few days and have gotten no where.
So in the repeat I have a computedfield displying the value of the column. I was thinking of making the field name for the comments field the value of the computedfield. The datasource would be the same, just the fieldnames would change and be based on the entries in the row.
The previous entries stackoverflow entries about dynamic field binding all list passing custom properties, I still haven't gotten my head around those.
If the value of the computedfield1 = "One" then the datasource/field name for the inputText1 = "document1.One", and if the computedField1 = "Two" then the datasource inputText1 = "document1.Two"
Is this even possible?
I'm a little confused by if you want these to be things you're setting to render at page load or if you want them to dynamically change based on user entered data, but I'll assume it's the former and give you an example.
If I'm iterating through a view in a repeat control, I probably have something like:
<xp:repeat rows="50" var="currRow" value="#{ViewName}" IndexVar="rowNum">
</xp:repeat>
Inside my repeat, I will put a reference to a custom class
<xp:repeat rows="50" var="currRow" value="#{ViewName}" IndexVar="rowNum">
<xc:dynamicRowBinding dataSource="#{currentDocument}">
<xc:this.binding1>
<![CDATA[#{javascript: currRow.getColumnValue("binding1");}]]>
</xc:this.binding1>
</xc:dynamicRowBinding>
</xp:repeat>
What this is assuming is that the document you're binding things to on the XPage is declared as currentDocument, and that there is a column in your underlying view that is calculating the desired field binding for the current row based on the properties and values of that document.
In the custom control, the following exists:
By defining dataSource and binding1 as properties within the custom control, they will be available as compositeData.
Thus, to bind a field using these components, we simply put the following definition in our custom control:
<xp:inputText value="#{compositeData.dataSource[compositeData.binding1]}">
</xp:inputText>
I hope this helps!
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
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
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
I have an application that uses the Ext Lib value picker from a view and it works but it is very cludgy. The reason is that there are over a thousand choices and the user has to scroll through them all to get to where he/she wants to go. I want to use the HughesConnect.com picklist CC, which is very nice. However, I am having trouble with a particular issue that is probably very simple but I can't figure it out.
I want to be able to use the HughesConnect.com picklist CC to grab one value at a time and put it into a field. Then, when the user clicks on the button again, I just want them to have the ability to grab a value and append it to the same field. Every time I run it now, it is just overwriting the field. I can't use Multi Value in the CC because the view has multi values in the column from the same document. I have found that if this is the case, it doesn't work. No matter what I try. I am not very good with arrays in XPages, so I am likely doing something wrong and to be honest, I don't even have any sample code because everything I have tried hasn't worked.
I am starting to wonder whether it's even possible but it sounds so simple that it must be.
The Value Picker allows you to add a search with a view data source. Is there a reason for not using that? I can't remember if search support multi-select. It may not.
If you want to use Mark's view picker, how about getting a bit creative. Push the value into a Hidden Input field that has an onChange event. In the onChange event, append the value to a different multi-value field. If you bind the Dojo List Text Box to your multi-value field, it will make it easier for users to deselect entries. It's a bit creative, but should produce exactly the result you're looking for.
I have a list box where I am trying to get the datafrom the people view in names.nsf.
The first column of the people view is computed and shows Last Name , First Name.
The code below works fine for my list box values but it does not take into consideration the value in the Filter By Column Value. Basiclly the code below acts like the Filter By Column value property does not exist. I know the Filter by Column value property is working because I replaced a repeat control on the page with a computed field and the repeat control is displaying the value excepected but the list box is displaying values from the first document in the view.
Thoughts I had to fix this are:
Use getAllDocumentsByKey to just search the people view but when I do that I lose the column values and I would need to recompute the value, something that I would like to avoid if possible incase the column formula changes.
Use FTSearch but what I really need to do is search that first column only and I am not aware of search operator that searchs a column only. Is there such a thing?
Another thought would be to somehow use the values of a repeat control, as the values for my list box, but I am guessing that this is not possible. I sort of thinking something with a scope varibale but I have not worked that out yet.
A repeat control works. How can I get my code to loop through the doeuments the same way a repeat control does?
And as a side question, is there anyway to tie a pager to a datasource as oppsed to a repeat control.
BTW What I currently do is to build a list box using a few computed fields and a repeat control but what I really want to do is to use a regular xpages list box control.
Here is the code:
var doc:NotesDocument = view1.getFirstDocument();
while (doc != null && count<10)
{
var tmpDoc:NotesDocument = view1.getNextDocument(doc)
ret.push(doc.getColumnValues()[1]);
doc.recycle();
count++;
doc = tmpDoc;
}
Try to use getAllEntriesByKey. This will give You access to column values (through ColumnValue property of view entry).
I have a need to have an alphabetical pager for a view. I didn't see any of the samples or the custom pager that addresses this. I would think that this would be a pretty common thing.
MJ
I'm not quite sure what you really mean by an "alphabetical pager", but I assume you might be looking for some kind of alphabetical navigator like we have it in the personal NAB inside the Notes client, right?
If so you're not really looking for a pager but for an alphabetical view filter. Here's one way to get there:
create a panel, give it a distinctive ID like "viewContainer" or
something. Put your view panel into the panel; of course the view's main sorting order must be alphabetical
create a 2nd panel above "viewContainer", no ID necessary here
put a repeat inside this new panel and bind it to a new JavaScript array, like that:
new Array("a", "b", "c", ... , "x", "y", "z");
enter a collection name for the repeat, like "letter"
put a link control inside the repeat. The link's label will be
computed to the repeat's collection name, i.e. "letter".
assign an onclick event to the link setting a sessionScope variable to the current collection name's value, like that:
sessionScope.filter = letter;
set the event's refresh mode to partial so that it refreshes your viewContainer panel
highlight your view control inside the viewContainer. In its data properties look for the property field labelled "Filter by column value" and make it computed. Enter this code:
sessionScope.filter;
That's it.
Edit:
of course you can build the repeat's datasource array dynamically from the view itself. So, instead of building that static a-to-z array you could also use something like this:
#Unique(#Left(#DbColumn(#DbName(), "yourLookupView", viewColNumber), 1));
That should return an array only containing those letters that really are in your view.
Also you could another static link control outside the repeat resetting the filter to show all entries. It would be built like the repeated link with the onclick event calling this code:
sessionScope.filter=null;
Enjoy!
I would go for this: make a view categorized by formula #Left( value; 1). Then render result of #DbColumn as pager by repeat or some ExtLib component (links list, navigator, menu). Each link will either limit shown view to "single category" or jumps to "starts with" character.