사용하십시오 viewScope 예를 들어, 감사합니다 viewScope.selectItems
변수.
- 이 viewScope를 selectItems 목록으로 사용하십시오.
- 초기 값을 추가하십시오.
- 나중에이 viewScope에 새 항목을 추가하면 콤보 상자의 선택 항목 목록에 나타납니다.
이 동작하는 예제입니다 : 내가 applicationScope를 사용하는 경우 값이 영구적으로 남아있을 것입니다
<xp:comboBox
id="comboBox1"
value="#{sessionScope.test}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
if (!viewScope.selectItems) {
viewScope.selectItems = ["your","initial","values"];
}
return viewScope.selectItems;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
<xp:inputText
id="inputText1"
value="#{viewScope.newItem}">
</xp:inputText>
<xp:button
value="Add to selectItems"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
viewScope.selectItems.add(viewScope.newItem);
viewScope.newItem = "";
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
? 그 값들이 저장되기를 바랍니다. 고맙습니다. –
사실은 영구적입니다. applicationScope의 수명이 길기 때문입니다. http 작업 또는 서버를 다시 시작하거나 코드를 변경하면 applicationScope가 재설정됩니다. 값을 영구히 저장하려면 예를 들어 값을 저장해야합니다. Notes 문서. –
@ Flopet17 해당 필드에 저장된 모든 값을 포함하는 열이있는보기가있는 경우 DbColumn 수식을 사용하여 selectItems 목록을 작성할 수 있습니다. 또는 범위가 지정된 변수에 의존하지 않고 가능한 값을 저장하도록 구성 문서를 만드는 것을 고려할 수도 있습니다. –