Is it possible to have data binding in the view? - xpages

From this post, thank you Simon Delicata's answer and comment. I can save get selected documents from a view and save as separate documents.
I have a question about this approach. If I edit the document, I click the link which will redirect me to the edit page, the edit page is similar to previous post's design: a combo box on the top, a view with check box (this view is used for selection), a button for save the selection values from the view and the combo box. Also there will another view which will display the saved values.
Here code and it can save as separate documents but it cannot show the saved value and put a "tick" symbol in the checkbox.
<xp:table id="table1a">
<xp:tr>
<xp:td id="table1">
<xp:comboBox id="comboBox1"
dojoType="dijit.form.ComboBox" style="width:250.0px"
value="#{document1.Category}">
<xp:selectItems id="selectItems3">
<xp:this.value><![CDATA[#{javascript:var SetFirstValueBlank = #Text("");
return SetFirstValueBlank;
}]]></xp:this.value>
</xp:selectItems>
<xp:selectItems id="selectItems4">
<xp:this.value><![CDATA[#{javascript:#Unique(#DbColumn(#DbName(), "CategoryListView", 1));}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="table1a">
</xp:eventHandler>
</xp:comboBox>
<xp:text escape="true" id="computedField1">
</xp:text>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:viewPanel rows="10" id="viewPanel1" var="rowData">
<xp:this.data>
<xp:dominoView var="view1"
viewName="hListView">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="ItemName"
id="viewColumn1" style="background-color:rgb(255,255,255)"
showCheckbox="true">
<xp:viewColumnHeader value="Item Name"
id="viewColumnHeader1" rendered="false">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:this.facets>
<xp:pager partialRefresh="true"
layout="Previous Group Next" xp:key="footerPager" id="pager2">
</xp:pager>
</xp:this.facets>
</xp:viewPanel>
<xp:br></xp:br>
<xp:button value="Add" id="button1"
style="height:35.0px">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:var Category = getComponent("comboBox1").getValue();
var viewPanel=getComponent("viewPanel1");
var docIDArray=viewPanel.getSelectedIds();
var unidArray = new Array();
for(i=0; i < docIDArray.length; i++) {
var unid=database.getDocumentByID(docIDArray[i]).getUniversalID();
unidArray.push(unid);
}
viewScope.put("unidArray", #Implode(unidArray, ","));
for(var i=0; i< unidArray.length;i++ )
{
var mdoc = database.createDocument();
mdoc.appendItemValue("Form", "ItemForm");
mdoc.appendItemValue("ItemName",unidArray[i]);
if(mdoc.computeWithForm(false,false))
{
mdoc.save(true, true);
getComponent("computedField9").setValue("Record saved");
}
else
{
}
}
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:viewPanel rows="6" id="viewPanel2">
<xp:this.data>
<xp:dominoView var="view2" viewName="CategoryItemView">
<xp:this.categoryFilter><![CDATA[#{javascript:getComponent("comboBox1").getValue();}]]></xp:this.categoryFilter>
</xp:dominoView>
</xp:this.data>
<xp:this.rendered><![CDATA[#{javascript:var value = getComponent("comboBox1").getValue();
if(value =="" || value == null)
{
return false;
}
else
{
return true;
}}]]></xp:this.rendered><xp:viewColumn id="viewColumn4" columnName="Category" rendered="false">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header" id="viewColumnHeader4" value="Category">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn id="viewColumn3" columnName="$10">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header" id="viewColumnHeader3" value="Category">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn columnName="ItemName" id="viewColumn2">
<xp:viewColumnHeader value="Item" id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="footerPager" id="pager3">
</xp:pager>
</xp:this.facets></xp:viewPanel><xp:br></xp:br></xp:td>
</xp:tr>
</xp:table>
So far as I know, suppose there a edit box or a combo box, if I use data binding to bind to a field and save it, the a edit box or a combo box can show the saved value when edit.
So I would like to know can the "similar approach" applies to the view? I search on the Internet and not much information about it.
I click the view and click Data in Properties tab, I notice the view does has data binding to bind to a form field.
Therefore is it possible to have data binding in the view so the view can show the saved value when edit. Thank you.

You're not binding to a document, you're binding to properties in a dominoDocument object. The dominoDocument object is a Java wrapper for the underlying document in the database that, because the document is read-write also exposes all fields as read-write, allowing editable components to be bound to them. If an edit box was bound to a read only property, I suspect it would not show as editable.
The dominoView object is a Java wrapper for the underlying view, and returns a collection of NotesXspViewEntry objects i.e. each row in the view. Those aren't read-write (Notes Client editable columns don't edit the view entry, they give an editable area that writes to the underlying document via backend code). You need to think about binding to "documents corresponding to view entries in the view".
View Panel columns can contain components instead of just mapping to column values. A View Panel is a repeat control with restricted layout and settings, so it's the same approach. Set the var property on the ViewPanel - this is a variable to get a handle on the current NotesXspViewEntry. You can't drag and drop into a column, if I remember correctly, you need to paste the code for the component into the relevant place.
If you want it editable, you'll need a dominoDocument datasource. Alternatively, reproduce the approach of Notes Client editable view column approach, bind to a temporary variable (e.g. requestScope property) and update the backend document on completion of the process. Another approach is to launch a dialog, passing the current row's UNID, and edit. Yet another approach is to use the In Place Form from XPages Extension Library.
Here's a presentation and demo from IBM Connect 2013 where I do something similar to make a column editable http://www.intec.co.uk/session-slides-and-sample-database-from-ibm-connect/.
More modern view components like the Data View make it easier.

Related

Data handling with nested repeat controls

In my Application I, as a user, can create "items" through an XPage.
Those items have an undefined amount of entries in a list (a simple text list) which I create myself. Those entries will be used to generate checkBoxes later.
I have a list of customers. I can add multiple items to each customer. The items are displayed inside a repeat control. Each row has an inner repeat control for the checkBoxes (generated from the text list).
Now my problem is, that I'm not sure how to handle the data or more precisely the checking/unchecking of the checkBoxes because I have an undefined number of items and an undefined number of the checkBoxes inside the items plus the checkBoxes are editable.
I hope my issue is clear. Please let me know if there is need for clarification or if you need some code - even though I think the problem lies purely with the logic in my head.
EDIT:
The custom control that is used in the customer XPage the checkBoxes I mentioned above are used for `status.
As you will see below I simply get the search keys for the items and use them to find the text lists to create the checkboxes.
Since the items are merely templates that are used for every user that logs in, I can't use those documents to save the state of the checkboxes.
The only thing I can think of at this moment is to actually create a document for every item that is being added to the customer and use this document as the storage - but isn't there a better way?
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet href="/item.css"></xp:styleSheet>
</xp:this.resources>
<xp:repeat id="repeat1" rows="30" var="rowData" indexVar="rowIndex" style="border: 1px solid #ccc;">
<xp:this.value>
<![CDATA[#{javascript:return currentForm.getItemValue("itemSearchkey");}]]>
</xp:this.value>
<xp:div>
<xp:button styleClass="accordion" id="button1">
<xp:this.value>
<![CDATA[#{javascript:
var itemTitle = "";
if(!"".equals(rowData) || rowData != null) {
itemTitle = itemBean.getItemTitle(rowData);
}
return itemTitle;
}]]>
</xp:this.value>
<xp:eventHandler event="onclick" submit="false">
<xp:this.script>
<![CDATA[
// ... some code for the accordion to work
]]>
</xp:this.script>
</xp:eventHandler>
</xp:button>
<xp:div styleClass="panel">
<xp:repeat id="repeat2" rows="30" var="rowDataStatus" indexVar="rowIndexStatus">
<xp:this.value>
<![CDATA[#{javascript:
var statusVector = null;
if(!"".equals(rowData) || rowData != null) {
statusVector = itemBean.getStatusList(rowData);
}
return statusVector;
}]]>
</xp:this.value>
<xp:checkBox id="checkBox1" checkedValue="true" uncheckedValue="false">
<xp:this.text><![CDATA[#{javascript:return rowDataStatus;}]]></xp:this.text>
</xp:checkBox>
</xp:repeat>
</xp:div>
</xp:div>
</xp:repeat>
</xp:view>
To create the list that is used for the checkBoxes I use a simple inputTextArea in a separate custom control. currentForm is the datasource:
...
<xp:inputTextarea id="statusList" value="#{currentForm.StatusList}"
multipleSeparator="#{javascript:#NewLine()}" rows="8">
</xp:inputTextarea>
...

Get selected documents from a view and save as separate document

I am trying to get selected documents from a view and save as separate documents
Here is the design of the xpage
A combo box on the top, a view with check box (this view is used for selection), a button for save the selection values from the view and the combo box. Also there will another view which will display the saved values.
From this post, I can get the unid of selected documents and save to view scope variable. The add button can save the selected value from the combo box and the view and show the result in another view.
However, if I choose more than one value in the view and click save, it saves all values in one document. So I try to use for loop to loop through the selected values in view and save, it still saves one value only in one document.
<xp:table id="table1a">
<xp:tr>
<xp:td id="table1">
<xp:comboBox id="comboBox1"
dojoType="dijit.form.ComboBox" style="width:250.0px"
value="#{document1.Category}">
<xp:selectItems id="selectItems3">
<xp:this.value><![CDATA[#{javascript:var SetFirstValueBlank = #Text("");
return SetFirstValueBlank;
}]]></xp:this.value>
</xp:selectItems>
<xp:selectItems id="selectItems4">
<xp:this.value><![CDATA[#{javascript:#Unique(#DbColumn(#DbName(), "CategoryListView", 1));}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="table1a">
</xp:eventHandler>
</xp:comboBox>
<xp:text escape="true" id="computedField1">
</xp:text>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:viewPanel rows="10" id="viewPanel1" var="rowData">
<xp:this.data>
<xp:dominoView var="view1"
viewName="hListView">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="ItemName"
id="viewColumn1" style="background-color:rgb(255,255,255)"
showCheckbox="true">
<xp:viewColumnHeader value="Item Name"
id="viewColumnHeader1" rendered="false">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:this.facets>
<xp:pager partialRefresh="true"
layout="Previous Group Next" xp:key="footerPager" id="pager2">
</xp:pager>
</xp:this.facets>
</xp:viewPanel>
<xp:br></xp:br>
<xp:button value="Add" id="button1"
style="height:35.0px">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:var Category = getComponent("comboBox1").getValue();
var viewPanel=getComponent("viewPanel1");
var docIDArray=viewPanel.getSelectedIds();
var unidArray = new Array();
for(i=0; i < docIDArray.length; i++) {
var unid=database.getDocumentByID(docIDArray[i]).getUniversalID();
unidArray.push(unid);
}
viewScope.put("unidArray", #Implode(unidArray, ","));
for(var i=0; i< unidArray.length;i++ )
{
document1.replaceItemValue("ItemName", unidArray[i]);
document1.save();
}
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:viewPanel rows="6" id="viewPanel2">
<xp:this.data>
<xp:dominoView var="view2" viewName="CategoryItemView">
<xp:this.categoryFilter><![CDATA[#{javascript:getComponent("comboBox1").getValue();}]]></xp:this.categoryFilter>
</xp:dominoView>
</xp:this.data>
<xp:this.rendered><![CDATA[#{javascript:var value = getComponent("comboBox1").getValue();
if(value =="" || value == null)
{
return false;
}
else
{
return true;
}}]]></xp:this.rendered><xp:viewColumn id="viewColumn4" columnName="Category" rendered="false">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header" id="viewColumnHeader4" value="Category">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn id="viewColumn3" columnName="$10">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header" id="viewColumnHeader3" value="Category">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn columnName="ItemName" id="viewColumn2">
<xp:viewColumnHeader value="Item" id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="footerPager" id="pager3">
</xp:pager>
</xp:this.facets></xp:viewPanel><xp:br></xp:br></xp:td>
</xp:tr>
</xp:table>
Would someone let me know how to save multiple values in separate documents please? Thank you.
(edit: some of previous content are removed)
I think I will focus on how to save multiple value as separate documents first because this part is quite important in the program, once I can save as separate documents, there will another function that needs the result to process.
I review the code, I think I will still use for loop but unfortunately, it still saves one document only.
I'm guessing the document1 object is bound to a on the XPage, which is only created when the XPage is opened. To cause your button to create multiple documents, the for loop needs to modified :
var oneOfMany : NotesXspDocument;
for(var i=0; i< unidArray.length;i++ )
{
oneOfMany = database.createDocument();
oneOfMany.replaceItemValue( "Category", document1.getItemValue("Category" ) );
oneOfMany.replaceItemValue("ItemName", unidArray[i]);
oneOfMany.replaceItemValue("form", "MyFormName" );
oneOfMany.save();
}
Because it no longer uses document1, this loop will need to populate the other items you need such as the form, for example MyFormName as in the example.

xPage with multiple datasources has the second datasource always opened in edit mode

I have an xPage with 2 datasources. I open the page and the first datasource is readonly, while the second datasource is in edit mode. Adding ignoreRequestParms=true seems to cause this behavior, but its the only way that the document will save to a different datasource.
I have found this link that someone has found similar behavior.
http://www-10.lotus.com/ldd/nd85forum.nsf/7756aedc25e6d81285256324005ac76c/5e2f855ea18ff802852576e3007c34f2?OpenDocument
There is something going on that I don't understand. If someone could explain this to me I would appreciate it.
Here is the code for the data source and the fields in the tab panel
<xp:dominoDocument var="document2" action="createDocument"
formName="software" ignoreRequestParams="true">
</xp:dominoDocument>
<xp:tabbedPanel id="tabbedPanel1">
<xp:tabPanel id="tabPanel1" label="Checklist Items">
<xp:checkBoxGroup id="checkBoxGroup1" layout="pageDirection"
value="#{document1.checklist}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var dbName = new Array("","");
var Rep = #Unique(#DbColumn(dbName,"checklistitems",3));
Rep}]]></xp:this.value>
</xp:selectItems>
</xp:checkBoxGroup>
</xp:tabPanel>
<xp:tabPanel label="Software" id="tabPanel2">
<xp:button value="Edit Software list" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="panelsoft">
<xp:this.action>
<xp:changeDocumentMode mode="edit"
var="document2">
</xp:changeDocumentMode>
</xp:this.action></xp:eventHandler></xp:button>
<xp:button value="Save Software list" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="panelsoft">
<xp:this.action>
<xp:actionGroup>
<xp:modifyField name="uid"
value="#{javascript:document1.getDocument().getUniversalID()}"
var="document2">
</xp:modifyField>
<xp:executeScript script="#{javascript:document2.save()}">
</xp:executeScript></xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:panel id="panelsoft"><xp:table rendered="#{javascript:document2.isEditable()}"><xp:tr><xp:td><xp:br></xp:br>
Software Name
</xp:td>
<xp:td>
<xp:inputText id="inputText1"
style="width:300px" value="#{document2.Softwarename}">
</xp:inputText></xp:td>
</xp:tr>
<xp:tr>
<xp:td></xp:td>
<xp:td></xp:td>
</xp:tr>
</xp:table>
<xp:viewPanel rows="30" id="viewPanel1">
<xp:this.facets>
<xp:pager partialRefresh="true"
layout="Previous Group Next" xp:key="headerPager" id="pager1">
</xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView var="view2" viewName="CustomSoftware"
categoryFilter="#{javascript:document1.getDocument().getUniversalID()}">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="uid" id="viewColumn1">
<xp:viewColumnHeader value="uid"
id="viewColumnHeader1">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Softwarename"
id="viewColumn2">
<xp:viewColumnHeader value="Software Name"
id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="comments" id="viewColumn3">
<xp:viewColumnHeader value="Comments"
id="viewColumnHeader3">
</xp:viewColumnHeader>
</xp:viewColumn>
</xp:viewPanel>
</xp:panel>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:panel>
</xp:panel>
<xp:br></xp:br>
</xp:tabPanel>
</xp:tabbedPanel>
Because action is set to createDocument (which you could omit, since that's the default value), this causes a new document to be created in memory. This is why the document is in edit mode: you're composing a new record. If you don't want to create a new document, then change the action attribute to one of the other options: openDocument or editDocument. Either of these require that the documentId attribute be set as well, because the data source needs to know which document you wish to, respectively, open or edit.
If you omit the ignoreRequestParams attribute, then this data source doesn't ignore the URL request parameters. Instead, it looks for parameters named databaseName, formName, documentId, and action. If any of these parameters are included in the URL, the value of each overrides what is defined on the data source. This is why if you open an instance of document1, but don't set ignoreRequestParams on document2, then both documents will have the same mode (read/edit): because neither data source is ignoring the URL, so both data sources are doing what the URL is telling them to.
Generally, when defining multiple data sources on the same XPage, you'll have one that can be considered the "primary" data source; any other data has some relationship to that data, but the primary data is the user's context for viewing all the data on that page. So you want that data source to respect URL parameters to allow navigation (from a Data View, View Panel, Repeat, etc.) to be able to indicate which document is being opened, and in what mode. But all data sources related to that document should explicitly specify what data they're bound to, and the action being taken on that data, and use ignoreRequestParams to ensure that the URL doesn't override this information.

Xpages Dynamic dojo dialog control

I have a list of products (created using a repeat control) and wish to click on a particular product and bring up a dialog with further information about that particular product. I don't really want to generate dijit.dialog thing for every single product on that page, so how can I do this dynamically possibly using AJAX and partial refresh.
A similar non xpages example can be seen here: http://www.replacementkeys.co.uk/window?dir=asc&limit=12&mode=grid&order=position - where you hover over an image and a quick view button comes up, which then dynamically loads the content for that product.
Any ideas would be truly appreciated.
We build the dialog outside the repeat control and then the action that launches or shows it also sets a viewScope variable that is used UNID for the data source in the dialog. Just make sure you refresh the contents of the dialog as you open it...
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.data>
<xp:dominoView var="promptView" viewName="dlgBoxes">
</xp:dominoView>
</xp:this.data>
<xp:panel>
<xp:repeat id="repeat1" rows="30" value="#{promptView}" var="promptEntry">
<xp:panel tagName="div">
<xp:text escape="true" id="computedField1" value="#{promptEntry.dlgName}">
</xp:text>
 
<xp:button value="details" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
var pe:NotesViewEntry = promptEntry;
viewScope.put("dlgDocUnid", pe.getUniversalID());
getComponent("dialog1").show();
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:panel>
</xp:repeat>
</xp:panel>
<xe:dialog id="dialog1" keepComponents="false" partialRefresh="true">
<xe:this.title><![CDATA[#{javascript:
var unid = viewScope.get("dlgDocUnid");
if(!unid) return "";
var doc:NotesDocument = database.getDocumentByUNID(unid);
return doc.getItemValueString("dlgName");}]]></xe:this.title>
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="dlgDoc" formName="dlgBox" action="openDocument">
<xp:this.documentId><![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:text escape="true" id="computedField2" value="#{dlgDoc.Title}">
</xp:text>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:text escape="true" id="computedField3" value="#{dlgDoc.dlg}">
</xp:text>
</xp:panel>
</xe:dialog>
</xp:view>
Happy coding
/Newbs
You can combine your repeat control with the Extension Library dialog control in order to be able to launch a dialog when the user clicks on the individual row. Chris Toohey has created an excellent article called Popup Dialog Forms from Views in XPages that demonstrates this.

How do I get the value of nth Edit box in a repeat control?

I have an EditBox control in a repeat control. Its iteration formula is:
return 5;
It is successfully displaying 4 edit boxes (the starting index is set to 1).
In SSJS, how can I get the value of the nth Edit Box?
You could set a sessionScope variable (or any scope variable) on the onchange event of the edit box and then in your SSJS reference the sessionScope variable. Here is some sample code, the bottom bit just shows your sessionScope variables on the page.
<?xml version="1.0" encoding="UTF-8"?>
<xp:repeat id="repeat1" rows="30" value="#{javascript:5}"
indexVar="rptIndex">
<xp:inputText id="inputText1">
<xp:eventHandler event="onchange" submit="true" refreshMode="complete">
<xp:this.action>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:sessionScope['text'+rptIndex] = getComponent("inputText1").getValue()}]]></xp:this.script>
</xp:executeScript>
</xp:this.action></xp:eventHandler></xp:inputText>
</xp:repeat>
<xp:table styleClass="debug">
<xp:tr>
<th>Variable Name</th>
<th>Variable Content</th>
</xp:tr>
<xp:repeat id="varRepeat" rows="30" value="#{javascript:sessionScope.keySet();}" var="scopeData">
<xp:tr>
<xp:td>
<xp:text escape="true" id="varName" value="#{javascript:scopeData}" />
</xp:td>
<xp:td>
<xp:text escape="true" id="varValue" value="#{javascript:sessionScope.get(scopeData)}" />
</xp:td>
</xp:tr>
</xp:repeat>
</xp:table>
</xp:view>
When you add a submission to an onChange event you create a rather chatty application - might bite you. The solution for setting the focus is rather different. First: focus is a client side operation, so you need a client script that 'knows what control is the first failure. The good news: XPages adds to all fields that failed a server side validation the attribute aria-invalid=true.
So you can use a dojo.onLoad script that queries that and sets the focus to the first member of the result. See also http://dontpanic82.blogspot.com/2011/07/xpages-styling-invalid-field.html
And for the query syntax:
http://dojotoolkit.org/reference-guide/1.7/dojo/query.html
Repeats are fun to deal with to say the least. If you look at examples in the teamroom template mobileThread custom control you'll see a repeat for displaying a list of replies, you'll also notice a lot of javascript to go along with it as for example running script on one button click would run on all buttons in the repeat.
If you are looking for the validation problem stwissel's solution looks the best. If this is something else and at some point you just need the value of any given edit box, maybe you should think about something like:
var domEl = dojo.byId(' <repeatControlId> ');
var textBoxes = domEl.getElementsByTagName("input");
var certainValue = textBoxes[3].value;
Now certainValue contains the value of a given edit box.
haven't tried this out, might need a little tweaking but the general idea should work I would think.
added another comment so i could add code.
Did a quick test and works fine for me, see my example below. Hope it helps. Try adding some print outs to see is it getting each bit.
<xp:repeat id="TestRepeat" rows="100" var="rowData"
indexVar="commentIndex" first="0" rendered="true">
<xp:this.value><![CDATA[#{javascript:
var dataArray = new Array();
dataArray.push(" Test");
dataArray.push(" Test");
dataArray.push(" Test");
dataArray.push(" Test");
dataArray.push(" Test");
return dataArray;
}]]></xp:this.value>
<xp:panel>
<xp:label value="Test"></xp:label>
<xp:inputText id="inputText1" value="Test" defaultValue="Test">
</xp:inputText>
<xp:br></xp:br>
</xp:panel>
</xp:repeat>
<xp:button value="Test" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[
var domEl = dojo.byId('#{id:TestRepeat}');
var textBoxes = domEl.getElementsByTagName("input");
alert( "Value 1: " + textBoxes[0].value);
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script>
</xp:eventHandler>
</xp:button>

Resources