如果所需输入有部分,ADFfaces 会立即忽略触发提交组件

发布于 2024-11-16 01:55:42 字数 293 浏览 6 评论 0原文

如果 selectOneChoice 设置为我想从 inputText 中删除必需的属性,因此 inputText 将具有 partialTrigger selectOneChoice 的 id代码>,但是当我更改 selectOneChoice 中的值(并且提交更改)时,仍然会仅为需要更新的组件触发所需的验证(因为存在partialTriggers)组件不会触发其验证。
有什么解决方法吗?

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.
Any workarounds ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如梦亦如幻 2024-11-23 01:55:42

您需要在 valueChangeListener 中更改所需的指示符。这将在模型更新之前发生。

例如,给定这个 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>

而这位听众,你会得到你所描述的行为。

public void selectionChange(ValueChangeEvent valueChangeEvent) {
    String newValue = valueChangeEvent.getNewValue().toString();
    RichInputText it = (RichInputText)valueChangeEvent.getComponent().findComponent("it1");
    it.setRequired(!"two".equals(newValue));
}

You need to change the required indicator in a valueChangeListener. This will happen before the model is updated.

For example, given this JSF fragment.

<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));
}
迷爱 2024-11-23 01:55:42

您可以发布 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>

Can you post the EL expression for the required attribute of your inputText?

<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>
时光倒影 2024-11-23 01:55:42

如果您想跳过验证,请在 pagedef 上将“跳过验证”设置为 True。

If you want to skip the validation then make the Skip Validation to True on pagedef.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文