FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Dec 14, 2016, 2:51 PM
9 Posts
topic has been resolvedResolved

Basic Xpage help

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 4

Hello folks,

 

I'm fairly new to XPages and I'm trying to do what I think should be a simple task but I can't seem to achieve it.  Perhaps someone could help me.

 

All I want to do is have a field for the user to input a name and then click "Search", which would find a match in the names.nsf and display it int he combo box.  I'm not sure how to get the button "Find" to refresh the combo box values

 

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:table style="width:100.0%">
        <xp:tr>
            <xp:td>Name</xp:td>
            <xp:td>
                <xp:inputText id="Name" value="#{viewScope.first}" defaultValue="John"></xp:inputText>
                <xp:button value="Find" id="button1">
                    <xp:this.action>
                        <xp:actionGroup>
                            <xp:setValue
                                binding="#{viewScope.name}"
                                value="" />
                        </xp:actionGroup>
                    </xp:this.action>
                </xp:button>
            </xp:td>
        </xp:tr>

        <xp:tr>
            <xp:td>User Match</xp:td>
            <xp:td>
                <xp:comboBox id="Color" value="#{view2}">
                    <xp:selectItem itemLabel="Select One" id="selectItem1"></xp:selectItem>

                    <xp:selectItems>
                        <xp:this.value><![CDATA[#{javascript:var dbname =new Array("", "names.nsf");
var txtControlValue = getComponent("Name").getValue();
return @DbLookup(dbname,"$VIMPeople",txtControlValue, 1, "[PARTIALMATCH]")}]]></xp:this.value>
                    </xp:selectItems>
                </xp:comboBox>
            </xp:td>
        </xp:tr>
    </xp:table>
</xp:view>

 

Thank you in advance for your help :)

Rony

Dec 14, 2016, 4:48 PM
9 Posts
Please ignore. Got my solution

 

Dec 15, 2016, 5:07 PM
589 Posts
umm

Rather then saying please ignore..  it would be better if you posted your own solution.  Then it would have chance to help others in the future.

 

Just a suggestion.

 

Dec 16, 2016, 10:23 AM
300 Posts
*and don't cross post, you also put this in the 8.5 forum
Dec 22, 2016, 10:42 AM
9 Posts
Solution

You are correct, I should have posted a solution.

I created a search field for the user to enter a name to search.

    <xp:table rendered="#{javascript:document1.isNewNote()}"
        style="width:25.0%" styleClass="searchPanel">
        <xp:tr>
            <xp:td>
                <xp:label value="Name:" id="Name_Label1" for="Name"></xp:label>
            </xp:td>
            <xp:td>
                <xp:inputText id="Name" defaultValue=""></xp:inputText>
                <xp:button value="Search" id="button4">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="partial">
                    </xp:eventHandler>
                </xp:button>
            </xp:td>
        </xp:tr>
    </xp:table>
    <xp:br></xp:br>

 

then I added a combox that displays the names that matches the search query.

    <xp:table>

        <xp:tr>
            <xp:td>Username</xp:td>
            <xp:td>

                <xp:comboBox value="#{document1.Username}" id="comboBox1">
                    <xp:selectItems id="selectItems1">
                        <xp:this.value><![CDATA[#{javascript:var dbname =new Array("", "names.nsf");
var txtControlValue = getComponent("Name").getValue();
if (txtControlValue == '') {
    return null;
} else {
    getComponent("userInfo").setRendered(true);
    return @DbLookup(dbname,"$VIMPeople",txtControlValue, 1, "[PARTIALMATCH]");
}}]]></xp:this.value>
                    </xp:selectItems>
                    <xp:eventHandler event="onchange" submit="true"
                        refreshMode="partial" id="eventHandler1">
                        <xp:this.action>
                            <xp:setValue binding="#{viewScope.username1}"
                                value="#{javascript:this.parent.getValue()}">
                            </xp:setValue>
                        </xp:this.action>
                    </xp:eventHandler>
                </xp:comboBox>
            </xp:td>
        </xp:tr>
    </xp:table>

 


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.