【问题标题】:How to call action when select noSelectionLabel?选择 noSelectionLabel 时如何调用操作?
【发布时间】:2011-09-30 20:03:19
【问题描述】:

我有上面的这段代码,当我选择他身上的一些项目时,它可以完美运行... a4j:support 工作正常并正确重新呈现我的另一个字段... 问题是如果我选择一个项目,然后我回到“noSelectionLabel”...... 当我出于某种原因这样做时,我的 a4j:support 不起作用,我没有进入我的方法“setarFormulario”,也没有重新渲染我的另一个字段......

<s:decorate template="layout/form.xhtml">
            <ui:define name="label">Evento:</ui:define>
            <h:selectOneMenu value="#{home.instance.evento}" required="true">
                <s:selectItems value="#{eventoService.obterTodos()}" var="evento" label="#{messages[evento.nome]}"  noSelectionLabel="#{messages['br.com.message.NoSelection']}" />
                <s:convertEntity  />
                <a4j:support event="onchange"  action="#{home.setarFormulario}" reRender="camposFormulario" ajaxSingle="true"  />
            </h:selectOneMenu>
        </s:decorate>

即使我选择了 noSelectionLabel,我如何才能进入我的方法?那么我的 home.instance.evento 必须为 null.. 或类似的东西...

【问题讨论】:

    标签: jsf richfaces seam selectonemenu


    【解决方案1】:

    Yor 字段 h:selectOneMenu 是必需的,然后选择 noSelectionLabel 值将导致验证错误,如果您有验证错误,则永远不会调用 action="#{home.setarFormulario}"

    作为一种解决方法,您可以将hideNoSelectionLabels:selectItems 属性设置为true,然后在选择值时隐藏 noSelectionLabel

    【讨论】:

    • 谢谢!我以前用另一种解决方法解决过...我已经提出了“required=true”...然后我的 setarFormulario 方法被调用...但是以这种方式解决你看起来更好:) 谢谢!
    【解决方案2】:
    <h:message for="id of the selectonemenu component " ></h:message>
    

    selectonemenu 标记中删除required =true

    【讨论】:

      猜你喜欢
      • 2013-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-08
      相关资源
      最近更新 更多