How to reset/clear a xp:typeAhead for an xp:inputText in Xpages?

68 Views Asked by At

on my Xpage I have in inputbox that has a data-binding via a managed bean:

<xp:inputText id="sId1" styleClass=" form-control" required="true" style="width:100%; padding: 4px 12px;" value="#{mandateBean.mandate.userId}" disableTheme="true">

The inputbox also has a typeahead feature:

<xp:typeAhead mode="full" minChars="3" var="searchValue" valueMarkup="true" valueList="#{javascript:functionsBean.getTypeAheadUserInfo(searchValue);}"></xp:typeAhead>

I would like to reset the inputbox via a link but this does not seem to have an effect:

<xp:link id="link1"><xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:mandateBean.getMandate().setUserId("")}]]></xp:this.action>
</xp:eventHandler></xp:link>

How should I reset the inputbox properly?

1

There are 1 best solutions below

0
Thomas Adrian On

Just add an event to the inputText and reset the field, example in jquery

<xp:eventHandler event="onchange" submit="false">
                                    <xp:this.script><![CDATA[$("[id$='inputText2']").val('');]]></xp:this.script>
                                </xp:eventHandler>