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



May 1, 2012, 1:32 PM
298 Posts

Using setRendered() in a repeat

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: Button,Repeat Control
  • Replies: 7
I have a button in a repeat that executes code and then should hide itself and show another button. if I use getComponent('button1").setRendered(true) it acts on all the buttons. Is there a way to get a handle on just the button that was in the repeat?

Howard
May 1, 2012, 3:01 PM
126 Posts
Re: Using setRendered() in a repeat
Take a look at the mobileThread custom control in teamroom. it does excatly this with an expand / collapse image and panel for every reply to a document.
 
It uses a javascript file to keep a map of all the controls and uses the index of the repeat to determine which one was clicked 
May 1, 2012, 5:43 PM
298 Posts
I did something similiar but ...
Simon, thanks, I did implement something similar as a work-around. I used a Java vector to store the state for each row to determine which button to show. But, I was wondering. If the button (or any component) in a repeat gets assigned a unique id for each repeated row, I was hoping that getComponent("id") would figure out to get the right recomputed id for that repeated row and not get all the buttons that got repeated? Or, is there another way to get this? For example, in CSJS, the getClientID() will always figure out the correct id and we can use that to get access to that element via CSJS. Is there anyway to use "this" in the onclick event to get to the button component itself? Howard
May 1, 2012, 8:03 PM
17 Posts
Re: Using setRendered() in a repeat
 You can use thisEvent.target to get handle to the button which was clicked, in CSJS. 
 Below is the piece of code which may help you out. 
 
<xp:link escape="true" id="linkShowHide" title="Show Details" text="Show" >
    <xp:eventHandler event="onclick" submit="false">
<xp:this.script>
          <![CDATA[var  nodeDailyRecs  = dojo.byId("#{id:dailyRecspanel}");nodeDailyRecs.style.display= (nodeDailyRecs.style.display == 'none')? "block" : "none"; _this = thisEvent.target;
if(nodeDailyRecs.style.display == 'none'){
_this.setAttribute('title',"Show Daily Hours");
_this.innerHTML = "Show"
}else {
_this.setAttribute('title',"Hide Daily Hours");
_this.innerHTML = "Hide"
}
]]></xp:this.script>
</xp:eventHandler>
</xp:link> 
May 2, 2012, 7:25 AM
126 Posts
Re: Using setRendered() in a repeat
Yes if CSJS will work for you, you can use the the client side onclick and the through CSJS modify the css attribute "display".
 
eg. domElement.style.display = "none"    /   domElement.style.display = "inline";
May 2, 2012, 1:24 PM
298 Posts
Prefer a SSJS solution
I do have to access Notes Documents, etc. so SSJS is needed in the button. Howard
May 2, 2012, 3:06 PM
126 Posts
Re: Using setRendered() in a repeat
Well then the only option i'm aware of is what I did in the mobileThread custom control.
 
I've seen many posts online where other developers have done the same and haven't seen any other solution. There could be a way to cross the CS id with the server side actions such as the executeOnServer method but its going to be a lot more hassle than having a map or vector of the controls
May 2, 2012, 5:57 PM
298 Posts
thanks, seems like an area that needs improvement
I would have thought I could do something like this.parent to get to the actual button code component object... I appreciate your time! Howard

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