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 12, 2012, 2:42 AM
24 Posts
topic has been resolvedResolved

Selecting Values For a Combo Box from a View

  • Category: Debugging
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 9
Hi,
 
I'm trying to select Values, for a Combo Box, from a View column. And the code actually works with out the @For Collumn.
 
The code i use is this:
 
 var Name = @DbColumn("","Aprover",2);
var BUnit = @DbColumn("","Aprover",4);
var Loc = compositeData.Location;
var NameLength = @Elements(@DbColumn("","Aprover",2));
var i = 1;
var x = null;
var ElementBUnit = null;
var ElementName = null;
var result = null;

@For(i = 1, i<NameLength, i=i+1,
    @Do(
        ElementBUnit = "["+@Element(BUnit,i)+"]",
        ElementName = @Element(Name,i),
        @If(ElementBUnit==Loc,x = ElementName,null)
    ),
    result = result + x
);

return result;
 
does somebody know why this is not working?
Thx
Oct 12, 2012, 12:19 PM
135 Posts
Re: Selecting Values For a Combo Box from a View
I would suggest using standard JavaSrcipt for and get rid of the @Do. The @-versions of those are confusing, at least to me.
 
- Panu 
Oct 15, 2012, 12:25 AM
24 Posts
Re: Selecting Values For a Combo Box from a View
Even If i do it that way I still get:

Error 500

HTTP Web Server: Command Not Handled Exception 
 
 
Oct 15, 2012, 8:59 PM
135 Posts
Re: Selecting Values For a Combo Box from a View
Can you post the XPage source or at least this part of it?
Oct 15, 2012, 11:15 PM
24 Posts
Re: Selecting Values For a Combo Box from a View
This?
 
*edit* deleted the wrong code
 
Oct 16, 2012, 3:05 PM
135 Posts
Re: Selecting Values For a Combo Box from a View
No, the XML available in "Source" tab in Designer.
Oct 16, 2012, 10:27 PM
24 Posts
Re: Selecting Values For a Combo Box from a View
okay here you go:
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.data>

        <xp:dominoView var="Aprover" viewName="Aprover"></xp:dominoView>
        <xp:dominoDocument var="AppProjects"
            formName="ApprovedProjects">
        </xp:dominoDocument>
        <xp:dominoDocument var="ApproverForm" formName="ApproverForm"></xp:dominoDocument>
    </xp:this.data>


    <xp:table>
        <xp:tr>
            <xp:td>
                <xp:label id="label1" value="First Approval:"></xp:label>
            </xp:td>
            <xp:td>
                <xp:comboBox id="comboBox1">
                    <xp:this.attrs></xp:this.attrs>
                    <xp:selectItems id="selectItems1">
                        <xp:this.value><![CDATA[#{javascript:var Name = @DbColumn("","Aprover",2);
var BUnit = @DbColumn("","Aprover",4);
var Instance = @DbColumn("","Aprover",5);
var Loc = compositeData.Location;
var NameLength = @Elements(@DbColumn("","Aprover",2));
var i = 1;
var x = null;
var ElementBUnit = null;
var ElementName = null;
var ElementInstance = null;
var result = "";

@For(i = 1, i<NameLength, i=i+1,
   
        ElementBUnit = "["+@Element(BUnit,i)+"]",
        ElementName = @Element(Name,i),
        ElementInstance = @Element(Instance,i),
        @If(ElementBUnit==Loc,
            @If(ElementInstance=="1st",
            x=ElementName
            ,null)
        ,null),
    result = result + x
);


}]]></xp:this.value>
                    </xp:selectItems>






                </xp:comboBox>
            </xp:td>
            <xp:td>

               
            </xp:td>
            <xp:td>

            </xp:td>
        </xp:tr>
        <xp:tr>
            <xp:td>
                <xp:label value="Second Approval:" id="label2"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="inputText1" value="#{AppProjects}">
                   
                </xp:inputText>
            </xp:td>
            <xp:td>
                </xp:td>
            <xp:td></xp:td>
        </xp:tr>
        <xp:tr>
            <xp:td>
                <xp:label value="Third Approval:" id="label3"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="inputText2" value="#{AppProjects}">
                   
                </xp:inputText>
            </xp:td>
            <xp:td></xp:td>
            <xp:td>
                <xp:button value="Approve!" id="button1">

                   
                </xp:button>
            </xp:td>
        </xp:tr>
        <xp:tr>
            <xp:td>
                <xp:label id="label4" value="Fourth Approval:"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="inputText3"></xp:inputText>
            </xp:td>
            <xp:td></xp:td>
            <xp:td>
                <xp:button value="Notivie People" id="button3">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="complete">
                        <xp:this.action>
                            <xp:executeScript
                                script="#{javascript:import ApproveMail;}">
                            </xp:executeScript>
                        </xp:this.action>
                    </xp:eventHandler>
                </xp:button>
            </xp:td>
        </xp:tr>
    </xp:table>

</xp:view>
 
Oct 17, 2012, 8:27 AM
135 Posts
Re: Selecting Values For a Combo Box from a View
Looks like you are still using @For and @If.
Oct 17, 2012, 5:39 PM
586 Posts
Re: Selecting Values For a Combo Box from a View
 Nick - I recently did a presentation on this acutally - where I populated the values of a combo box from a view column.  I used the code below.
 
Here's the SSJS for the Values.
 
i think this will be coming up on a notesIn9 pretty soon. 
 
 

var db:NotesDatabase = session.getDatabase(database.getServer(), "fakenames.nsf")

var myView:NotesView = db.getView("byStatebyCity");

var nav:NotesViewNavigator = myView.createViewNavFromCategory(viewScope.get("vsState"));

var entry:NotesViewEntry = nav.getFirst();

var myList = new java.util.ArrayList()


var tmpEntry:NotesViewEntry

return


while (null != entry) {

tmpEntry = entry;

myList.add(entry.getColumnValues()[2])

entry.recycle()

entry = tmpEntry;

}


return myList

Oct 18, 2012, 1:57 AM
24 Posts
Re: Selecting Values For a Combo Box from a View
thanks guys it works now.
 I am using this now:
 
 <?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.data>

        <xp:dominoView var="Aprover" viewName="Aprover"></xp:dominoView>
        <xp:dominoDocument var="AppProjects"
            formName="ApprovedProjects">
        </xp:dominoDocument>
        <xp:dominoDocument var="ApproverForm" formName="ApproverForm"></xp:dominoDocument>
    </xp:this.data>


    <xp:table>
        <xp:tr>
            <xp:td>
                <xp:label id="label1" value="First Approval:"></xp:label>
            </xp:td>
            <xp:td>
                <xp:comboBox id="comboBox1">
                    <xp:this.attrs></xp:this.attrs>
                    <xp:this.defaultValue><![CDATA[#{javascript:    var Name = @DbColumn("","Aprover",2);
    var BUnit = @DbColumn("","Aprover",4);
    var Instance = @DbColumn("","Aprover",5);
    var Loc = compositeData.Location;
    var NameLength = @Elements(@DbColumn("","Aprover",2));
    var i = 1;
    var ElementBUnit = null;
    var ElementName = null;
    var ElementInstance = null;
    var result = "";
    
    for (i = 1; i<NameLength; i=i+1)
    {
        ElementBUnit = "["+@Element(BUnit,i)+"]";
        ElementName = @Element(Name,i);
        ElementInstance = @Element(Instance,i);
        if(ElementBUnit==Loc)
        {
            if(ElementInstance=="1st")
            {
                result=ElementName;
            }
        }
    }

    return result;}]]></xp:this.defaultValue><xp:selectItems id="selectItems1">
                        <xp:this.value><![CDATA[#{javascript:@DbColumn("","Aprover",2);



}]]></xp:this.value>
                    </xp:selectItems>






                </xp:comboBox>
            </xp:td>
            <xp:td>

               
            </xp:td>
            <xp:td>

            <xp:inputText id="inputText4"><xp:this.defaultValue><![CDATA[#{javascript:@Elements(@DbColumn("","Aprover",2));}]]></xp:this.defaultValue></xp:inputText></xp:td>
        </xp:tr>
        <xp:tr>
            <xp:td>
                <xp:label value="Second Approval:" id="label2"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="inputText1" value="#{AppProjects}">
                   
                </xp:inputText>
            </xp:td>
            <xp:td>
                </xp:td>
            <xp:td></xp:td>
        </xp:tr>
        <xp:tr>
            <xp:td>
                <xp:label value="Third Approval:" id="label3"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="inputText2" value="#{AppProjects}">
                   
                </xp:inputText>
            </xp:td>
            <xp:td></xp:td>
            <xp:td>
                <xp:button value="Approve!" id="button1">

                   
                </xp:button>
            </xp:td>
        </xp:tr>
        <xp:tr>
            <xp:td>
                <xp:label id="label4" value="Fourth Approval:"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="inputText3"></xp:inputText>
            </xp:td>
            <xp:td></xp:td>
            <xp:td>
                <xp:button value="Notivie People" id="button3">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="complete">
                        <xp:this.action>
                            <xp:executeScript
                                script="#{javascript:import ApproveMail;}">
                            </xp:executeScript>
                        </xp:this.action>
                    </xp:eventHandler>
                </xp:button>
            </xp:td>
        </xp:tr>
    </xp:table>

</xp:view>


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