【问题标题】:JSF ActionListener doesn't fireJSF ActionListener 不触发
【发布时间】:2014-03-05 15:32:45
【问题描述】:

调用函数vcardController.renderModify 的动作侦听器不会触发(在函数renderModify 中我将变量renderHiddenEdit 设置为true)并且editCardForm 中的面板不会呈现。有人可以帮助我吗?

<h:form id="editCardForm">
                <p:panel id="editCard"  style="">
                    <p:panel rendered="#{vcardController.renderHiddenEdit}" >
                        <h:inputHidden id="resourceid" value="#{vcardController.resourceId}" />
                        <h:inputHidden id="vcardraw" value="#{vcardController.vcardRaw}" />
                        <h:graphicImage alt="" style="width: 3em;" class="imagesearch" url="#{resource['img:user.svg']}"/>
                    </p:panel>
                </p:panel>
            </h:form>

            <h:form id="viewCardForm">
                <p:panel id="viewCard" style="">
                    <p:panel rendered="#{vcardController.renderHidden}" >
                        <h:inputHidden id="resourceid" value="#{vcardController.resourceId}" />
                        <h:inputHidden id="vcardraw" value="#{vcardController.vcardRaw}" />
                        <p:commandButton
                            id="testmodifica"
                            class="mod nocorner modifycard"
                            value="modify"
                            update=":editCardForm"
                            actionListener="#{vcardController.renderModify}" />
                    </p:panel>
                </p:panel>
            </h:form> 

            <h:form id="formReqEdit" class="formReqEdit" style="display: none;">
                <h:inputHidden id="vcardraw" value="#{vcardController.vcardRaw}" />
                <h:inputHidden id="resourceid" value="#{vcardController.resourceId}" />
                <p:commandButton
                    id="requestForm"
                    style="display: none;"
                    update=":viewCardForm"
                    oncomplete="contactsDOMAction.showCard(xhr, status, args)"
                    actionListener="#{vcardController.activateModifyCard}" />   
            </h:form> 

【问题讨论】:

  • 如何触发按钮动作???显示:无??可以放更多信息吗??
  • @RafaHernández 来自 javascript 代码我选择 requestForm 并触发点击事件以触发按钮操作 $("#requestForm").click()
  • 对不起,我写错了。我现在纠正它。

标签: jsf primefaces


【解决方案1】:
  1. 如果要渲染“editCardForm”,必须将“editCardForm”放入命令按钮的更新参数中
  2. 良好的做法是添加“流程”。然后,您确定将来自组件的哪些数据发送到 bean,在您的情况下 process="@this" 如果您只想调用动作侦听器。

  3. Rafa Hernández 说得对,如果它有 display:none,你希望如何按下按钮?

【讨论】:

  • 对不起,我写错了。我现在纠正它。
  • 正如 Damian S. 所说,设置 process="@this" 工作。我试过了。
猜你喜欢
  • 2014-08-28
  • 1970-01-01
  • 1970-01-01
  • 2012-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-22
  • 1970-01-01
相关资源
最近更新 更多