After I wrote my first answer I headed home. On my way I thought this through and think I found a rather easy solution; since I fell that some of the ideas from the other answer could help understand my solution proposal I leave it intact and create this new one. Here's what you can try:
add a value to your repeater's indexVar property, e.g. rIndex (you'll find it under All Properties)
assuming that a button to become active it must be clicked by a user you add some SSJS code to its onclick event like this in order to store the current indexVar value in a requestScope variable:
requestScope.put("activeIndex", rIndex)
make sure that the onclick performs a partial refresh on a container that includes the repeat control
create code to compute your repeated button's style class; if the repeat's iteration index is the one stored in the requestScope you assign one style class, otherwise assign another one:
if(rIndex==requestScope.get("activeIndex")){
"btnStyleActive";
}else{
"btnStyleInactive";
}
Because the onclick partially refreshes the repeater and its contents the correctstyleClass is applied.
I don't have Domino Designer at home so I can't try it, but I feel this must work.
Update: Just built my own solution, very similar to Knut's snippet, and it's working nicely; no runtime errors. For completeness' sake I added an entry variable (var="rEntry") to the repeater but you may not need that.
I'll post my page's xml code so that you can copy and paste and try:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet href="/test.css"></xp:styleSheet>
</xp:this.resources>
<xp:panel id="pnMainContainer">
<xp:repeat
id="repeat1"
rows="30"
indexVar="rIndex"
var="rEntry">
<xp:this.value><![CDATA[#{javascript:[1, 2, 3, 4, 5]}]]></xp:this.value>
<xp:panel id="pnRptInner">
<xp:label id="label1">
<xp:this.value><![CDATA[#{javascript:"Entry content for this iteration = "+ rEntry.toString() + " "}]]></xp:this.value>
</xp:label>
<xp:button id="button1">
<xp:this.value><![CDATA[#{javascript:"Repeated Button @ index #" + rIndex.toString()}]]></xp:this.value>
<xp:this.styleClass><![CDATA[#{javascript:if(requestScope.get("activeIndex")==rIndex){
"btnStyleActive";
}else{
"btnStyleInactive";
}}]]></xp:this.styleClass>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial" refreshId="pnMainContainer">
<xp:this.action><![CDATA[#{javascript:requestScope.put("activeIndex", rIndex)}]]></xp:this.action>
</xp:eventHandler></xp:button>
</xp:panel>
</xp:repeat>
</xp:panel>
</xp:view>
To make it complete, here's the very simple css:
.btnStyleInactive{color:blue;}
.btnStyleActive{color:red;};
Make sure that:
- the button's onclick performs a partial update on the repeater itself
or a surrounding container
- the onclick code is SSJS