0
votes

I can't figure out where this is going wrong, I have almost the exact same code working on another page. I have the valuePicker getting its values from a viewScope.vsFieldNames and I know that it is populated before I click the value picker, but when the picker dialog displays I get the error

TypeError: resp is null

the field reqOnSave is a multiline edit box and it is null but I don't think that should make any difference. I have used a scope variable as the valueList in several other pages without trouble. I'm sure I'm missing something simple.

Edited Oct 17 My page looks like this:

Page Layout

When I click on Select Fields I get the display below. I know that viewScope.vsFieldNames is properly populated at this point because I examine it using the debug Tool Bar.

I really don't like the xe:valuePicker because it calls a dialog and I would prefer something like a multi-select combobox, but there is not a standard core or Extension Library control that does this (at least that I can find).

Error Message

Here is my complete code:

   <div class="row">
        <div class="col-sm-2">
            <xp:label value="Application" id="label1"
                for="ApplicationCombo">
            </xp:label>
        </div>
        <div class="col-sm-4">
            <xp:comboBox id="ApplicationCombo"
                value="#{formDoc.Application}">
                <xp:selectItems>
                    <xp:this.value><![CDATA[#{javascript:var rtn:Array = database.getView("vwWFSApplicationsEnabled").getColumnValues(0);
rtn.unshift("");}]]></xp:this.value>
                </xp:selectItems>
                <xp:eventHandler event="onchange" submit="true"
                    refreshMode="partial" refreshId="panelBody">
                    <xp:this.action>
                        <![CDATA[#{javascript:try{formDoc.replaceItemValue("FormName","");
}catch(e){

}}]]>
                    </xp:this.action>
                </xp:eventHandler>
            </xp:comboBox>
        </div>
    </div>
    <xp:panel id="panelBody">
    <xp:text escape="true" id="computedField1">
        <xp:this.value><![CDATA[#{javascript:try{
    var app:string = formDoc.getValue("Application");
    var debug:Boolean = true;
    if (debug) WFSUtils.sysOut("Application = " + app);
    var form:String = formDoc.getValue("FormName");
    if (debug) WFSUtils.sysOut("Form = " + form);
    if (!(app == null || app == "")){
        if ((!(form.substring(0,3) == "---")) && (!(form == null || form == ""))) {
            if (debug) WFSUtils.sysOut("Form Name = " + form);
            var thisForm:NotesForm = appProps[app].appDB.getForm(form);
            if (debug) WFSUtils.sysOut("Got Form Name = " + thisForm.getName());
            var rtn:Array = thisForm.getFields();
            if (debug) WFSUtils.sysOut("Rtn = " + rtn.toString());
            viewScope.vsFieldNames = rtn;
            return null
        }
    }
    viewScope.vsFieldNames = null;
    return null
}catch(e){

    WFSUtils.sysOut("Error in Get Fields " + e.toString());
    viewScope.vsFieldNames = null;
    return null;
}}]]></xp:this.value>
    </xp:text>
    <div class="row">
            <div class="col-sm-2">
                <xp:label value="Form Name :" id="label2"
                    for="FormCombo">
                </xp:label>
            </div>
            <div class="col-sm-4">
                <xp:comboBox id="comboBox1"
                    value="#{formDoc.FormName}">
                    <xp:selectItems>
                        <xp:this.value>
                            <![CDATA[#{javascript:var app:string = formDoc.getValue("Application");
if (!(app == null || app == "")){
    var rtn = appProps[app].appDB.getView("vwWFSForms").getColumnValues(0);
    rtn = sort_unique(rtn);
    rtn.unshift("--- Select A Form ---");
    return rtn
}else{
    return null
}}]]>
                        </xp:this.value>
                    </xp:selectItems>
                    <xp:eventHandler event="onchange" submit="true"
                        refreshMode="partial" refreshId="panelBody">
                    </xp:eventHandler>
                </xp:comboBox>
            </div>
        </div><!-- row Form -->
        <div class="row">
            <div class="col-sm-2">
                <xp:label value="Required Fields On Save :" id="label3"
                    for="djComboReqOnSave">
                </xp:label>
            </div>
            <div class="col-sm-4">
                <xe:valuePicker id="pickerFields"
                    dialogTitle="Select One or More Fields" for="reqOnSave"
                    pickerText="Select Field/s :">
                    <xe:this.dataProvider>
                        <xe:simpleValuePicker caseInsensitive="false">
                            <xe:this.valueList><![CDATA[${javascript:viewScope.vsFieldNames;
}]]></xe:this.valueList>
                        </xe:simpleValuePicker>
                    </xe:this.dataProvider>
                </xe:valuePicker>

            </div>
            <div class="col-sm-2">
                <xp:inputTextarea id="reqOnSave"
                    value="#{formDoc.ReqOnSave}" multipleSeparator=",">
                </xp:inputTextarea>
            </div>
        </div><!-- row reqOnSave -->
        <div class="row">

        </div>
    </xp:panel>
1
What control is "resp"? - Per Henrik Lausten
Looks as if there was something inside the container called "panelBody" that is trying to do something with a control or an object called "resp" as soon as "panelBody" is updated. You say this is working within a different page; that will be the key: what are the differences? - Lothar Mueller
Something else I just realized: the screenshot shows something looking like an alert (XPiNC?), but its title "TestError" is somewhat special, doesn't look like a standard system alert, and your code is referring to an object "WFSUtils"; maybe you need to look in there for that mysterious "resp" object... - Lothar Mueller
Not an answer to your question, but something to be noted I feel. I always got "resp is null" with value picker when I lost the session ( as in when the session expired). - Chintan Parekh
Paul's answer below fixed the problem. Lothar WFSUtils.sysOut simply formates a message then prints it to the server console. and "TestError" is the name of the XPage being called. - Bill F

1 Answers

2
votes

resp is the Client-Side JavaScript variable passed to the picker, so the picker doesn't have any options loaded to it.

The ValuePicker uses ${javascript:viewScope.vsFieldNames;}. So the fact that it's visible using debug toolbar may be misleading, because the debug toolbar is showing the output after the values have been loaded to the ValuePicker.

To use that code, you'll need to be setting viewScope.vsFieldNames in beforePageLoad event. To double-check it's not null when the code is running, amend to debug out the content before calling viewScope.vsFieldNames, e.g. ${javascript:print(viewScope.vsFieldNames); return viewScope.vsFieldNames;}. The chances are that when it's running the value is not initialised yet.

If you can't set it in beforePageLoad, to solve the problem, instead of ${javascript:viewScope.vsFieldNames;} (SSJS page load) use #{viewScope.vsFieldNames} (EL dynamic). That should work, you'll be avoiding the SSJS parser, so performance will not be negatively impacted.