1
votes

I have a form displayed in read mode using custom control which is bound to a view scoped bean. I need to have a picker on this CC so that users can select other documents. These display as links (generated using repeat control). I planned to trigger a method in my view scoped bean to save this value when selection changes.

Now I am stuck with:

  1. onChange event of multi-valued field (used with picker) does not trigger SSJS code
  2. I tried creating a button which I clicked using CSJS on onChange of above field - this does not work either.

In short, SSJS code is not being triggered.

This is troubling me as I have a created a file download control wherein I have added a remove button calling a method in bean and it works just fine.

I am using Debugtoolbar by Mark Leusink and I am not able to display a simple message or set any scope variable. this is happening for onChange and onClick events!! I have provided my CC code below. If you want you can put it in any Xpage bound to a view scoped bean.

    <?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
    <xp:panel id="panel1">
        <xp:inputTextarea id="inputTextarea1" style="display:none" value="#{viewScope[compositeData.pickerDetails.beanName][compositeData.pickerDetails.saveToField]}"
            multipleSeparator=","
        >
            <xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="repeatLinks">
                <xp:this.action><![CDATA[#{javascript://viewScope[compositeData.pickerDetails.beanName][compositeData.pickerDetails.saveToField]= getComponent("inputTextarea1").getValue();
//viewScope.get(compositeData.pickerDetails.beanName).setValue(compositeData.pickerDetails.saveToField,getComponent("inputTextarea1").getValue());
//viewScope[compositeData.pickerDetails.beanName].linkDocs(compositeData.pickerDetails.saveToField,getComponent("inputTextarea1").getValue());}]]></xp:this.action>
                <xp:this.script><![CDATA[//console.log("Btn found : "+document.getElementById(getID("btnLinks")));
document.getElementById(getID("btnLinks")).click();]]></xp:this.script>
            </xp:eventHandler>
        </xp:inputTextarea>
        <xe:valuePicker id="valuePicker1" listHeight="auto" listWidth="auto" dialogTitle="#{javascript:compositeData.pickerDetails.title}" for="inputTextarea1">
            <xe:this.dataProvider>
                <xe:simpleValuePicker labelSeparator="|">
                    <xe:this.valueList><![CDATA[#{javascript:var cd = compositeData.pickerDetails;
getPickerList(cd.viewName,cd.filter,cd.filterField);}]]></xe:this.valueList>
                </xe:simpleValuePicker>
            </xe:this.dataProvider>
        </xe:valuePicker>
        <xp:repeat id="repeatLinks" rows="30" var="docLink">
            <xp:this.value><![CDATA[#{viewScope[compositeData.pickerDetails.beanName][compositeData.pickerDetails.saveToField]}]]></xp:this.value>
            <xp:text escape="false" id="computedField1">
                <!-- Link is generated here -->
            </xp:text>
            <xp:br></xp:br>
        </xp:repeat>

        <xp:button value="Click Me" id="btnLinks" refreshId="repeatLinks" refreshMode="partial">
            <xp:this.onclick><![CDATA[#{javascript:viewScope[compositeData.pickerDetails.beanName].linkDocs(compositeData.pickerDetails.saveToField,getComponent("inputTextarea1").getValue());}]]></xp:this.onclick>
        </xp:button>
    </xp:panel>
</xp:view>
2

2 Answers

1
votes

You mention this is a custom control. The most likely cause then is validation failure elsewhere on the page. Your button calls SSJS without execMode="partial" and an execId. This means the complete XPage is validated during the partial refresh. Your refreshId doesn't include an errors block, so there's nothing to alert the user (and you!) if there is a validation error.

Setting execMode="partial" and execId="panel1" on your button should resolve the problem.

If that's the case, for the future I would recommend adding a PhaseListener into your applications so you can easily output what phases are being triggered and/or always ensuring the refreshArea includes an errors control.

1
votes

If you remove the style "display:none;" does the code then trigger?

There might be a validation failure that's taking place. What happens if you select "process data without validation" for these events?