【问题标题】:Is it possible to disable AJAX in RichFaces?是否可以在 RichFaces 中禁用 AJAX?
【发布时间】:2010-11-24 19:19:49
【问题描述】:

是否可以在 Seam/RichFaces 页面中禁用 AJAX,以便通过常规服务器-客户端请求发送请求,刷新整个页面而不是单个元素?我正在使用a4j:outputPanela4j:commandButton,并且需要通过切换按钮让它们在某些情况下不使用 AJAX。

这是页面中的代码 sn-p。谢谢。

<a4j:outputPanel id="output" rendered="#{not empty overtime.overtimeItems}" 
    ajaxRendered="true">
  <c:forEach items="#{overtime.overtimeItems}" var="oc">
    <h:outputLabel value="#{oc.dateLabel}"
      style="font-weight:#{(oc.id == 1) ? 'bold' : 'normal'}" 
      for="#{oc.overtimeDateId}" />
    <rich:calendar value="#{oc.overtimeDate}" 
      requiredMessage="Date 1 is required."
      id="#{oc.overtimeDateId}" datePattern="MM-dd-yyyy" 
      required="#{oc.id == 1 ? true : false}" firstWeekDay="0">
      <a4j:support event="onchanged" 
         reRender="#{oc.overtimeHoursId}, #{oc.overtimeHoursOutputId}" 
         ajaxSingle="true"/>
    </rich:calendar>
    ......

  </c:foreach>
</a4j:outputPanel>

<a4j:commandButton action="#{utilities.sendEmail('/pages/overtime/mail.xhtml')}" 
    type="submit" value="Submit" 
    reRender="status, valid1, valid2" eventsQueue="foo" status="status" 
    onclick="this.disabled=false" id="btnSubmit"
    oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.hideModalPanel(\'mpErrors\');' : 'Richfaces.showModalPanel(\'mpErrors\'); this.disabled=false'}"/>

【问题讨论】:

  • 我创建了一个没有 a4j 组件的页面版本。找不到其他方法。

标签: ajax richfaces seam


【解决方案1】:

这样做的唯一方法是将这些 ajax 组件包装在面板组中并使用渲染属性。您基本上需要提供条件渲染并提供 ajax 组件的非 ajax 替代方案。

所以你会有类似的东西:

<h:panelGroup rendered="#{someBean.ajaxEnabled}">
    <a4j:commandButton ..... />
</h:panelGroup>

<h:panelGroup rendered="#{!someBean.ajaxEnabled}">
    <h:commandButton ..... />
</h:panelGroup>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-07
    • 2010-11-01
    相关资源
    最近更新 更多