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



Jun 11, 2013, 2:22 PM
17 Posts

setRendered: set to true on an component I just set to false?

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 9.0
  • Role: Developer
  • Tags:
  • Replies: 7

I have one button that hides a row of a table using a partial refresh and SSJS

getComponent("R3").setRendered(false)

 

I have another button that attempts to show the same row that was just hidden

getComponent("IR3").setRendered(true)

In the browser, I get an error that no element with that ID exists.

 

How do I do this?

Jun 11, 2013, 2:31 PM
54 Posts
rendered

with the first piece of code you hide the component "R3". It´s now not available and that´s why the second code run into an error.

put a div around "R3" e.g. "Div1" and refresh it.

Jun 11, 2013, 3:00 PM
17 Posts
I get the same results, can't find ID

thanks, but I tried putting DIV tags with an ID around various components on the page, and it get the same result. It will hide the DIV using setRendered and a partial refresh, but when I try to bring it back, the Browser says it cannot find an element with that ID.

 

Jun 11, 2013, 3:02 PM
54 Posts
hide

You don´t should hide the Div.

Hide "R3" e.g. and refresh the Div.

Jun 11, 2013, 4:45 PM
17 Posts
Doesn't work on table elements

Ok. Now I understand that. It works fine on other elements on the page (a field, panel, img, etc), but it does not seem to work when trying to put DIV tags around a TR or TD.

Jun 11, 2013, 4:52 PM
54 Posts
table

If you want to hide fields or somthing else inside a <td> put the whole table into a div and refresh rhe div.

Example table:

 

<xp:button value="rendered false" id="button5">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="Div2">
            <xp:this.action><![CDATA[#{javascript:getComponent("inputText3").setRendered(false);
}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>
    <xp:button value="rendered true" id="button6">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="Div2">
            <xp:this.action><![CDATA[#{javascript:getComponent("inputText3").setRendered(true)}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>

 

<xp:div id="Div2">
        <xp:table>
            <xp:tr>
                <xp:td>
                    <xp:inputText id="inputText2"></xp:inputText>
                </xp:td>
                <xp:td>
                    <xp:inputText id="inputText3"></xp:inputText>
                </xp:td>
            </xp:tr>
        <xp:tr>
                <xp:td></xp:td>
                <xp:td>
                    <xp:inputText id="inputText4"></xp:inputText>
                </xp:td>
            </xp:tr>
        </xp:table>
    </xp:div>

Jun 11, 2013, 5:04 PM
17 Posts
Thanks

Ok!!!! Thanks for working this out with me. HUGE HELP!

Jun 12, 2013, 11:27 PM
453 Posts
One thing that I have found about the render property

Don't use rendered = false if you need access to the values because rendered = false does not just hide the contents, they are not rendered at all. I use a computed Style property and set display:none. So I only use the rendered property when I truly  do not want the content hidden and not available. Maybe I'm a slow learner but this took me a lot of hours to figure out. Another work around is to set rendered = false and loaded = true . In this case the values are accessible but not visible. The problem I found with this is that if the control has a default value it does not appear to be computed. I personally like the display:none better because the rule can be contained in a single property, then use rendered when simply do not want the control to be part of the XPage at all.


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