javascript - How to sort xPage multiline editBox by field converter? -
i have multiline edit box on page. want converter converts entered text list (replaces e.g. comas new line) @unique , sort on save. here code doesn't work:
<xp:inputtextarea value="#{document1.members}" id="inputmembers" multipletrim="true" immediate="true"> <xp:this.multipleseparator><![cdata[#{javascript:"\n"}]]></xp:this.multipleseparator> <xp:this.converter> <xp:customconverter> <xp:this.getasobject><![cdata[#{javascript:@unique(value).sort();}]]></xp:this.getasobject> <xp:this.getasstring><![cdata[#{javascript:@replacesubstring(value, ",", "\n");}]]></xp:this.getasstring> </xp:customconverter> </xp:this.converter>
it replace comas new line doesn't sort list
don't use multipleseparator property. otherwise, getasobject converter executed every entry (=line) separately. that's why sort doesn't work.
implode entries "\n" instead when converting value browser (getasstring) , explode multiple lines , comma separated values when getting lines browser (getasobject) , sort resulting array:
<xp:inputtextarea value="#{document1.members}" id="inputmembers" rows="10"> <xp:this.converter> <xp:customconverter> <xp:this.getasobject><![cdata[#{javascript: @unique(@trim(@explode(value, ["\n", ","]))).sort() }]]></xp:this.getasobject> <xp:this.getasstring><![cdata[#{javascript: @implode(value, "\n") }]]></xp:this.getasstring> </xp:customconverter> </xp:this.converter> </xp:inputtextarea>
Comments
Post a Comment