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



Oct 25, 2011, 8:02 PM
19 Posts

Trying to hide a panel if a return value does not exist

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: Xpage,Panel,Hide When
  • Replies: 5
I have an XPage Custom Control with multiple panels and repeats.  Everything is working with one exception.  I want to hide / show a panel only when there is information to display. 
As you can see below, the Locator Info label.  It is in a Panel along with the computedField4.  Computed Field4 gets populated from data in a previous repeat.  I do a lookup with a value from the previous repeat and pull data from another database. 
 
I want to hide the Locator Info panel if no values were found that would populate computedField4.  I put a formula in the Visible section of the Panel that looks for a scoped variable  which I set when I do the lookup for computedField4.  If I find data I set the scorped variable to 1 if not I set it to 0.  It is not showing the hidden panel when it executes.  Below the screen shot is the pertinent code for the panel.
 
Any thoughts would be appreciated!
 
 <xp:panel>
                            <xp:this.data>
                                <xp:dominoDocument var="docLocator"
                                    databaseName="dbWorkflow\locator.nsf" formName="frmLocatorUpdate"
                                    action="openDocument" />
                            </xp:this.data>

                            <xp:this.rendered><![CDATA[#{javascript:if( viewScope.get( "ShowLocatorInfo" ) )
     return 1;
else
    return 0;}]]></xp:this.rendered>
                            <xp:label value="Locator Info" id="label2"
                                style="font-weight:bold;color:rgb(0,0,255)" />

                            <xp:repeat id="repeatLocator" rows="5" var="locatorRowData">
                                <xp:this.value><![CDATA[#{javascript:var path = database.getFilePath().split(database.getFileName())[0]
var dbInfo = new Array(@DbName()[0],path + "locator.nsf");
var aName = repeatCurrentICE.getColumnValue( "EmpNotesID" );

//  do not display locator information unless found below
viewScope.put( "ShowLocatorInfo", 0 );
// REM {  Fetch the locator document for this person.};
var locatorInfo = @DbLookup( dbInfo, "vwLocatorLookupSFOBO", aName, 5, "[FAILSILENT]" );
if( locatorInfo && typeof locatorInfo != "string" )
{
    for( var index = 0; index < locatorInfo.length; index++ )
    {
        locatorInfo[index] = locatorInfo[index].replace( "@@", "\n" );
        viewScope.put( "ShowLocatorInfo", 1 );
    }
}
else
{
    if( locatorInfo != "" )
    {
        var tempStr = locatorInfo;
        locatorInfo = new Array();
        locatorInfo[0] = tempStr.replace( "@@", "\n" );
        viewScope.put( "ShowLocatorInfo", 1 );
    }
}
return locatorInfo;
}]]></xp:this.value>
                                <dl>
                                    <xp:text escape="true" id="computedField4">
                                        <xp:this.value><![CDATA[#{javascript:locatorRowData;}]]></xp:this.value>
                                    </xp:text>
                                </dl>
                            </xp:repeat>
                        </xp:panel>
                        <xp:br />
                    </xp:panel>
 
 
Oct 26, 2011, 7:08 AM
17 Posts
Re: Trying to hide a panel if a return value does not exist
It looks like you test if the viewScope variable exists. Check the value of the variable with something like
 
<xp:this.rendered><![CDATA[#{javascript:if (viewScope.xx==null) {
    return false;}
else {
if (viewScope.xx == "1") {
    return true;
}
}}]]></xp:this.rendered>
Oct 26, 2011, 8:46 AM
272 Posts
Re: Trying to hide a panel if a return value does not exist
Hi,
 
in your posted code the viewScope will never get filled and always be empty. The code won't be executed, because the rendered property is always false.
 
Sven
Oct 28, 2011, 2:09 AM
19 Posts
Re: Trying to hide a panel if a return value does not exist
Sven,
I thought that might be the case, so how do I get the code to execute but only display the text if a value was found?
Oct 29, 2011, 10:44 PM
272 Posts
Re: Trying to hide a panel if a return value does not exist
Hi,
 
you could try to change the rendered property of the components to this:
 
<xp:this.rendered><![CDATA[#{javascript:var ok:boolean = true;
try{
    var sRepeat:com.ibm.xsp.component.xp.XspDataIterator = getComponent("locatorRowData");
    if( sRepeat.getValue() == null )
        ok = false;
    if( sRepeat.getRowCount() == 0 )
        ok = false;
}catch(e){}
       
return ok;}]]></xp:this.rendered>
 
Hope this helps
Sven

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