[英]ADFfaces Ignores Immediate if the required input has partialTrigger the submiting component
I have a selectOneChoice
with autoSubmit=true
and immediate=true
to skip validation, if the selectOneChoice
is set to some value I want to remove the required attribute from an inputText , so the inputText
will have partialTrigger
the id of the selectOneChoice
, but when I change the value from the selectOneChoice
(and the change is submitted) the required validation is still triggered just for the component which needs to be updated (because of the presence of the partialTriggers) the other required components doesn't trigger its validation. 我有一个selectOneChoice
, autoSubmit=true
和immediate=true
跳过验证,如果selectOneChoice
设置为某个值我想从inputText中删除所需的属性 ,所以inputText
将partialTrigger
作为selectOneChoice
的id,但是当我更改selectOneChoice
的值(并且提交更改)仍然仅针对需要更新的组件触发所需的验证(由于存在partialTriggers),其他所需组件不会触发其验证。
Any workarounds ? 任何解决方法?
You need to change the required indicator in a valueChangeListener. 您需要在valueChangeListener中更改所需的指标。 This will happen before the model is updated. 这将在模型更新之前发生。
For example, given this JSF fragment. 例如,给定这个JSF片段。
<af:panelFormLayout id="pfl1">
<af:inputText label="Label 1" id="it1" value="#{pageFlowScope.RemoveRequiredBean.myValue}" required="true" partialTriggers="soc1"/>
<af:selectOneChoice label="Selection" value="#{pageFlowScope.RemoveRequiredBean.selection}" id="soc1" autoSubmit="true" immediate="true"
valueChangeListener="#{pageFlowScope.RemoveRequiredBean.selectionChange}">
<af:selectItem label="one" value="one" id="si3"/>
<af:selectItem label="two" value="two" id="si1"/>
<af:selectItem label="three" value="three" id="si2"/>
</af:selectOneChoice>
<af:commandButton text="commandButton 1" id="cb1"/>
<f:facet name="footer"/>
</af:panelFormLayout>
And this listener, you get the behavior you describe. 而这个听众,你得到你描述的行为。
public void selectionChange(ValueChangeEvent valueChangeEvent) {
String newValue = valueChangeEvent.getNewValue().toString();
RichInputText it = (RichInputText)valueChangeEvent.getComponent().findComponent("it1");
it.setRequired(!"two".equals(newValue));
}
如果要跳过验证,请在pagedef上将Skip Validation设置为True。
Can you post the EL expression for the required attribute of your inputText? 你可以发布你的inputText所需属性的EL表达式吗?
<af:inputText label="ResId" id="it1" required="#{someValueExpression}"
partialTriggers="soc1">
</af:inputText>
<af:selectOneChoice label="Label 1" id="soc1" autoSubmit="true">
<af:selectItem label="test" value="test" id="si1"/>
<af:selectItem label="test2" value="test2" id="si12"/>
</af:selectOneChoice>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.