【问题标题】:p:commandLink does not work , when ajax renderedp:commandLink 不起作用,当 ajax 呈现时
【发布时间】:2013-10-29 14:49:04
【问题描述】:

我正在尝试构建一个 ajax 表单。我使用名为“pageMode”的 bean 变量来保存表单的状态(开始、确认...等)。根据pageMode的值,我的jsf页面渲染或者不渲染一些按钮。 (启动时只显示提交按钮,提交后显示确认按钮...)

这是我的问题;

第一次访问页面时提交按钮工作正常,但提交后确认按钮无法正常工作(不触发 bean 方法)意味着 pageMode=confirm,

我试图用 h:pannelGrid 包裹我的按钮并将 rendred 属性赋予它.. 没用 :((.

xhtml 是这样的;

<h:form id="ApplicationForm" styleClass ="form-horizontal well"> 

    <p:panel header="#{msg.bilgiler}" id="formVars"  styleClass="well">

    <h:panelGrid styleClass="defaultTable" id="pg" columns="2">
        <h:outputText value="#{msg.ad}"/>
        <p:inputText value="#{applicationFormInc.userData.userName}" rendered="#{applicationFormInc.pageMode=='start'}"/>
        <h:outputText value="#{applicationFormInc.userData.userName}"  rendered="#{applicationFormInc.pageMode=='confirm'}"/>

        ...

        <p:commandLink styleClass="btn btn-primary" update="pg,confirmButtons" rendered="#{applicationFormInc.pageMode=='start'}"
                                   action="#{applicationFormInc.confirmActionAjax}" value="Submit">
                        <i class="icon-remove icon-white"></i>
                    </p:commandLink>
        <h:panelGrid id="confirmButtons" >
        <p:commandLink styleClass="btn btn-primary" update="pg" rendered="#{applicationFormInc.pageMode=='confirm'}"
                       action="#{applicationFormInc.executeAction}" value="ConfirmAndSave" >
                        <i class="icon-remove icon-white"></i>
                    </p:commandLink>

            </h:panelGrid>
    </h:panelGrid>
    </p:panel>

</h:form>

Bean 端执行动作

 public String executeAction(){
    DbTools tr = new DbTools();
    tr.insertRecord(getUserData()); 
    return "index.xhtml?faces-redirect=true";
}

谢谢。

【问题讨论】:

  • 你能发布executeAction代码吗?还是其中的一部分?
  • 添加了 executeAction...

标签: jsf primefaces


【解决方案1】:

用你的 commandLinks 定义你想要处理的东西 -

<p:commandLink .... process="ApplicationForm" >

或者如果您不想处理任何输入:

<p:commandLink .... process="@this" >

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 2013-01-23
    • 2017-06-23
    • 2020-07-12
    • 1970-01-01
    相关资源
    最近更新 更多